babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4100. static readonly GEQUAL: number;
  4101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areLightsDisposed: boolean;
  7692. /** @hidden */
  7693. _areAttributesDirty: boolean;
  7694. /** @hidden */
  7695. _areTexturesDirty: boolean;
  7696. /** @hidden */
  7697. _areFresnelDirty: boolean;
  7698. /** @hidden */
  7699. _areMiscDirty: boolean;
  7700. /** @hidden */
  7701. _areImageProcessingDirty: boolean;
  7702. /** @hidden */
  7703. _normals: boolean;
  7704. /** @hidden */
  7705. _uvs: boolean;
  7706. /** @hidden */
  7707. _needNormals: boolean;
  7708. /** @hidden */
  7709. _needUVs: boolean;
  7710. [id: string]: any;
  7711. /**
  7712. * Specifies if the material needs to be re-calculated
  7713. */
  7714. readonly isDirty: boolean;
  7715. /**
  7716. * Marks the material to indicate that it has been re-calculated
  7717. */
  7718. markAsProcessed(): void;
  7719. /**
  7720. * Marks the material to indicate that it needs to be re-calculated
  7721. */
  7722. markAsUnprocessed(): void;
  7723. /**
  7724. * Marks the material to indicate all of its defines need to be re-calculated
  7725. */
  7726. markAllAsDirty(): void;
  7727. /**
  7728. * Marks the material to indicate that image processing needs to be re-calculated
  7729. */
  7730. markAsImageProcessingDirty(): void;
  7731. /**
  7732. * Marks the material to indicate the lights need to be re-calculated
  7733. * @param disposed Defines whether the light is dirty due to dispose or not
  7734. */
  7735. markAsLightDirty(disposed?: boolean): void;
  7736. /**
  7737. * Marks the attribute state as changed
  7738. */
  7739. markAsAttributesDirty(): void;
  7740. /**
  7741. * Marks the texture state as changed
  7742. */
  7743. markAsTexturesDirty(): void;
  7744. /**
  7745. * Marks the fresnel state as changed
  7746. */
  7747. markAsFresnelDirty(): void;
  7748. /**
  7749. * Marks the misc state as changed
  7750. */
  7751. markAsMiscDirty(): void;
  7752. /**
  7753. * Rebuilds the material defines
  7754. */
  7755. rebuild(): void;
  7756. /**
  7757. * Specifies if two material defines are equal
  7758. * @param other - A material define instance to compare to
  7759. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7760. */
  7761. isEqual(other: MaterialDefines): boolean;
  7762. /**
  7763. * Clones this instance's defines to another instance
  7764. * @param other - material defines to clone values to
  7765. */
  7766. cloneTo(other: MaterialDefines): void;
  7767. /**
  7768. * Resets the material define values
  7769. */
  7770. reset(): void;
  7771. /**
  7772. * Converts the material define values to a string
  7773. * @returns - String of material define information
  7774. */
  7775. toString(): string;
  7776. }
  7777. }
  7778. declare module "babylonjs/Materials/colorCurves" {
  7779. import { Effect } from "babylonjs/Materials/effect";
  7780. /**
  7781. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7782. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7783. * 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;
  7784. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7785. */
  7786. export class ColorCurves {
  7787. private _dirty;
  7788. private _tempColor;
  7789. private _globalCurve;
  7790. private _highlightsCurve;
  7791. private _midtonesCurve;
  7792. private _shadowsCurve;
  7793. private _positiveCurve;
  7794. private _negativeCurve;
  7795. private _globalHue;
  7796. private _globalDensity;
  7797. private _globalSaturation;
  7798. private _globalExposure;
  7799. /**
  7800. * Gets the global Hue value.
  7801. * 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).
  7802. */
  7803. /**
  7804. * Sets the global Hue value.
  7805. * 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).
  7806. */
  7807. globalHue: number;
  7808. /**
  7809. * Gets the global Density value.
  7810. * 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.
  7811. * Values less than zero provide a filter of opposite hue.
  7812. */
  7813. /**
  7814. * Sets the global Density value.
  7815. * 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.
  7816. * Values less than zero provide a filter of opposite hue.
  7817. */
  7818. globalDensity: number;
  7819. /**
  7820. * Gets the global Saturation value.
  7821. * 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.
  7822. */
  7823. /**
  7824. * Sets the global Saturation value.
  7825. * 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.
  7826. */
  7827. globalSaturation: number;
  7828. /**
  7829. * Gets the global Exposure value.
  7830. * 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.
  7831. */
  7832. /**
  7833. * Sets the global Exposure value.
  7834. * 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.
  7835. */
  7836. globalExposure: number;
  7837. private _highlightsHue;
  7838. private _highlightsDensity;
  7839. private _highlightsSaturation;
  7840. private _highlightsExposure;
  7841. /**
  7842. * Gets the highlights Hue value.
  7843. * 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).
  7844. */
  7845. /**
  7846. * Sets the highlights Hue value.
  7847. * 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).
  7848. */
  7849. highlightsHue: number;
  7850. /**
  7851. * Gets the highlights Density value.
  7852. * 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.
  7853. * Values less than zero provide a filter of opposite hue.
  7854. */
  7855. /**
  7856. * Sets the highlights Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. highlightsDensity: number;
  7861. /**
  7862. * Gets the highlights Saturation value.
  7863. * 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.
  7864. */
  7865. /**
  7866. * Sets the highlights Saturation value.
  7867. * 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.
  7868. */
  7869. highlightsSaturation: number;
  7870. /**
  7871. * Gets the highlights Exposure value.
  7872. * 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.
  7873. */
  7874. /**
  7875. * Sets the highlights Exposure value.
  7876. * 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.
  7877. */
  7878. highlightsExposure: number;
  7879. private _midtonesHue;
  7880. private _midtonesDensity;
  7881. private _midtonesSaturation;
  7882. private _midtonesExposure;
  7883. /**
  7884. * Gets the midtones Hue value.
  7885. * 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).
  7886. */
  7887. /**
  7888. * Sets the midtones Hue value.
  7889. * 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).
  7890. */
  7891. midtonesHue: number;
  7892. /**
  7893. * Gets the midtones Density value.
  7894. * 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.
  7895. * Values less than zero provide a filter of opposite hue.
  7896. */
  7897. /**
  7898. * Sets the midtones Density value.
  7899. * 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.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. midtonesDensity: number;
  7903. /**
  7904. * Gets the midtones Saturation value.
  7905. * 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.
  7906. */
  7907. /**
  7908. * Sets the midtones Saturation value.
  7909. * 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.
  7910. */
  7911. midtonesSaturation: number;
  7912. /**
  7913. * Gets the midtones Exposure value.
  7914. * 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.
  7915. */
  7916. /**
  7917. * Sets the midtones Exposure value.
  7918. * 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.
  7919. */
  7920. midtonesExposure: number;
  7921. private _shadowsHue;
  7922. private _shadowsDensity;
  7923. private _shadowsSaturation;
  7924. private _shadowsExposure;
  7925. /**
  7926. * Gets the shadows Hue value.
  7927. * 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).
  7928. */
  7929. /**
  7930. * Sets the shadows Hue value.
  7931. * 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).
  7932. */
  7933. shadowsHue: number;
  7934. /**
  7935. * Gets the shadows Density value.
  7936. * 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.
  7937. * Values less than zero provide a filter of opposite hue.
  7938. */
  7939. /**
  7940. * Sets the shadows 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. shadowsDensity: number;
  7945. /**
  7946. * Gets the shadows Saturation value.
  7947. * 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.
  7948. */
  7949. /**
  7950. * Sets the shadows Saturation value.
  7951. * 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.
  7952. */
  7953. shadowsSaturation: number;
  7954. /**
  7955. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  7957. */
  7958. /**
  7959. * Sets the shadows Exposure value.
  7960. * 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.
  7961. */
  7962. shadowsExposure: number;
  7963. /**
  7964. * Returns the class name
  7965. * @returns The class name
  7966. */
  7967. getClassName(): string;
  7968. /**
  7969. * Binds the color curves to the shader.
  7970. * @param colorCurves The color curve to bind
  7971. * @param effect The effect to bind to
  7972. * @param positiveUniform The positive uniform shader parameter
  7973. * @param neutralUniform The neutral uniform shader parameter
  7974. * @param negativeUniform The negative uniform shader parameter
  7975. */
  7976. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7977. /**
  7978. * Prepare the list of uniforms associated with the ColorCurves effects.
  7979. * @param uniformsList The list of uniforms used in the effect
  7980. */
  7981. static PrepareUniforms(uniformsList: string[]): void;
  7982. /**
  7983. * Returns color grading data based on a hue, density, saturation and exposure value.
  7984. * @param filterHue The hue of the color filter.
  7985. * @param filterDensity The density of the color filter.
  7986. * @param saturation The saturation.
  7987. * @param exposure The exposure.
  7988. * @param result The result data container.
  7989. */
  7990. private getColorGradingDataToRef;
  7991. /**
  7992. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7993. * @param value The input slider value in range [-100,100].
  7994. * @returns Adjusted value.
  7995. */
  7996. private static applyColorGradingSliderNonlinear;
  7997. /**
  7998. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7999. * @param hue The hue (H) input.
  8000. * @param saturation The saturation (S) input.
  8001. * @param brightness The brightness (B) input.
  8002. * @result An RGBA color represented as Vector4.
  8003. */
  8004. private static fromHSBToRef;
  8005. /**
  8006. * Returns a value clamped between min and max
  8007. * @param value The value to clamp
  8008. * @param min The minimum of value
  8009. * @param max The maximum of value
  8010. * @returns The clamped value.
  8011. */
  8012. private static clamp;
  8013. /**
  8014. * Clones the current color curve instance.
  8015. * @return The cloned curves
  8016. */
  8017. clone(): ColorCurves;
  8018. /**
  8019. * Serializes the current color curve instance to a json representation.
  8020. * @return a JSON representation
  8021. */
  8022. serialize(): any;
  8023. /**
  8024. * Parses the color curve from a json representation.
  8025. * @param source the JSON source to parse
  8026. * @return The parsed curves
  8027. */
  8028. static Parse(source: any): ColorCurves;
  8029. }
  8030. }
  8031. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8032. import { Observable } from "babylonjs/Misc/observable";
  8033. import { Nullable } from "babylonjs/types";
  8034. import { Color4 } from "babylonjs/Maths/math.color";
  8035. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8036. import { Effect } from "babylonjs/Materials/effect";
  8037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8038. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8039. /**
  8040. * Interface to follow in your material defines to integrate easily the
  8041. * Image proccessing functions.
  8042. * @hidden
  8043. */
  8044. export interface IImageProcessingConfigurationDefines {
  8045. IMAGEPROCESSING: boolean;
  8046. VIGNETTE: boolean;
  8047. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8048. VIGNETTEBLENDMODEOPAQUE: boolean;
  8049. TONEMAPPING: boolean;
  8050. TONEMAPPING_ACES: boolean;
  8051. CONTRAST: boolean;
  8052. EXPOSURE: boolean;
  8053. COLORCURVES: boolean;
  8054. COLORGRADING: boolean;
  8055. COLORGRADING3D: boolean;
  8056. SAMPLER3DGREENDEPTH: boolean;
  8057. SAMPLER3DBGRMAP: boolean;
  8058. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8059. }
  8060. /**
  8061. * @hidden
  8062. */
  8063. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8064. IMAGEPROCESSING: boolean;
  8065. VIGNETTE: boolean;
  8066. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8067. VIGNETTEBLENDMODEOPAQUE: boolean;
  8068. TONEMAPPING: boolean;
  8069. TONEMAPPING_ACES: boolean;
  8070. CONTRAST: boolean;
  8071. COLORCURVES: boolean;
  8072. COLORGRADING: boolean;
  8073. COLORGRADING3D: boolean;
  8074. SAMPLER3DGREENDEPTH: boolean;
  8075. SAMPLER3DBGRMAP: boolean;
  8076. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8077. EXPOSURE: boolean;
  8078. constructor();
  8079. }
  8080. /**
  8081. * This groups together the common properties used for image processing either in direct forward pass
  8082. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8083. * or not.
  8084. */
  8085. export class ImageProcessingConfiguration {
  8086. /**
  8087. * Default tone mapping applied in BabylonJS.
  8088. */
  8089. static readonly TONEMAPPING_STANDARD: number;
  8090. /**
  8091. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8092. * to other engines rendering to increase portability.
  8093. */
  8094. static readonly TONEMAPPING_ACES: number;
  8095. /**
  8096. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8097. */
  8098. colorCurves: Nullable<ColorCurves>;
  8099. private _colorCurvesEnabled;
  8100. /**
  8101. * Gets wether the color curves effect is enabled.
  8102. */
  8103. /**
  8104. * Sets wether the color curves effect is enabled.
  8105. */
  8106. colorCurvesEnabled: boolean;
  8107. private _colorGradingTexture;
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. /**
  8112. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8113. */
  8114. colorGradingTexture: Nullable<BaseTexture>;
  8115. private _colorGradingEnabled;
  8116. /**
  8117. * Gets wether the color grading effect is enabled.
  8118. */
  8119. /**
  8120. * Sets wether the color grading effect is enabled.
  8121. */
  8122. colorGradingEnabled: boolean;
  8123. private _colorGradingWithGreenDepth;
  8124. /**
  8125. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. /**
  8128. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8129. */
  8130. colorGradingWithGreenDepth: boolean;
  8131. private _colorGradingBGR;
  8132. /**
  8133. * Gets wether the color grading texture contains BGR values.
  8134. */
  8135. /**
  8136. * Sets wether the color grading texture contains BGR values.
  8137. */
  8138. colorGradingBGR: boolean;
  8139. /** @hidden */
  8140. _exposure: number;
  8141. /**
  8142. * Gets the Exposure used in the effect.
  8143. */
  8144. /**
  8145. * Sets the Exposure used in the effect.
  8146. */
  8147. exposure: number;
  8148. private _toneMappingEnabled;
  8149. /**
  8150. * Gets wether the tone mapping effect is enabled.
  8151. */
  8152. /**
  8153. * Sets wether the tone mapping effect is enabled.
  8154. */
  8155. toneMappingEnabled: boolean;
  8156. private _toneMappingType;
  8157. /**
  8158. * Gets the type of tone mapping effect.
  8159. */
  8160. /**
  8161. * Sets the type of tone mapping effect used in BabylonJS.
  8162. */
  8163. toneMappingType: number;
  8164. protected _contrast: number;
  8165. /**
  8166. * Gets the contrast used in the effect.
  8167. */
  8168. /**
  8169. * Sets the contrast used in the effect.
  8170. */
  8171. contrast: number;
  8172. /**
  8173. * Vignette stretch size.
  8174. */
  8175. vignetteStretch: number;
  8176. /**
  8177. * Vignette centre X Offset.
  8178. */
  8179. vignetteCentreX: number;
  8180. /**
  8181. * Vignette centre Y Offset.
  8182. */
  8183. vignetteCentreY: number;
  8184. /**
  8185. * Vignette weight or intensity of the vignette effect.
  8186. */
  8187. vignetteWeight: number;
  8188. /**
  8189. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8190. * if vignetteEnabled is set to true.
  8191. */
  8192. vignetteColor: Color4;
  8193. /**
  8194. * Camera field of view used by the Vignette effect.
  8195. */
  8196. vignetteCameraFov: number;
  8197. private _vignetteBlendMode;
  8198. /**
  8199. * Gets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. /**
  8202. * Sets the vignette blend mode allowing different kind of effect.
  8203. */
  8204. vignetteBlendMode: number;
  8205. private _vignetteEnabled;
  8206. /**
  8207. * Gets wether the vignette effect is enabled.
  8208. */
  8209. /**
  8210. * Sets wether the vignette effect is enabled.
  8211. */
  8212. vignetteEnabled: boolean;
  8213. private _applyByPostProcess;
  8214. /**
  8215. * Gets wether the image processing is applied through a post process or not.
  8216. */
  8217. /**
  8218. * Sets wether the image processing is applied through a post process or not.
  8219. */
  8220. applyByPostProcess: boolean;
  8221. private _isEnabled;
  8222. /**
  8223. * Gets wether the image processing is enabled or not.
  8224. */
  8225. /**
  8226. * Sets wether the image processing is enabled or not.
  8227. */
  8228. isEnabled: boolean;
  8229. /**
  8230. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8231. */
  8232. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8233. /**
  8234. * Method called each time the image processing information changes requires to recompile the effect.
  8235. */
  8236. protected _updateParameters(): void;
  8237. /**
  8238. * Gets the current class name.
  8239. * @return "ImageProcessingConfiguration"
  8240. */
  8241. getClassName(): string;
  8242. /**
  8243. * Prepare the list of uniforms associated with the Image Processing effects.
  8244. * @param uniforms The list of uniforms used in the effect
  8245. * @param defines the list of defines currently in use
  8246. */
  8247. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8248. /**
  8249. * Prepare the list of samplers associated with the Image Processing effects.
  8250. * @param samplersList The list of uniforms used in the effect
  8251. * @param defines the list of defines currently in use
  8252. */
  8253. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8254. /**
  8255. * Prepare the list of defines associated to the shader.
  8256. * @param defines the list of defines to complete
  8257. * @param forPostProcess Define if we are currently in post process mode or not
  8258. */
  8259. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8260. /**
  8261. * Returns true if all the image processing information are ready.
  8262. * @returns True if ready, otherwise, false
  8263. */
  8264. isReady(): boolean;
  8265. /**
  8266. * Binds the image processing to the shader.
  8267. * @param effect The effect to bind to
  8268. * @param aspectRatio Define the current aspect ratio of the effect
  8269. */
  8270. bind(effect: Effect, aspectRatio?: number): void;
  8271. /**
  8272. * Clones the current image processing instance.
  8273. * @return The cloned image processing
  8274. */
  8275. clone(): ImageProcessingConfiguration;
  8276. /**
  8277. * Serializes the current image processing instance to a json representation.
  8278. * @return a JSON representation
  8279. */
  8280. serialize(): any;
  8281. /**
  8282. * Parses the image processing from a json representation.
  8283. * @param source the JSON source to parse
  8284. * @return The parsed image processing
  8285. */
  8286. static Parse(source: any): ImageProcessingConfiguration;
  8287. private static _VIGNETTEMODE_MULTIPLY;
  8288. private static _VIGNETTEMODE_OPAQUE;
  8289. /**
  8290. * Used to apply the vignette as a mix with the pixel color.
  8291. */
  8292. static readonly VIGNETTEMODE_MULTIPLY: number;
  8293. /**
  8294. * Used to apply the vignette as a replacement of the pixel color.
  8295. */
  8296. static readonly VIGNETTEMODE_OPAQUE: number;
  8297. }
  8298. }
  8299. declare module "babylonjs/Shaders/postprocess.vertex" {
  8300. /** @hidden */
  8301. export var postprocessVertexShader: {
  8302. name: string;
  8303. shader: string;
  8304. };
  8305. }
  8306. declare module "babylonjs/Maths/math.axis" {
  8307. import { Vector3 } from "babylonjs/Maths/math.vector";
  8308. /** Defines supported spaces */
  8309. export enum Space {
  8310. /** Local (object) space */
  8311. LOCAL = 0,
  8312. /** World space */
  8313. WORLD = 1,
  8314. /** Bone space */
  8315. BONE = 2
  8316. }
  8317. /** Defines the 3 main axes */
  8318. export class Axis {
  8319. /** X axis */
  8320. static X: Vector3;
  8321. /** Y axis */
  8322. static Y: Vector3;
  8323. /** Z axis */
  8324. static Z: Vector3;
  8325. }
  8326. }
  8327. declare module "babylonjs/Cameras/targetCamera" {
  8328. import { Nullable } from "babylonjs/types";
  8329. import { Camera } from "babylonjs/Cameras/camera";
  8330. import { Scene } from "babylonjs/scene";
  8331. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8332. /**
  8333. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8334. * This is the base of the follow, arc rotate cameras and Free camera
  8335. * @see http://doc.babylonjs.com/features/cameras
  8336. */
  8337. export class TargetCamera extends Camera {
  8338. private static _RigCamTransformMatrix;
  8339. private static _TargetTransformMatrix;
  8340. private static _TargetFocalPoint;
  8341. /**
  8342. * Define the current direction the camera is moving to
  8343. */
  8344. cameraDirection: Vector3;
  8345. /**
  8346. * Define the current rotation the camera is rotating to
  8347. */
  8348. cameraRotation: Vector2;
  8349. /**
  8350. * When set, the up vector of the camera will be updated by the rotation of the camera
  8351. */
  8352. updateUpVectorFromRotation: boolean;
  8353. private _tmpQuaternion;
  8354. /**
  8355. * Define the current rotation of the camera
  8356. */
  8357. rotation: Vector3;
  8358. /**
  8359. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8360. */
  8361. rotationQuaternion: Quaternion;
  8362. /**
  8363. * Define the current speed of the camera
  8364. */
  8365. speed: number;
  8366. /**
  8367. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8368. * around all axis.
  8369. */
  8370. noRotationConstraint: boolean;
  8371. /**
  8372. * Define the current target of the camera as an object or a position.
  8373. */
  8374. lockedTarget: any;
  8375. /** @hidden */
  8376. _currentTarget: Vector3;
  8377. /** @hidden */
  8378. _initialFocalDistance: number;
  8379. /** @hidden */
  8380. _viewMatrix: Matrix;
  8381. /** @hidden */
  8382. _camMatrix: Matrix;
  8383. /** @hidden */
  8384. _cameraTransformMatrix: Matrix;
  8385. /** @hidden */
  8386. _cameraRotationMatrix: Matrix;
  8387. /** @hidden */
  8388. _referencePoint: Vector3;
  8389. /** @hidden */
  8390. _transformedReferencePoint: Vector3;
  8391. protected _globalCurrentTarget: Vector3;
  8392. protected _globalCurrentUpVector: Vector3;
  8393. /** @hidden */
  8394. _reset: () => void;
  8395. private _defaultUp;
  8396. /**
  8397. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8398. * This is the base of the follow, arc rotate cameras and Free camera
  8399. * @see http://doc.babylonjs.com/features/cameras
  8400. * @param name Defines the name of the camera in the scene
  8401. * @param position Defines the start position of the camera in the scene
  8402. * @param scene Defines the scene the camera belongs to
  8403. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8404. */
  8405. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8406. /**
  8407. * Gets the position in front of the camera at a given distance.
  8408. * @param distance The distance from the camera we want the position to be
  8409. * @returns the position
  8410. */
  8411. getFrontPosition(distance: number): Vector3;
  8412. /** @hidden */
  8413. _getLockedTargetPosition(): Nullable<Vector3>;
  8414. private _storedPosition;
  8415. private _storedRotation;
  8416. private _storedRotationQuaternion;
  8417. /**
  8418. * Store current camera state of the camera (fov, position, rotation, etc..)
  8419. * @returns the camera
  8420. */
  8421. storeState(): Camera;
  8422. /**
  8423. * Restored camera state. You must call storeState() first
  8424. * @returns whether it was successful or not
  8425. * @hidden
  8426. */
  8427. _restoreStateValues(): boolean;
  8428. /** @hidden */
  8429. _initCache(): void;
  8430. /** @hidden */
  8431. _updateCache(ignoreParentClass?: boolean): void;
  8432. /** @hidden */
  8433. _isSynchronizedViewMatrix(): boolean;
  8434. /** @hidden */
  8435. _computeLocalCameraSpeed(): number;
  8436. /**
  8437. * Defines the target the camera should look at.
  8438. * @param target Defines the new target as a Vector or a mesh
  8439. */
  8440. setTarget(target: Vector3): void;
  8441. /**
  8442. * Return the current target position of the camera. This value is expressed in local space.
  8443. * @returns the target position
  8444. */
  8445. getTarget(): Vector3;
  8446. /** @hidden */
  8447. _decideIfNeedsToMove(): boolean;
  8448. /** @hidden */
  8449. _updatePosition(): void;
  8450. /** @hidden */
  8451. _checkInputs(): void;
  8452. protected _updateCameraRotationMatrix(): void;
  8453. /**
  8454. * 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)
  8455. * @returns the current camera
  8456. */
  8457. private _rotateUpVectorWithCameraRotationMatrix;
  8458. private _cachedRotationZ;
  8459. private _cachedQuaternionRotationZ;
  8460. /** @hidden */
  8461. _getViewMatrix(): Matrix;
  8462. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8463. /**
  8464. * @hidden
  8465. */
  8466. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8467. /**
  8468. * @hidden
  8469. */
  8470. _updateRigCameras(): void;
  8471. private _getRigCamPositionAndTarget;
  8472. /**
  8473. * Gets the current object class name.
  8474. * @return the class name
  8475. */
  8476. getClassName(): string;
  8477. }
  8478. }
  8479. declare module "babylonjs/Events/keyboardEvents" {
  8480. /**
  8481. * Gather the list of keyboard event types as constants.
  8482. */
  8483. export class KeyboardEventTypes {
  8484. /**
  8485. * The keydown event is fired when a key becomes active (pressed).
  8486. */
  8487. static readonly KEYDOWN: number;
  8488. /**
  8489. * The keyup event is fired when a key has been released.
  8490. */
  8491. static readonly KEYUP: number;
  8492. }
  8493. /**
  8494. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8495. */
  8496. export class KeyboardInfo {
  8497. /**
  8498. * Defines the type of event (KeyboardEventTypes)
  8499. */
  8500. type: number;
  8501. /**
  8502. * Defines the related dom event
  8503. */
  8504. event: KeyboardEvent;
  8505. /**
  8506. * Instantiates a new keyboard info.
  8507. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8508. * @param type Defines the type of event (KeyboardEventTypes)
  8509. * @param event Defines the related dom event
  8510. */
  8511. constructor(
  8512. /**
  8513. * Defines the type of event (KeyboardEventTypes)
  8514. */
  8515. type: number,
  8516. /**
  8517. * Defines the related dom event
  8518. */
  8519. event: KeyboardEvent);
  8520. }
  8521. /**
  8522. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8523. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8524. */
  8525. export class KeyboardInfoPre extends KeyboardInfo {
  8526. /**
  8527. * Defines the type of event (KeyboardEventTypes)
  8528. */
  8529. type: number;
  8530. /**
  8531. * Defines the related dom event
  8532. */
  8533. event: KeyboardEvent;
  8534. /**
  8535. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8536. */
  8537. skipOnPointerObservable: boolean;
  8538. /**
  8539. * Instantiates a new keyboard pre info.
  8540. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8541. * @param type Defines the type of event (KeyboardEventTypes)
  8542. * @param event Defines the related dom event
  8543. */
  8544. constructor(
  8545. /**
  8546. * Defines the type of event (KeyboardEventTypes)
  8547. */
  8548. type: number,
  8549. /**
  8550. * Defines the related dom event
  8551. */
  8552. event: KeyboardEvent);
  8553. }
  8554. }
  8555. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8556. import { Nullable } from "babylonjs/types";
  8557. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8558. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8559. /**
  8560. * Manage the keyboard inputs to control the movement of a free camera.
  8561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8562. */
  8563. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8564. /**
  8565. * Defines the camera the input is attached to.
  8566. */
  8567. camera: FreeCamera;
  8568. /**
  8569. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8570. */
  8571. keysUp: number[];
  8572. /**
  8573. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8574. */
  8575. keysDown: number[];
  8576. /**
  8577. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8578. */
  8579. keysLeft: number[];
  8580. /**
  8581. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8582. */
  8583. keysRight: number[];
  8584. private _keys;
  8585. private _onCanvasBlurObserver;
  8586. private _onKeyboardObserver;
  8587. private _engine;
  8588. private _scene;
  8589. /**
  8590. * Attach the input controls to a specific dom element to get the input from.
  8591. * @param element Defines the element the controls should be listened from
  8592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8593. */
  8594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8595. /**
  8596. * Detach the current controls from the specified dom element.
  8597. * @param element Defines the element to stop listening the inputs from
  8598. */
  8599. detachControl(element: Nullable<HTMLElement>): void;
  8600. /**
  8601. * Update the current camera state depending on the inputs that have been used this frame.
  8602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8603. */
  8604. checkInputs(): void;
  8605. /**
  8606. * Gets the class name of the current intput.
  8607. * @returns the class name
  8608. */
  8609. getClassName(): string;
  8610. /** @hidden */
  8611. _onLostFocus(): void;
  8612. /**
  8613. * Get the friendly name associated with the input class.
  8614. * @returns the input friendly name
  8615. */
  8616. getSimpleName(): string;
  8617. }
  8618. }
  8619. declare module "babylonjs/Lights/shadowLight" {
  8620. import { Camera } from "babylonjs/Cameras/camera";
  8621. import { Scene } from "babylonjs/scene";
  8622. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8624. import { Light } from "babylonjs/Lights/light";
  8625. /**
  8626. * Interface describing all the common properties and methods a shadow light needs to implement.
  8627. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8628. * as well as binding the different shadow properties to the effects.
  8629. */
  8630. export interface IShadowLight extends Light {
  8631. /**
  8632. * The light id in the scene (used in scene.findLighById for instance)
  8633. */
  8634. id: string;
  8635. /**
  8636. * The position the shdow will be casted from.
  8637. */
  8638. position: Vector3;
  8639. /**
  8640. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8641. */
  8642. direction: Vector3;
  8643. /**
  8644. * The transformed position. Position of the light in world space taking parenting in account.
  8645. */
  8646. transformedPosition: Vector3;
  8647. /**
  8648. * The transformed direction. Direction of the light in world space taking parenting in account.
  8649. */
  8650. transformedDirection: Vector3;
  8651. /**
  8652. * The friendly name of the light in the scene.
  8653. */
  8654. name: string;
  8655. /**
  8656. * Defines the shadow projection clipping minimum z value.
  8657. */
  8658. shadowMinZ: number;
  8659. /**
  8660. * Defines the shadow projection clipping maximum z value.
  8661. */
  8662. shadowMaxZ: number;
  8663. /**
  8664. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8665. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8666. */
  8667. computeTransformedInformation(): boolean;
  8668. /**
  8669. * Gets the scene the light belongs to.
  8670. * @returns The scene
  8671. */
  8672. getScene(): Scene;
  8673. /**
  8674. * Callback defining a custom Projection Matrix Builder.
  8675. * This can be used to override the default projection matrix computation.
  8676. */
  8677. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8678. /**
  8679. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8680. * @param matrix The materix to updated with the projection information
  8681. * @param viewMatrix The transform matrix of the light
  8682. * @param renderList The list of mesh to render in the map
  8683. * @returns The current light
  8684. */
  8685. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8686. /**
  8687. * Gets the current depth scale used in ESM.
  8688. * @returns The scale
  8689. */
  8690. getDepthScale(): number;
  8691. /**
  8692. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8693. * @returns true if a cube texture needs to be use
  8694. */
  8695. needCube(): boolean;
  8696. /**
  8697. * Detects if the projection matrix requires to be recomputed this frame.
  8698. * @returns true if it requires to be recomputed otherwise, false.
  8699. */
  8700. needProjectionMatrixCompute(): boolean;
  8701. /**
  8702. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8703. */
  8704. forceProjectionMatrixCompute(): void;
  8705. /**
  8706. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8707. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8708. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8709. */
  8710. getShadowDirection(faceIndex?: number): Vector3;
  8711. /**
  8712. * Gets the minZ used for shadow according to both the scene and the light.
  8713. * @param activeCamera The camera we are returning the min for
  8714. * @returns the depth min z
  8715. */
  8716. getDepthMinZ(activeCamera: Camera): number;
  8717. /**
  8718. * Gets the maxZ used for shadow according to both the scene and the light.
  8719. * @param activeCamera The camera we are returning the max for
  8720. * @returns the depth max z
  8721. */
  8722. getDepthMaxZ(activeCamera: Camera): number;
  8723. }
  8724. /**
  8725. * Base implementation IShadowLight
  8726. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8727. */
  8728. export abstract class ShadowLight extends Light implements IShadowLight {
  8729. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8730. protected _position: Vector3;
  8731. protected _setPosition(value: Vector3): void;
  8732. /**
  8733. * Sets the position the shadow will be casted from. Also use as the light position for both
  8734. * point and spot lights.
  8735. */
  8736. /**
  8737. * Sets the position the shadow will be casted from. Also use as the light position for both
  8738. * point and spot lights.
  8739. */
  8740. position: Vector3;
  8741. protected _direction: Vector3;
  8742. protected _setDirection(value: Vector3): void;
  8743. /**
  8744. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8745. * Also use as the light direction on spot and directional lights.
  8746. */
  8747. /**
  8748. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8749. * Also use as the light direction on spot and directional lights.
  8750. */
  8751. direction: Vector3;
  8752. private _shadowMinZ;
  8753. /**
  8754. * Gets the shadow projection clipping minimum z value.
  8755. */
  8756. /**
  8757. * Sets the shadow projection clipping minimum z value.
  8758. */
  8759. shadowMinZ: number;
  8760. private _shadowMaxZ;
  8761. /**
  8762. * Sets the shadow projection clipping maximum z value.
  8763. */
  8764. /**
  8765. * Gets the shadow projection clipping maximum z value.
  8766. */
  8767. shadowMaxZ: number;
  8768. /**
  8769. * Callback defining a custom Projection Matrix Builder.
  8770. * This can be used to override the default projection matrix computation.
  8771. */
  8772. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8773. /**
  8774. * The transformed position. Position of the light in world space taking parenting in account.
  8775. */
  8776. transformedPosition: Vector3;
  8777. /**
  8778. * The transformed direction. Direction of the light in world space taking parenting in account.
  8779. */
  8780. transformedDirection: Vector3;
  8781. private _needProjectionMatrixCompute;
  8782. /**
  8783. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8784. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8785. */
  8786. computeTransformedInformation(): boolean;
  8787. /**
  8788. * Return the depth scale used for the shadow map.
  8789. * @returns the depth scale.
  8790. */
  8791. getDepthScale(): number;
  8792. /**
  8793. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8794. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8795. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8796. */
  8797. getShadowDirection(faceIndex?: number): Vector3;
  8798. /**
  8799. * Returns the ShadowLight absolute position in the World.
  8800. * @returns the position vector in world space
  8801. */
  8802. getAbsolutePosition(): Vector3;
  8803. /**
  8804. * Sets the ShadowLight direction toward the passed target.
  8805. * @param target The point to target in local space
  8806. * @returns the updated ShadowLight direction
  8807. */
  8808. setDirectionToTarget(target: Vector3): Vector3;
  8809. /**
  8810. * Returns the light rotation in euler definition.
  8811. * @returns the x y z rotation in local space.
  8812. */
  8813. getRotation(): Vector3;
  8814. /**
  8815. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8816. * @returns true if a cube texture needs to be use
  8817. */
  8818. needCube(): boolean;
  8819. /**
  8820. * Detects if the projection matrix requires to be recomputed this frame.
  8821. * @returns true if it requires to be recomputed otherwise, false.
  8822. */
  8823. needProjectionMatrixCompute(): boolean;
  8824. /**
  8825. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8826. */
  8827. forceProjectionMatrixCompute(): void;
  8828. /** @hidden */
  8829. _initCache(): void;
  8830. /** @hidden */
  8831. _isSynchronized(): boolean;
  8832. /**
  8833. * Computes the world matrix of the node
  8834. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8835. * @returns the world matrix
  8836. */
  8837. computeWorldMatrix(force?: boolean): Matrix;
  8838. /**
  8839. * Gets the minZ used for shadow according to both the scene and the light.
  8840. * @param activeCamera The camera we are returning the min for
  8841. * @returns the depth min z
  8842. */
  8843. getDepthMinZ(activeCamera: Camera): number;
  8844. /**
  8845. * Gets the maxZ used for shadow according to both the scene and the light.
  8846. * @param activeCamera The camera we are returning the max for
  8847. * @returns the depth max z
  8848. */
  8849. getDepthMaxZ(activeCamera: Camera): number;
  8850. /**
  8851. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8852. * @param matrix The materix to updated with the projection information
  8853. * @param viewMatrix The transform matrix of the light
  8854. * @param renderList The list of mesh to render in the map
  8855. * @returns The current light
  8856. */
  8857. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8858. }
  8859. }
  8860. declare module "babylonjs/Materials/materialHelper" {
  8861. import { Nullable } from "babylonjs/types";
  8862. import { Scene } from "babylonjs/scene";
  8863. import { Engine } from "babylonjs/Engines/engine";
  8864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8865. import { Light } from "babylonjs/Lights/light";
  8866. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8867. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8869. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8870. /**
  8871. * "Static Class" containing the most commonly used helper while dealing with material for
  8872. * rendering purpose.
  8873. *
  8874. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8875. *
  8876. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8877. */
  8878. export class MaterialHelper {
  8879. /**
  8880. * Bind the current view position to an effect.
  8881. * @param effect The effect to be bound
  8882. * @param scene The scene the eyes position is used from
  8883. */
  8884. static BindEyePosition(effect: Effect, scene: Scene): void;
  8885. /**
  8886. * Helps preparing the defines values about the UVs in used in the effect.
  8887. * UVs are shared as much as we can accross channels in the shaders.
  8888. * @param texture The texture we are preparing the UVs for
  8889. * @param defines The defines to update
  8890. * @param key The channel key "diffuse", "specular"... used in the shader
  8891. */
  8892. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8893. /**
  8894. * Binds a texture matrix value to its corrsponding uniform
  8895. * @param texture The texture to bind the matrix for
  8896. * @param uniformBuffer The uniform buffer receivin the data
  8897. * @param key The channel key "diffuse", "specular"... used in the shader
  8898. */
  8899. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8900. /**
  8901. * Gets the current status of the fog (should it be enabled?)
  8902. * @param mesh defines the mesh to evaluate for fog support
  8903. * @param scene defines the hosting scene
  8904. * @returns true if fog must be enabled
  8905. */
  8906. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8907. /**
  8908. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8909. * @param mesh defines the current mesh
  8910. * @param scene defines the current scene
  8911. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8912. * @param pointsCloud defines if point cloud rendering has to be turned on
  8913. * @param fogEnabled defines if fog has to be turned on
  8914. * @param alphaTest defines if alpha testing has to be turned on
  8915. * @param defines defines the current list of defines
  8916. */
  8917. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8918. /**
  8919. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8920. * @param scene defines the current scene
  8921. * @param engine defines the current engine
  8922. * @param defines specifies the list of active defines
  8923. * @param useInstances defines if instances have to be turned on
  8924. * @param useClipPlane defines if clip plane have to be turned on
  8925. */
  8926. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8927. /**
  8928. * Prepares the defines for bones
  8929. * @param mesh The mesh containing the geometry data we will draw
  8930. * @param defines The defines to update
  8931. */
  8932. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8933. /**
  8934. * Prepares the defines for morph targets
  8935. * @param mesh The mesh containing the geometry data we will draw
  8936. * @param defines The defines to update
  8937. */
  8938. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8939. /**
  8940. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8941. * @param mesh The mesh containing the geometry data we will draw
  8942. * @param defines The defines to update
  8943. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8944. * @param useBones Precise whether bones should be used or not (override mesh info)
  8945. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8946. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8947. * @returns false if defines are considered not dirty and have not been checked
  8948. */
  8949. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8950. /**
  8951. * Prepares the defines related to multiview
  8952. * @param scene The scene we are intending to draw
  8953. * @param defines The defines to update
  8954. */
  8955. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8956. /**
  8957. * Prepares the defines related to the light information passed in parameter
  8958. * @param scene The scene we are intending to draw
  8959. * @param mesh The mesh the effect is compiling for
  8960. * @param light The light the effect is compiling for
  8961. * @param lightIndex The index of the light
  8962. * @param defines The defines to update
  8963. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8964. * @param state Defines the current state regarding what is needed (normals, etc...)
  8965. */
  8966. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8967. needNormals: boolean;
  8968. needRebuild: boolean;
  8969. shadowEnabled: boolean;
  8970. specularEnabled: boolean;
  8971. lightmapMode: boolean;
  8972. }): void;
  8973. /**
  8974. * Prepares the defines related to the light information passed in parameter
  8975. * @param scene The scene we are intending to draw
  8976. * @param mesh The mesh the effect is compiling for
  8977. * @param defines The defines to update
  8978. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8979. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8980. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8981. * @returns true if normals will be required for the rest of the effect
  8982. */
  8983. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8984. /**
  8985. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8986. * @param lightIndex defines the light index
  8987. * @param uniformsList The uniform list
  8988. * @param samplersList The sampler list
  8989. * @param projectedLightTexture defines if projected texture must be used
  8990. * @param uniformBuffersList defines an optional list of uniform buffers
  8991. */
  8992. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8993. /**
  8994. * Prepares the uniforms and samplers list to be used in the effect
  8995. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8996. * @param samplersList The sampler list
  8997. * @param defines The defines helping in the list generation
  8998. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8999. */
  9000. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9001. /**
  9002. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9003. * @param defines The defines to update while falling back
  9004. * @param fallbacks The authorized effect fallbacks
  9005. * @param maxSimultaneousLights The maximum number of lights allowed
  9006. * @param rank the current rank of the Effect
  9007. * @returns The newly affected rank
  9008. */
  9009. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9010. private static _TmpMorphInfluencers;
  9011. /**
  9012. * Prepares the list of attributes required for morph targets according to the effect defines.
  9013. * @param attribs The current list of supported attribs
  9014. * @param mesh The mesh to prepare the morph targets attributes for
  9015. * @param influencers The number of influencers
  9016. */
  9017. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9018. /**
  9019. * Prepares the list of attributes required for morph targets according to the effect defines.
  9020. * @param attribs The current list of supported attribs
  9021. * @param mesh The mesh to prepare the morph targets attributes for
  9022. * @param defines The current Defines of the effect
  9023. */
  9024. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9025. /**
  9026. * Prepares the list of attributes required for bones according to the effect defines.
  9027. * @param attribs The current list of supported attribs
  9028. * @param mesh The mesh to prepare the bones attributes for
  9029. * @param defines The current Defines of the effect
  9030. * @param fallbacks The current efffect fallback strategy
  9031. */
  9032. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9033. /**
  9034. * Check and prepare the list of attributes required for instances according to the effect defines.
  9035. * @param attribs The current list of supported attribs
  9036. * @param defines The current MaterialDefines of the effect
  9037. */
  9038. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9039. /**
  9040. * Add the list of attributes required for instances to the attribs array.
  9041. * @param attribs The current list of supported attribs
  9042. */
  9043. static PushAttributesForInstances(attribs: string[]): void;
  9044. /**
  9045. * Binds the light shadow information to the effect for the given mesh.
  9046. * @param light The light containing the generator
  9047. * @param scene The scene the lights belongs to
  9048. * @param mesh The mesh we are binding the information to render
  9049. * @param lightIndex The light index in the effect used to render the mesh
  9050. * @param effect The effect we are binding the data to
  9051. */
  9052. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9053. /**
  9054. * Binds the light information to the effect.
  9055. * @param light The light containing the generator
  9056. * @param effect The effect we are binding the data to
  9057. * @param lightIndex The light index in the effect used to render
  9058. */
  9059. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9060. /**
  9061. * Binds the lights information from the scene to the effect for the given mesh.
  9062. * @param light Light to bind
  9063. * @param lightIndex Light index
  9064. * @param scene The scene where the light belongs to
  9065. * @param mesh The mesh we are binding the information to render
  9066. * @param effect The effect we are binding the data to
  9067. * @param useSpecular Defines if specular is supported
  9068. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9069. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9070. */
  9071. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9072. /**
  9073. * Binds the lights information from the scene to the effect for the given mesh.
  9074. * @param scene The scene the lights belongs to
  9075. * @param mesh The mesh we are binding the information to render
  9076. * @param effect The effect we are binding the data to
  9077. * @param defines The generated defines for the effect
  9078. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9079. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9080. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9081. */
  9082. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9083. private static _tempFogColor;
  9084. /**
  9085. * Binds the fog information from the scene to the effect for the given mesh.
  9086. * @param scene The scene the lights belongs to
  9087. * @param mesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. * @param linearSpace Defines if the fog effect is applied in linear space
  9090. */
  9091. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9092. /**
  9093. * Binds the bones information from the mesh to the effect.
  9094. * @param mesh The mesh we are binding the information to render
  9095. * @param effect The effect we are binding the data to
  9096. */
  9097. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9098. /**
  9099. * Binds the morph targets information from the mesh to the effect.
  9100. * @param abstractMesh The mesh we are binding the information to render
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9104. /**
  9105. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9106. * @param defines The generated defines used in the effect
  9107. * @param effect The effect we are binding the data to
  9108. * @param scene The scene we are willing to render with logarithmic scale for
  9109. */
  9110. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9111. /**
  9112. * Binds the clip plane information from the scene to the effect.
  9113. * @param scene The scene the clip plane information are extracted from
  9114. * @param effect The effect we are binding the data to
  9115. */
  9116. static BindClipPlane(effect: Effect, scene: Scene): void;
  9117. }
  9118. }
  9119. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9120. /** @hidden */
  9121. export var packingFunctions: {
  9122. name: string;
  9123. shader: string;
  9124. };
  9125. }
  9126. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9127. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9128. /** @hidden */
  9129. export var shadowMapPixelShader: {
  9130. name: string;
  9131. shader: string;
  9132. };
  9133. }
  9134. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9135. /** @hidden */
  9136. export var bonesDeclaration: {
  9137. name: string;
  9138. shader: string;
  9139. };
  9140. }
  9141. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9142. /** @hidden */
  9143. export var morphTargetsVertexGlobalDeclaration: {
  9144. name: string;
  9145. shader: string;
  9146. };
  9147. }
  9148. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9149. /** @hidden */
  9150. export var morphTargetsVertexDeclaration: {
  9151. name: string;
  9152. shader: string;
  9153. };
  9154. }
  9155. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9156. /** @hidden */
  9157. export var instancesDeclaration: {
  9158. name: string;
  9159. shader: string;
  9160. };
  9161. }
  9162. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9163. /** @hidden */
  9164. export var helperFunctions: {
  9165. name: string;
  9166. shader: string;
  9167. };
  9168. }
  9169. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9170. /** @hidden */
  9171. export var morphTargetsVertex: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9177. /** @hidden */
  9178. export var instancesVertex: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9184. /** @hidden */
  9185. export var bonesVertex: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9191. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9192. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9193. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9194. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9195. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9196. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9197. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9198. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9199. /** @hidden */
  9200. export var shadowMapVertexShader: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9206. /** @hidden */
  9207. export var depthBoxBlurPixelShader: {
  9208. name: string;
  9209. shader: string;
  9210. };
  9211. }
  9212. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9213. import { Nullable } from "babylonjs/types";
  9214. import { Scene } from "babylonjs/scene";
  9215. import { Matrix } from "babylonjs/Maths/math.vector";
  9216. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9218. import { Mesh } from "babylonjs/Meshes/mesh";
  9219. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9220. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9221. import { Effect } from "babylonjs/Materials/effect";
  9222. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9223. import "babylonjs/Shaders/shadowMap.fragment";
  9224. import "babylonjs/Shaders/shadowMap.vertex";
  9225. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9226. import { Observable } from "babylonjs/Misc/observable";
  9227. /**
  9228. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9229. */
  9230. export interface ICustomShaderOptions {
  9231. /**
  9232. * Gets or sets the custom shader name to use
  9233. */
  9234. shaderName: string;
  9235. /**
  9236. * The list of attribute names used in the shader
  9237. */
  9238. attributes?: string[];
  9239. /**
  9240. * The list of unifrom names used in the shader
  9241. */
  9242. uniforms?: string[];
  9243. /**
  9244. * The list of sampler names used in the shader
  9245. */
  9246. samplers?: string[];
  9247. /**
  9248. * The list of defines used in the shader
  9249. */
  9250. defines?: string[];
  9251. }
  9252. /**
  9253. * Interface to implement to create a shadow generator compatible with BJS.
  9254. */
  9255. export interface IShadowGenerator {
  9256. /**
  9257. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9258. * @returns The render target texture if present otherwise, null
  9259. */
  9260. getShadowMap(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9263. * @returns The render target texture if the shadow map is present otherwise, null
  9264. */
  9265. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9266. /**
  9267. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9268. * @param subMesh The submesh we want to render in the shadow map
  9269. * @param useInstances Defines wether will draw in the map using instances
  9270. * @returns true if ready otherwise, false
  9271. */
  9272. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9273. /**
  9274. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9275. * @param defines Defines of the material we want to update
  9276. * @param lightIndex Index of the light in the enabled light list of the material
  9277. */
  9278. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9279. /**
  9280. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9281. * defined in the generator but impacting the effect).
  9282. * It implies the unifroms available on the materials are the standard BJS ones.
  9283. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9284. * @param effect The effect we are binfing the information for
  9285. */
  9286. bindShadowLight(lightIndex: string, effect: Effect): void;
  9287. /**
  9288. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9289. * (eq to shadow prjection matrix * light transform matrix)
  9290. * @returns The transform matrix used to create the shadow map
  9291. */
  9292. getTransformMatrix(): Matrix;
  9293. /**
  9294. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9295. * Cube and 2D textures for instance.
  9296. */
  9297. recreateShadowMap(): void;
  9298. /**
  9299. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9300. * @param onCompiled Callback triggered at the and of the effects compilation
  9301. * @param options Sets of optional options forcing the compilation with different modes
  9302. */
  9303. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9304. useInstances: boolean;
  9305. }>): void;
  9306. /**
  9307. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9308. * @param options Sets of optional options forcing the compilation with different modes
  9309. * @returns A promise that resolves when the compilation completes
  9310. */
  9311. forceCompilationAsync(options?: Partial<{
  9312. useInstances: boolean;
  9313. }>): Promise<void>;
  9314. /**
  9315. * Serializes the shadow generator setup to a json object.
  9316. * @returns The serialized JSON object
  9317. */
  9318. serialize(): any;
  9319. /**
  9320. * Disposes the Shadow map and related Textures and effects.
  9321. */
  9322. dispose(): void;
  9323. }
  9324. /**
  9325. * Default implementation IShadowGenerator.
  9326. * This is the main object responsible of generating shadows in the framework.
  9327. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9328. */
  9329. export class ShadowGenerator implements IShadowGenerator {
  9330. /**
  9331. * Shadow generator mode None: no filtering applied.
  9332. */
  9333. static readonly FILTER_NONE: number;
  9334. /**
  9335. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9336. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9337. */
  9338. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9339. /**
  9340. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9341. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9342. */
  9343. static readonly FILTER_POISSONSAMPLING: number;
  9344. /**
  9345. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9346. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9347. */
  9348. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9349. /**
  9350. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9351. * edge artifacts on steep falloff.
  9352. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9353. */
  9354. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9355. /**
  9356. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9357. * edge artifacts on steep falloff.
  9358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9359. */
  9360. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9361. /**
  9362. * Shadow generator mode PCF: Percentage Closer Filtering
  9363. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9364. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9365. */
  9366. static readonly FILTER_PCF: number;
  9367. /**
  9368. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9369. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9370. * Contact Hardening
  9371. */
  9372. static readonly FILTER_PCSS: number;
  9373. /**
  9374. * Reserved for PCF and PCSS
  9375. * Highest Quality.
  9376. *
  9377. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9378. *
  9379. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9380. */
  9381. static readonly QUALITY_HIGH: number;
  9382. /**
  9383. * Reserved for PCF and PCSS
  9384. * Good tradeoff for quality/perf cross devices
  9385. *
  9386. * Execute PCF on a 3*3 kernel.
  9387. *
  9388. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9389. */
  9390. static readonly QUALITY_MEDIUM: number;
  9391. /**
  9392. * Reserved for PCF and PCSS
  9393. * The lowest quality but the fastest.
  9394. *
  9395. * Execute PCF on a 1*1 kernel.
  9396. *
  9397. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9398. */
  9399. static readonly QUALITY_LOW: number;
  9400. /** Gets or sets the custom shader name to use */
  9401. customShaderOptions: ICustomShaderOptions;
  9402. /**
  9403. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9404. */
  9405. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9406. /**
  9407. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9408. */
  9409. onAfterShadowMapRenderObservable: Observable<Effect>;
  9410. /**
  9411. * Observable triggered before a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9413. */
  9414. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. /**
  9416. * Observable triggered after a mesh is rendered in the shadow map.
  9417. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9418. */
  9419. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9420. private _bias;
  9421. /**
  9422. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9423. */
  9424. /**
  9425. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9426. */
  9427. bias: number;
  9428. private _normalBias;
  9429. /**
  9430. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9431. */
  9432. /**
  9433. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9434. */
  9435. normalBias: number;
  9436. private _blurBoxOffset;
  9437. /**
  9438. * Gets the blur box offset: offset applied during the blur pass.
  9439. * Only useful if useKernelBlur = false
  9440. */
  9441. /**
  9442. * Sets the blur box offset: offset applied during the blur pass.
  9443. * Only useful if useKernelBlur = false
  9444. */
  9445. blurBoxOffset: number;
  9446. private _blurScale;
  9447. /**
  9448. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9449. * 2 means half of the size.
  9450. */
  9451. /**
  9452. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9453. * 2 means half of the size.
  9454. */
  9455. blurScale: number;
  9456. private _blurKernel;
  9457. /**
  9458. * Gets the blur kernel: kernel size of the blur pass.
  9459. * Only useful if useKernelBlur = true
  9460. */
  9461. /**
  9462. * Sets the blur kernel: kernel size of the blur pass.
  9463. * Only useful if useKernelBlur = true
  9464. */
  9465. blurKernel: number;
  9466. private _useKernelBlur;
  9467. /**
  9468. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9469. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9470. */
  9471. /**
  9472. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9473. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9474. */
  9475. useKernelBlur: boolean;
  9476. private _depthScale;
  9477. /**
  9478. * Gets the depth scale used in ESM mode.
  9479. */
  9480. /**
  9481. * Sets the depth scale used in ESM mode.
  9482. * This can override the scale stored on the light.
  9483. */
  9484. depthScale: number;
  9485. private _filter;
  9486. /**
  9487. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9488. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9489. */
  9490. /**
  9491. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9492. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9493. */
  9494. filter: number;
  9495. /**
  9496. * Gets if the current filter is set to Poisson Sampling.
  9497. */
  9498. /**
  9499. * Sets the current filter to Poisson Sampling.
  9500. */
  9501. usePoissonSampling: boolean;
  9502. /**
  9503. * Gets if the current filter is set to ESM.
  9504. */
  9505. /**
  9506. * Sets the current filter is to ESM.
  9507. */
  9508. useExponentialShadowMap: boolean;
  9509. /**
  9510. * Gets if the current filter is set to filtered ESM.
  9511. */
  9512. /**
  9513. * Gets if the current filter is set to filtered ESM.
  9514. */
  9515. useBlurExponentialShadowMap: boolean;
  9516. /**
  9517. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9518. * exponential to prevent steep falloff artifacts).
  9519. */
  9520. /**
  9521. * Sets the current filter to "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. useCloseExponentialShadowMap: boolean;
  9525. /**
  9526. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9527. * exponential to prevent steep falloff artifacts).
  9528. */
  9529. /**
  9530. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9531. * exponential to prevent steep falloff artifacts).
  9532. */
  9533. useBlurCloseExponentialShadowMap: boolean;
  9534. /**
  9535. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9536. */
  9537. /**
  9538. * Sets the current filter to "PCF" (percentage closer filtering).
  9539. */
  9540. usePercentageCloserFiltering: boolean;
  9541. private _filteringQuality;
  9542. /**
  9543. * Gets the PCF or PCSS Quality.
  9544. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9545. */
  9546. /**
  9547. * Sets the PCF or PCSS Quality.
  9548. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9549. */
  9550. filteringQuality: number;
  9551. /**
  9552. * Gets if the current filter is set to "PCSS" (contact hardening).
  9553. */
  9554. /**
  9555. * Sets the current filter to "PCSS" (contact hardening).
  9556. */
  9557. useContactHardeningShadow: boolean;
  9558. private _contactHardeningLightSizeUVRatio;
  9559. /**
  9560. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9561. * Using a ratio helps keeping shape stability independently of the map size.
  9562. *
  9563. * It does not account for the light projection as it was having too much
  9564. * instability during the light setup or during light position changes.
  9565. *
  9566. * Only valid if useContactHardeningShadow is true.
  9567. */
  9568. /**
  9569. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9570. * Using a ratio helps keeping shape stability independently of the map size.
  9571. *
  9572. * It does not account for the light projection as it was having too much
  9573. * instability during the light setup or during light position changes.
  9574. *
  9575. * Only valid if useContactHardeningShadow is true.
  9576. */
  9577. contactHardeningLightSizeUVRatio: number;
  9578. private _darkness;
  9579. /** Gets or sets the actual darkness of a shadow */
  9580. darkness: number;
  9581. /**
  9582. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9583. * 0 means strongest and 1 would means no shadow.
  9584. * @returns the darkness.
  9585. */
  9586. getDarkness(): number;
  9587. /**
  9588. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9589. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9590. * @returns the shadow generator allowing fluent coding.
  9591. */
  9592. setDarkness(darkness: number): ShadowGenerator;
  9593. private _transparencyShadow;
  9594. /** Gets or sets the ability to have transparent shadow */
  9595. transparencyShadow: boolean;
  9596. /**
  9597. * Sets the ability to have transparent shadow (boolean).
  9598. * @param transparent True if transparent else False
  9599. * @returns the shadow generator allowing fluent coding
  9600. */
  9601. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9602. private _shadowMap;
  9603. private _shadowMap2;
  9604. /**
  9605. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9606. * @returns The render target texture if present otherwise, null
  9607. */
  9608. getShadowMap(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9611. * @returns The render target texture if the shadow map is present otherwise, null
  9612. */
  9613. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9614. /**
  9615. * Gets the class name of that object
  9616. * @returns "ShadowGenerator"
  9617. */
  9618. getClassName(): string;
  9619. /**
  9620. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9621. * @param mesh Mesh to add
  9622. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9623. * @returns the Shadow Generator itself
  9624. */
  9625. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9626. /**
  9627. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9628. * @param mesh Mesh to remove
  9629. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9630. * @returns the Shadow Generator itself
  9631. */
  9632. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9633. /**
  9634. * Controls the extent to which the shadows fade out at the edge of the frustum
  9635. * Used only by directionals and spots
  9636. */
  9637. frustumEdgeFalloff: number;
  9638. private _light;
  9639. /**
  9640. * Returns the associated light object.
  9641. * @returns the light generating the shadow
  9642. */
  9643. getLight(): IShadowLight;
  9644. /**
  9645. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9646. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9647. * It might on the other hand introduce peter panning.
  9648. */
  9649. forceBackFacesOnly: boolean;
  9650. private _scene;
  9651. private _lightDirection;
  9652. private _effect;
  9653. private _viewMatrix;
  9654. private _projectionMatrix;
  9655. private _transformMatrix;
  9656. private _cachedPosition;
  9657. private _cachedDirection;
  9658. private _cachedDefines;
  9659. private _currentRenderID;
  9660. private _boxBlurPostprocess;
  9661. private _kernelBlurXPostprocess;
  9662. private _kernelBlurYPostprocess;
  9663. private _blurPostProcesses;
  9664. private _mapSize;
  9665. private _currentFaceIndex;
  9666. private _currentFaceIndexCache;
  9667. private _textureType;
  9668. private _defaultTextureMatrix;
  9669. /** @hidden */
  9670. static _SceneComponentInitialization: (scene: Scene) => void;
  9671. /**
  9672. * Creates a ShadowGenerator object.
  9673. * A ShadowGenerator is the required tool to use the shadows.
  9674. * Each light casting shadows needs to use its own ShadowGenerator.
  9675. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9676. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9677. * @param light The light object generating the shadows.
  9678. * @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.
  9679. */
  9680. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9681. private _initializeGenerator;
  9682. private _initializeShadowMap;
  9683. private _initializeBlurRTTAndPostProcesses;
  9684. private _renderForShadowMap;
  9685. private _renderSubMeshForShadowMap;
  9686. private _applyFilterValues;
  9687. /**
  9688. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9689. * @param onCompiled Callback triggered at the and of the effects compilation
  9690. * @param options Sets of optional options forcing the compilation with different modes
  9691. */
  9692. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9693. useInstances: boolean;
  9694. }>): void;
  9695. /**
  9696. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9697. * @param options Sets of optional options forcing the compilation with different modes
  9698. * @returns A promise that resolves when the compilation completes
  9699. */
  9700. forceCompilationAsync(options?: Partial<{
  9701. useInstances: boolean;
  9702. }>): Promise<void>;
  9703. /**
  9704. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9705. * @param subMesh The submesh we want to render in the shadow map
  9706. * @param useInstances Defines wether will draw in the map using instances
  9707. * @returns true if ready otherwise, false
  9708. */
  9709. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9710. /**
  9711. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9712. * @param defines Defines of the material we want to update
  9713. * @param lightIndex Index of the light in the enabled light list of the material
  9714. */
  9715. prepareDefines(defines: any, lightIndex: number): void;
  9716. /**
  9717. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9718. * defined in the generator but impacting the effect).
  9719. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9720. * @param effect The effect we are binfing the information for
  9721. */
  9722. bindShadowLight(lightIndex: string, effect: Effect): void;
  9723. /**
  9724. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9725. * (eq to shadow prjection matrix * light transform matrix)
  9726. * @returns The transform matrix used to create the shadow map
  9727. */
  9728. getTransformMatrix(): Matrix;
  9729. /**
  9730. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9731. * Cube and 2D textures for instance.
  9732. */
  9733. recreateShadowMap(): void;
  9734. private _disposeBlurPostProcesses;
  9735. private _disposeRTTandPostProcesses;
  9736. /**
  9737. * Disposes the ShadowGenerator.
  9738. * Returns nothing.
  9739. */
  9740. dispose(): void;
  9741. /**
  9742. * Serializes the shadow generator setup to a json object.
  9743. * @returns The serialized JSON object
  9744. */
  9745. serialize(): any;
  9746. /**
  9747. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9748. * @param parsedShadowGenerator The JSON object to parse
  9749. * @param scene The scene to create the shadow map for
  9750. * @returns The parsed shadow generator
  9751. */
  9752. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9753. }
  9754. }
  9755. declare module "babylonjs/Lights/light" {
  9756. import { Nullable } from "babylonjs/types";
  9757. import { Scene } from "babylonjs/scene";
  9758. import { Vector3 } from "babylonjs/Maths/math.vector";
  9759. import { Color3 } from "babylonjs/Maths/math.color";
  9760. import { Node } from "babylonjs/node";
  9761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9762. import { Effect } from "babylonjs/Materials/effect";
  9763. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9764. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9765. /**
  9766. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9767. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9768. * 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.
  9769. */
  9770. export abstract class Light extends Node {
  9771. /**
  9772. * Falloff Default: light is falling off following the material specification:
  9773. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9774. */
  9775. static readonly FALLOFF_DEFAULT: number;
  9776. /**
  9777. * Falloff Physical: light is falling off following the inverse squared distance law.
  9778. */
  9779. static readonly FALLOFF_PHYSICAL: number;
  9780. /**
  9781. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9782. * to enhance interoperability with other engines.
  9783. */
  9784. static readonly FALLOFF_GLTF: number;
  9785. /**
  9786. * Falloff Standard: light is falling off like in the standard material
  9787. * to enhance interoperability with other materials.
  9788. */
  9789. static readonly FALLOFF_STANDARD: number;
  9790. /**
  9791. * If every light affecting the material is in this lightmapMode,
  9792. * material.lightmapTexture adds or multiplies
  9793. * (depends on material.useLightmapAsShadowmap)
  9794. * after every other light calculations.
  9795. */
  9796. static readonly LIGHTMAP_DEFAULT: number;
  9797. /**
  9798. * material.lightmapTexture as only diffuse lighting from this light
  9799. * adds only specular lighting from this light
  9800. * adds dynamic shadows
  9801. */
  9802. static readonly LIGHTMAP_SPECULAR: number;
  9803. /**
  9804. * material.lightmapTexture as only lighting
  9805. * no light calculation from this light
  9806. * only adds dynamic shadows from this light
  9807. */
  9808. static readonly LIGHTMAP_SHADOWSONLY: number;
  9809. /**
  9810. * Each light type uses the default quantity according to its type:
  9811. * point/spot lights use luminous intensity
  9812. * directional lights use illuminance
  9813. */
  9814. static readonly INTENSITYMODE_AUTOMATIC: number;
  9815. /**
  9816. * lumen (lm)
  9817. */
  9818. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9819. /**
  9820. * candela (lm/sr)
  9821. */
  9822. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9823. /**
  9824. * lux (lm/m^2)
  9825. */
  9826. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9827. /**
  9828. * nit (cd/m^2)
  9829. */
  9830. static readonly INTENSITYMODE_LUMINANCE: number;
  9831. /**
  9832. * Light type const id of the point light.
  9833. */
  9834. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9835. /**
  9836. * Light type const id of the directional light.
  9837. */
  9838. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9839. /**
  9840. * Light type const id of the spot light.
  9841. */
  9842. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9843. /**
  9844. * Light type const id of the hemispheric light.
  9845. */
  9846. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9847. /**
  9848. * Diffuse gives the basic color to an object.
  9849. */
  9850. diffuse: Color3;
  9851. /**
  9852. * Specular produces a highlight color on an object.
  9853. * Note: This is note affecting PBR materials.
  9854. */
  9855. specular: Color3;
  9856. /**
  9857. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9858. * falling off base on range or angle.
  9859. * This can be set to any values in Light.FALLOFF_x.
  9860. *
  9861. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9862. * other types of materials.
  9863. */
  9864. falloffType: number;
  9865. /**
  9866. * Strength of the light.
  9867. * Note: By default it is define in the framework own unit.
  9868. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9869. */
  9870. intensity: number;
  9871. private _range;
  9872. protected _inverseSquaredRange: number;
  9873. /**
  9874. * Defines how far from the source the light is impacting in scene units.
  9875. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9876. */
  9877. /**
  9878. * Defines how far from the source the light is impacting in scene units.
  9879. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9880. */
  9881. range: number;
  9882. /**
  9883. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9884. * of light.
  9885. */
  9886. private _photometricScale;
  9887. private _intensityMode;
  9888. /**
  9889. * Gets the photometric scale used to interpret the intensity.
  9890. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9891. */
  9892. /**
  9893. * Sets the photometric scale used to interpret the intensity.
  9894. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9895. */
  9896. intensityMode: number;
  9897. private _radius;
  9898. /**
  9899. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9900. */
  9901. /**
  9902. * sets the light radius used by PBR Materials to simulate soft area lights.
  9903. */
  9904. radius: number;
  9905. private _renderPriority;
  9906. /**
  9907. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9908. * exceeding the number allowed of the materials.
  9909. */
  9910. renderPriority: number;
  9911. private _shadowEnabled;
  9912. /**
  9913. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9914. * the current shadow generator.
  9915. */
  9916. /**
  9917. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9918. * the current shadow generator.
  9919. */
  9920. shadowEnabled: boolean;
  9921. private _includedOnlyMeshes;
  9922. /**
  9923. * Gets the only meshes impacted by this light.
  9924. */
  9925. /**
  9926. * Sets the only meshes impacted by this light.
  9927. */
  9928. includedOnlyMeshes: AbstractMesh[];
  9929. private _excludedMeshes;
  9930. /**
  9931. * Gets the meshes not impacted by this light.
  9932. */
  9933. /**
  9934. * Sets the meshes not impacted by this light.
  9935. */
  9936. excludedMeshes: AbstractMesh[];
  9937. private _excludeWithLayerMask;
  9938. /**
  9939. * Gets the layer id use to find what meshes are not impacted by the light.
  9940. * Inactive if 0
  9941. */
  9942. /**
  9943. * Sets the layer id use to find what meshes are not impacted by the light.
  9944. * Inactive if 0
  9945. */
  9946. excludeWithLayerMask: number;
  9947. private _includeOnlyWithLayerMask;
  9948. /**
  9949. * Gets the layer id use to find what meshes are impacted by the light.
  9950. * Inactive if 0
  9951. */
  9952. /**
  9953. * Sets the layer id use to find what meshes are impacted by the light.
  9954. * Inactive if 0
  9955. */
  9956. includeOnlyWithLayerMask: number;
  9957. private _lightmapMode;
  9958. /**
  9959. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9960. */
  9961. /**
  9962. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9963. */
  9964. lightmapMode: number;
  9965. /**
  9966. * Shadow generator associted to the light.
  9967. * @hidden Internal use only.
  9968. */
  9969. _shadowGenerator: Nullable<IShadowGenerator>;
  9970. /**
  9971. * @hidden Internal use only.
  9972. */
  9973. _excludedMeshesIds: string[];
  9974. /**
  9975. * @hidden Internal use only.
  9976. */
  9977. _includedOnlyMeshesIds: string[];
  9978. /**
  9979. * The current light unifom buffer.
  9980. * @hidden Internal use only.
  9981. */
  9982. _uniformBuffer: UniformBuffer;
  9983. /**
  9984. * Creates a Light object in the scene.
  9985. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9986. * @param name The firendly name of the light
  9987. * @param scene The scene the light belongs too
  9988. */
  9989. constructor(name: string, scene: Scene);
  9990. protected abstract _buildUniformLayout(): void;
  9991. /**
  9992. * Sets the passed Effect "effect" with the Light information.
  9993. * @param effect The effect to update
  9994. * @param lightIndex The index of the light in the effect to update
  9995. * @returns The light
  9996. */
  9997. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9998. /**
  9999. * Returns the string "Light".
  10000. * @returns the class name
  10001. */
  10002. getClassName(): string;
  10003. /** @hidden */
  10004. readonly _isLight: boolean;
  10005. /**
  10006. * Converts the light information to a readable string for debug purpose.
  10007. * @param fullDetails Supports for multiple levels of logging within scene loading
  10008. * @returns the human readable light info
  10009. */
  10010. toString(fullDetails?: boolean): string;
  10011. /** @hidden */
  10012. protected _syncParentEnabledState(): void;
  10013. /**
  10014. * Set the enabled state of this node.
  10015. * @param value - the new enabled state
  10016. */
  10017. setEnabled(value: boolean): void;
  10018. /**
  10019. * Returns the Light associated shadow generator if any.
  10020. * @return the associated shadow generator.
  10021. */
  10022. getShadowGenerator(): Nullable<IShadowGenerator>;
  10023. /**
  10024. * Returns a Vector3, the absolute light position in the World.
  10025. * @returns the world space position of the light
  10026. */
  10027. getAbsolutePosition(): Vector3;
  10028. /**
  10029. * Specifies if the light will affect the passed mesh.
  10030. * @param mesh The mesh to test against the light
  10031. * @return true the mesh is affected otherwise, false.
  10032. */
  10033. canAffectMesh(mesh: AbstractMesh): boolean;
  10034. /**
  10035. * Sort function to order lights for rendering.
  10036. * @param a First Light object to compare to second.
  10037. * @param b Second Light object to compare first.
  10038. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10039. */
  10040. static CompareLightsPriority(a: Light, b: Light): number;
  10041. /**
  10042. * Releases resources associated with this node.
  10043. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10044. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10045. */
  10046. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10047. /**
  10048. * Returns the light type ID (integer).
  10049. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10050. */
  10051. getTypeID(): number;
  10052. /**
  10053. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10054. * @returns the scaled intensity in intensity mode unit
  10055. */
  10056. getScaledIntensity(): number;
  10057. /**
  10058. * Returns a new Light object, named "name", from the current one.
  10059. * @param name The name of the cloned light
  10060. * @returns the new created light
  10061. */
  10062. clone(name: string): Nullable<Light>;
  10063. /**
  10064. * Serializes the current light into a Serialization object.
  10065. * @returns the serialized object.
  10066. */
  10067. serialize(): any;
  10068. /**
  10069. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10070. * This new light is named "name" and added to the passed scene.
  10071. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10072. * @param name The friendly name of the light
  10073. * @param scene The scene the new light will belong to
  10074. * @returns the constructor function
  10075. */
  10076. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10077. /**
  10078. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10079. * @param parsedLight The JSON representation of the light
  10080. * @param scene The scene to create the parsed light in
  10081. * @returns the created light after parsing
  10082. */
  10083. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10084. private _hookArrayForExcluded;
  10085. private _hookArrayForIncludedOnly;
  10086. private _resyncMeshes;
  10087. /**
  10088. * Forces the meshes to update their light related information in their rendering used effects
  10089. * @hidden Internal Use Only
  10090. */
  10091. _markMeshesAsLightDirty(): void;
  10092. /**
  10093. * Recomputes the cached photometric scale if needed.
  10094. */
  10095. private _computePhotometricScale;
  10096. /**
  10097. * Returns the Photometric Scale according to the light type and intensity mode.
  10098. */
  10099. private _getPhotometricScale;
  10100. /**
  10101. * Reorder the light in the scene according to their defined priority.
  10102. * @hidden Internal Use Only
  10103. */
  10104. _reorderLightsInScene(): void;
  10105. /**
  10106. * Prepares the list of defines specific to the light type.
  10107. * @param defines the list of defines
  10108. * @param lightIndex defines the index of the light for the effect
  10109. */
  10110. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10111. }
  10112. }
  10113. declare module "babylonjs/Actions/action" {
  10114. import { Observable } from "babylonjs/Misc/observable";
  10115. import { Condition } from "babylonjs/Actions/condition";
  10116. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10117. import { ActionManager } from "babylonjs/Actions/actionManager";
  10118. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10119. /**
  10120. * Interface used to define Action
  10121. */
  10122. export interface IAction {
  10123. /**
  10124. * Trigger for the action
  10125. */
  10126. trigger: number;
  10127. /** Options of the trigger */
  10128. triggerOptions: any;
  10129. /**
  10130. * Gets the trigger parameters
  10131. * @returns the trigger parameters
  10132. */
  10133. getTriggerParameter(): any;
  10134. /**
  10135. * Internal only - executes current action event
  10136. * @hidden
  10137. */
  10138. _executeCurrent(evt?: ActionEvent): void;
  10139. /**
  10140. * Serialize placeholder for child classes
  10141. * @param parent of child
  10142. * @returns the serialized object
  10143. */
  10144. serialize(parent: any): any;
  10145. /**
  10146. * Internal only
  10147. * @hidden
  10148. */
  10149. _prepare(): void;
  10150. /**
  10151. * Internal only - manager for action
  10152. * @hidden
  10153. */
  10154. _actionManager: AbstractActionManager;
  10155. /**
  10156. * Adds action to chain of actions, may be a DoNothingAction
  10157. * @param action defines the next action to execute
  10158. * @returns The action passed in
  10159. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10160. */
  10161. then(action: IAction): IAction;
  10162. }
  10163. /**
  10164. * The action to be carried out following a trigger
  10165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10166. */
  10167. export class Action implements IAction {
  10168. /** the trigger, with or without parameters, for the action */
  10169. triggerOptions: any;
  10170. /**
  10171. * Trigger for the action
  10172. */
  10173. trigger: number;
  10174. /**
  10175. * Internal only - manager for action
  10176. * @hidden
  10177. */
  10178. _actionManager: ActionManager;
  10179. private _nextActiveAction;
  10180. private _child;
  10181. private _condition?;
  10182. private _triggerParameter;
  10183. /**
  10184. * An event triggered prior to action being executed.
  10185. */
  10186. onBeforeExecuteObservable: Observable<Action>;
  10187. /**
  10188. * Creates a new Action
  10189. * @param triggerOptions the trigger, with or without parameters, for the action
  10190. * @param condition an optional determinant of action
  10191. */
  10192. constructor(
  10193. /** the trigger, with or without parameters, for the action */
  10194. triggerOptions: any, condition?: Condition);
  10195. /**
  10196. * Internal only
  10197. * @hidden
  10198. */
  10199. _prepare(): void;
  10200. /**
  10201. * Gets the trigger parameters
  10202. * @returns the trigger parameters
  10203. */
  10204. getTriggerParameter(): any;
  10205. /**
  10206. * Internal only - executes current action event
  10207. * @hidden
  10208. */
  10209. _executeCurrent(evt?: ActionEvent): void;
  10210. /**
  10211. * Execute placeholder for child classes
  10212. * @param evt optional action event
  10213. */
  10214. execute(evt?: ActionEvent): void;
  10215. /**
  10216. * Skips to next active action
  10217. */
  10218. skipToNextActiveAction(): void;
  10219. /**
  10220. * Adds action to chain of actions, may be a DoNothingAction
  10221. * @param action defines the next action to execute
  10222. * @returns The action passed in
  10223. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10224. */
  10225. then(action: Action): Action;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getProperty(propertyPath: string): string;
  10231. /**
  10232. * Internal only
  10233. * @hidden
  10234. */
  10235. _getEffectiveTarget(target: any, propertyPath: string): any;
  10236. /**
  10237. * Serialize placeholder for child classes
  10238. * @param parent of child
  10239. * @returns the serialized object
  10240. */
  10241. serialize(parent: any): any;
  10242. /**
  10243. * Internal only called by serialize
  10244. * @hidden
  10245. */
  10246. protected _serialize(serializedAction: any, parent?: any): any;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _SerializeValueAsString: (value: any) => string;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10257. name: string;
  10258. targetType: string;
  10259. value: string;
  10260. };
  10261. }
  10262. }
  10263. declare module "babylonjs/Actions/condition" {
  10264. import { ActionManager } from "babylonjs/Actions/actionManager";
  10265. /**
  10266. * A Condition applied to an Action
  10267. */
  10268. export class Condition {
  10269. /**
  10270. * Internal only - manager for action
  10271. * @hidden
  10272. */
  10273. _actionManager: ActionManager;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _evaluationId: number;
  10279. /**
  10280. * Internal only
  10281. * @hidden
  10282. */
  10283. _currentResult: boolean;
  10284. /**
  10285. * Creates a new Condition
  10286. * @param actionManager the manager of the action the condition is applied to
  10287. */
  10288. constructor(actionManager: ActionManager);
  10289. /**
  10290. * Check if the current condition is valid
  10291. * @returns a boolean
  10292. */
  10293. isValid(): boolean;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getProperty(propertyPath: string): string;
  10299. /**
  10300. * Internal only
  10301. * @hidden
  10302. */
  10303. _getEffectiveTarget(target: any, propertyPath: string): any;
  10304. /**
  10305. * Serialize placeholder for child classes
  10306. * @returns the serialized object
  10307. */
  10308. serialize(): any;
  10309. /**
  10310. * Internal only
  10311. * @hidden
  10312. */
  10313. protected _serialize(serializedCondition: any): any;
  10314. }
  10315. /**
  10316. * Defines specific conditional operators as extensions of Condition
  10317. */
  10318. export class ValueCondition extends Condition {
  10319. /** path to specify the property of the target the conditional operator uses */
  10320. propertyPath: string;
  10321. /** the value compared by the conditional operator against the current value of the property */
  10322. value: any;
  10323. /** the conditional operator, default ValueCondition.IsEqual */
  10324. operator: number;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsEqual;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsDifferent;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsGreater;
  10340. /**
  10341. * Internal only
  10342. * @hidden
  10343. */
  10344. private static _IsLesser;
  10345. /**
  10346. * returns the number for IsEqual
  10347. */
  10348. static readonly IsEqual: number;
  10349. /**
  10350. * Returns the number for IsDifferent
  10351. */
  10352. static readonly IsDifferent: number;
  10353. /**
  10354. * Returns the number for IsGreater
  10355. */
  10356. static readonly IsGreater: number;
  10357. /**
  10358. * Returns the number for IsLesser
  10359. */
  10360. static readonly IsLesser: number;
  10361. /**
  10362. * Internal only The action manager for the condition
  10363. * @hidden
  10364. */
  10365. _actionManager: ActionManager;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _target;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _effectiveTarget;
  10376. /**
  10377. * Internal only
  10378. * @hidden
  10379. */
  10380. private _property;
  10381. /**
  10382. * Creates a new ValueCondition
  10383. * @param actionManager manager for the action the condition applies to
  10384. * @param target for the action
  10385. * @param propertyPath path to specify the property of the target the conditional operator uses
  10386. * @param value the value compared by the conditional operator against the current value of the property
  10387. * @param operator the conditional operator, default ValueCondition.IsEqual
  10388. */
  10389. constructor(actionManager: ActionManager, target: any,
  10390. /** path to specify the property of the target the conditional operator uses */
  10391. propertyPath: string,
  10392. /** the value compared by the conditional operator against the current value of the property */
  10393. value: any,
  10394. /** the conditional operator, default ValueCondition.IsEqual */
  10395. operator?: number);
  10396. /**
  10397. * Compares the given value with the property value for the specified conditional operator
  10398. * @returns the result of the comparison
  10399. */
  10400. isValid(): boolean;
  10401. /**
  10402. * Serialize the ValueCondition into a JSON compatible object
  10403. * @returns serialization object
  10404. */
  10405. serialize(): any;
  10406. /**
  10407. * Gets the name of the conditional operator for the ValueCondition
  10408. * @param operator the conditional operator
  10409. * @returns the name
  10410. */
  10411. static GetOperatorName(operator: number): string;
  10412. }
  10413. /**
  10414. * Defines a predicate condition as an extension of Condition
  10415. */
  10416. export class PredicateCondition extends Condition {
  10417. /** defines the predicate function used to validate the condition */
  10418. predicate: () => boolean;
  10419. /**
  10420. * Internal only - manager for action
  10421. * @hidden
  10422. */
  10423. _actionManager: ActionManager;
  10424. /**
  10425. * Creates a new PredicateCondition
  10426. * @param actionManager manager for the action the condition applies to
  10427. * @param predicate defines the predicate function used to validate the condition
  10428. */
  10429. constructor(actionManager: ActionManager,
  10430. /** defines the predicate function used to validate the condition */
  10431. predicate: () => boolean);
  10432. /**
  10433. * @returns the validity of the predicate condition
  10434. */
  10435. isValid(): boolean;
  10436. }
  10437. /**
  10438. * Defines a state condition as an extension of Condition
  10439. */
  10440. export class StateCondition extends Condition {
  10441. /** Value to compare with target state */
  10442. value: string;
  10443. /**
  10444. * Internal only - manager for action
  10445. * @hidden
  10446. */
  10447. _actionManager: ActionManager;
  10448. /**
  10449. * Internal only
  10450. * @hidden
  10451. */
  10452. private _target;
  10453. /**
  10454. * Creates a new StateCondition
  10455. * @param actionManager manager for the action the condition applies to
  10456. * @param target of the condition
  10457. * @param value to compare with target state
  10458. */
  10459. constructor(actionManager: ActionManager, target: any,
  10460. /** Value to compare with target state */
  10461. value: string);
  10462. /**
  10463. * Gets a boolean indicating if the current condition is met
  10464. * @returns the validity of the state
  10465. */
  10466. isValid(): boolean;
  10467. /**
  10468. * Serialize the StateCondition into a JSON compatible object
  10469. * @returns serialization object
  10470. */
  10471. serialize(): any;
  10472. }
  10473. }
  10474. declare module "babylonjs/Actions/directActions" {
  10475. import { Action } from "babylonjs/Actions/action";
  10476. import { Condition } from "babylonjs/Actions/condition";
  10477. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10478. /**
  10479. * This defines an action responsible to toggle a boolean once triggered.
  10480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10481. */
  10482. export class SwitchBooleanAction extends Action {
  10483. /**
  10484. * The path to the boolean property in the target object
  10485. */
  10486. propertyPath: string;
  10487. private _target;
  10488. private _effectiveTarget;
  10489. private _property;
  10490. /**
  10491. * Instantiate the action
  10492. * @param triggerOptions defines the trigger options
  10493. * @param target defines the object containing the boolean
  10494. * @param propertyPath defines the path to the boolean property in the target object
  10495. * @param condition defines the trigger related conditions
  10496. */
  10497. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10498. /** @hidden */
  10499. _prepare(): void;
  10500. /**
  10501. * Execute the action toggle the boolean value.
  10502. */
  10503. execute(): void;
  10504. /**
  10505. * Serializes the actions and its related information.
  10506. * @param parent defines the object to serialize in
  10507. * @returns the serialized object
  10508. */
  10509. serialize(parent: any): any;
  10510. }
  10511. /**
  10512. * This defines an action responsible to set a the state field of the target
  10513. * to a desired value once triggered.
  10514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10515. */
  10516. export class SetStateAction extends Action {
  10517. /**
  10518. * The value to store in the state field.
  10519. */
  10520. value: string;
  10521. private _target;
  10522. /**
  10523. * Instantiate the action
  10524. * @param triggerOptions defines the trigger options
  10525. * @param target defines the object containing the state property
  10526. * @param value defines the value to store in the state field
  10527. * @param condition defines the trigger related conditions
  10528. */
  10529. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10530. /**
  10531. * Execute the action and store the value on the target state property.
  10532. */
  10533. execute(): void;
  10534. /**
  10535. * Serializes the actions and its related information.
  10536. * @param parent defines the object to serialize in
  10537. * @returns the serialized object
  10538. */
  10539. serialize(parent: any): any;
  10540. }
  10541. /**
  10542. * This defines an action responsible to set a property of the target
  10543. * to a desired value once triggered.
  10544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10545. */
  10546. export class SetValueAction extends Action {
  10547. /**
  10548. * The path of the property to set in the target.
  10549. */
  10550. propertyPath: string;
  10551. /**
  10552. * The value to set in the property
  10553. */
  10554. value: any;
  10555. private _target;
  10556. private _effectiveTarget;
  10557. private _property;
  10558. /**
  10559. * Instantiate the action
  10560. * @param triggerOptions defines the trigger options
  10561. * @param target defines the object containing the property
  10562. * @param propertyPath defines the path of the property to set in the target
  10563. * @param value defines the value to set in the property
  10564. * @param condition defines the trigger related conditions
  10565. */
  10566. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10567. /** @hidden */
  10568. _prepare(): void;
  10569. /**
  10570. * Execute the action and set the targetted property to the desired value.
  10571. */
  10572. execute(): void;
  10573. /**
  10574. * Serializes the actions and its related information.
  10575. * @param parent defines the object to serialize in
  10576. * @returns the serialized object
  10577. */
  10578. serialize(parent: any): any;
  10579. }
  10580. /**
  10581. * This defines an action responsible to increment the target value
  10582. * to a desired value once triggered.
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10584. */
  10585. export class IncrementValueAction extends Action {
  10586. /**
  10587. * The path of the property to increment in the target.
  10588. */
  10589. propertyPath: string;
  10590. /**
  10591. * The value we should increment the property by.
  10592. */
  10593. value: any;
  10594. private _target;
  10595. private _effectiveTarget;
  10596. private _property;
  10597. /**
  10598. * Instantiate the action
  10599. * @param triggerOptions defines the trigger options
  10600. * @param target defines the object containing the property
  10601. * @param propertyPath defines the path of the property to increment in the target
  10602. * @param value defines the value value we should increment the property by
  10603. * @param condition defines the trigger related conditions
  10604. */
  10605. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10606. /** @hidden */
  10607. _prepare(): void;
  10608. /**
  10609. * Execute the action and increment the target of the value amount.
  10610. */
  10611. execute(): void;
  10612. /**
  10613. * Serializes the actions and its related information.
  10614. * @param parent defines the object to serialize in
  10615. * @returns the serialized object
  10616. */
  10617. serialize(parent: any): any;
  10618. }
  10619. /**
  10620. * This defines an action responsible to start an animation once triggered.
  10621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10622. */
  10623. export class PlayAnimationAction extends Action {
  10624. /**
  10625. * Where the animation should start (animation frame)
  10626. */
  10627. from: number;
  10628. /**
  10629. * Where the animation should stop (animation frame)
  10630. */
  10631. to: number;
  10632. /**
  10633. * Define if the animation should loop or stop after the first play.
  10634. */
  10635. loop?: boolean;
  10636. private _target;
  10637. /**
  10638. * Instantiate the action
  10639. * @param triggerOptions defines the trigger options
  10640. * @param target defines the target animation or animation name
  10641. * @param from defines from where the animation should start (animation frame)
  10642. * @param end defines where the animation should stop (animation frame)
  10643. * @param loop defines if the animation should loop or stop after the first play
  10644. * @param condition defines the trigger related conditions
  10645. */
  10646. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10647. /** @hidden */
  10648. _prepare(): void;
  10649. /**
  10650. * Execute the action and play the animation.
  10651. */
  10652. execute(): void;
  10653. /**
  10654. * Serializes the actions and its related information.
  10655. * @param parent defines the object to serialize in
  10656. * @returns the serialized object
  10657. */
  10658. serialize(parent: any): any;
  10659. }
  10660. /**
  10661. * This defines an action responsible to stop an animation once triggered.
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10663. */
  10664. export class StopAnimationAction extends Action {
  10665. private _target;
  10666. /**
  10667. * Instantiate the action
  10668. * @param triggerOptions defines the trigger options
  10669. * @param target defines the target animation or animation name
  10670. * @param condition defines the trigger related conditions
  10671. */
  10672. constructor(triggerOptions: any, target: any, condition?: Condition);
  10673. /** @hidden */
  10674. _prepare(): void;
  10675. /**
  10676. * Execute the action and stop the animation.
  10677. */
  10678. execute(): void;
  10679. /**
  10680. * Serializes the actions and its related information.
  10681. * @param parent defines the object to serialize in
  10682. * @returns the serialized object
  10683. */
  10684. serialize(parent: any): any;
  10685. }
  10686. /**
  10687. * This defines an action responsible that does nothing once triggered.
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10689. */
  10690. export class DoNothingAction extends Action {
  10691. /**
  10692. * Instantiate the action
  10693. * @param triggerOptions defines the trigger options
  10694. * @param condition defines the trigger related conditions
  10695. */
  10696. constructor(triggerOptions?: any, condition?: Condition);
  10697. /**
  10698. * Execute the action and do nothing.
  10699. */
  10700. execute(): void;
  10701. /**
  10702. * Serializes the actions and its related information.
  10703. * @param parent defines the object to serialize in
  10704. * @returns the serialized object
  10705. */
  10706. serialize(parent: any): any;
  10707. }
  10708. /**
  10709. * This defines an action responsible to trigger several actions once triggered.
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10711. */
  10712. export class CombineAction extends Action {
  10713. /**
  10714. * The list of aggregated animations to run.
  10715. */
  10716. children: Action[];
  10717. /**
  10718. * Instantiate the action
  10719. * @param triggerOptions defines the trigger options
  10720. * @param children defines the list of aggregated animations to run
  10721. * @param condition defines the trigger related conditions
  10722. */
  10723. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10724. /** @hidden */
  10725. _prepare(): void;
  10726. /**
  10727. * Execute the action and executes all the aggregated actions.
  10728. */
  10729. execute(evt: ActionEvent): void;
  10730. /**
  10731. * Serializes the actions and its related information.
  10732. * @param parent defines the object to serialize in
  10733. * @returns the serialized object
  10734. */
  10735. serialize(parent: any): any;
  10736. }
  10737. /**
  10738. * This defines an action responsible to run code (external event) once triggered.
  10739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10740. */
  10741. export class ExecuteCodeAction extends Action {
  10742. /**
  10743. * The callback function to run.
  10744. */
  10745. func: (evt: ActionEvent) => void;
  10746. /**
  10747. * Instantiate the action
  10748. * @param triggerOptions defines the trigger options
  10749. * @param func defines the callback function to run
  10750. * @param condition defines the trigger related conditions
  10751. */
  10752. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10753. /**
  10754. * Execute the action and run the attached code.
  10755. */
  10756. execute(evt: ActionEvent): void;
  10757. }
  10758. /**
  10759. * This defines an action responsible to set the parent property of the target once triggered.
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10761. */
  10762. export class SetParentAction extends Action {
  10763. private _parent;
  10764. private _target;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param target defines the target containing the parent property
  10769. * @param parent defines from where the animation should start (animation frame)
  10770. * @param condition defines the trigger related conditions
  10771. */
  10772. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10773. /** @hidden */
  10774. _prepare(): void;
  10775. /**
  10776. * Execute the action and set the parent property.
  10777. */
  10778. execute(): void;
  10779. /**
  10780. * Serializes the actions and its related information.
  10781. * @param parent defines the object to serialize in
  10782. * @returns the serialized object
  10783. */
  10784. serialize(parent: any): any;
  10785. }
  10786. }
  10787. declare module "babylonjs/Actions/actionManager" {
  10788. import { Nullable } from "babylonjs/types";
  10789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10790. import { Scene } from "babylonjs/scene";
  10791. import { IAction } from "babylonjs/Actions/action";
  10792. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10793. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10794. /**
  10795. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10796. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class ActionManager extends AbstractActionManager {
  10800. /**
  10801. * Nothing
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly NothingTrigger: number;
  10805. /**
  10806. * On pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnPickTrigger: number;
  10810. /**
  10811. * On left pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnLeftPickTrigger: number;
  10815. /**
  10816. * On right pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnRightPickTrigger: number;
  10820. /**
  10821. * On center pick
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnCenterPickTrigger: number;
  10825. /**
  10826. * On pick down
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnPickDownTrigger: number;
  10830. /**
  10831. * On double pick
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnDoublePickTrigger: number;
  10835. /**
  10836. * On pick up
  10837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10838. */
  10839. static readonly OnPickUpTrigger: number;
  10840. /**
  10841. * On pick out.
  10842. * This trigger will only be raised if you also declared a OnPickDown
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnPickOutTrigger: number;
  10846. /**
  10847. * On long press
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnLongPressTrigger: number;
  10851. /**
  10852. * On pointer over
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOverTrigger: number;
  10856. /**
  10857. * On pointer out
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnPointerOutTrigger: number;
  10861. /**
  10862. * On every frame
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnEveryFrameTrigger: number;
  10866. /**
  10867. * On intersection enter
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionEnterTrigger: number;
  10871. /**
  10872. * On intersection exit
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnIntersectionExitTrigger: number;
  10876. /**
  10877. * On key down
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyDownTrigger: number;
  10881. /**
  10882. * On key up
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10884. */
  10885. static readonly OnKeyUpTrigger: number;
  10886. private _scene;
  10887. /**
  10888. * Creates a new action manager
  10889. * @param scene defines the hosting scene
  10890. */
  10891. constructor(scene: Scene);
  10892. /**
  10893. * Releases all associated resources
  10894. */
  10895. dispose(): void;
  10896. /**
  10897. * Gets hosting scene
  10898. * @returns the hosting scene
  10899. */
  10900. getScene(): Scene;
  10901. /**
  10902. * Does this action manager handles actions of any of the given triggers
  10903. * @param triggers defines the triggers to be tested
  10904. * @return a boolean indicating whether one (or more) of the triggers is handled
  10905. */
  10906. hasSpecificTriggers(triggers: number[]): boolean;
  10907. /**
  10908. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10909. * speed.
  10910. * @param triggerA defines the trigger to be tested
  10911. * @param triggerB defines the trigger to be tested
  10912. * @return a boolean indicating whether one (or more) of the triggers is handled
  10913. */
  10914. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10915. /**
  10916. * Does this action manager handles actions of a given trigger
  10917. * @param trigger defines the trigger to be tested
  10918. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10919. * @return whether the trigger is handled
  10920. */
  10921. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10922. /**
  10923. * Does this action manager has pointer triggers
  10924. */
  10925. readonly hasPointerTriggers: boolean;
  10926. /**
  10927. * Does this action manager has pick triggers
  10928. */
  10929. readonly hasPickTriggers: boolean;
  10930. /**
  10931. * Registers an action to this action manager
  10932. * @param action defines the action to be registered
  10933. * @return the action amended (prepared) after registration
  10934. */
  10935. registerAction(action: IAction): Nullable<IAction>;
  10936. /**
  10937. * Unregisters an action to this action manager
  10938. * @param action defines the action to be unregistered
  10939. * @return a boolean indicating whether the action has been unregistered
  10940. */
  10941. unregisterAction(action: IAction): Boolean;
  10942. /**
  10943. * Process a specific trigger
  10944. * @param trigger defines the trigger to process
  10945. * @param evt defines the event details to be processed
  10946. */
  10947. processTrigger(trigger: number, evt?: IActionEvent): void;
  10948. /** @hidden */
  10949. _getEffectiveTarget(target: any, propertyPath: string): any;
  10950. /** @hidden */
  10951. _getProperty(propertyPath: string): string;
  10952. /**
  10953. * Serialize this manager to a JSON object
  10954. * @param name defines the property name to store this manager
  10955. * @returns a JSON representation of this manager
  10956. */
  10957. serialize(name: string): any;
  10958. /**
  10959. * Creates a new ActionManager from a JSON data
  10960. * @param parsedActions defines the JSON data to read from
  10961. * @param object defines the hosting mesh
  10962. * @param scene defines the hosting scene
  10963. */
  10964. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10965. /**
  10966. * Get a trigger name by index
  10967. * @param trigger defines the trigger index
  10968. * @returns a trigger name
  10969. */
  10970. static GetTriggerName(trigger: number): string;
  10971. }
  10972. }
  10973. declare module "babylonjs/Culling/ray" {
  10974. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10975. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10977. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10978. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10979. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10980. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10981. import { Plane } from "babylonjs/Maths/math.plane";
  10982. /**
  10983. * Class representing a ray with position and direction
  10984. */
  10985. export class Ray {
  10986. /** origin point */
  10987. origin: Vector3;
  10988. /** direction */
  10989. direction: Vector3;
  10990. /** length of the ray */
  10991. length: number;
  10992. private static readonly TmpVector3;
  10993. private _tmpRay;
  10994. /**
  10995. * Creates a new ray
  10996. * @param origin origin point
  10997. * @param direction direction
  10998. * @param length length of the ray
  10999. */
  11000. constructor(
  11001. /** origin point */
  11002. origin: Vector3,
  11003. /** direction */
  11004. direction: Vector3,
  11005. /** length of the ray */
  11006. length?: number);
  11007. /**
  11008. * Checks if the ray intersects a box
  11009. * @param minimum bound of the box
  11010. * @param maximum bound of the box
  11011. * @param intersectionTreshold extra extend to be added to the box in all direction
  11012. * @returns if the box was hit
  11013. */
  11014. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11015. /**
  11016. * Checks if the ray intersects a box
  11017. * @param box the bounding box to check
  11018. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11019. * @returns if the box was hit
  11020. */
  11021. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11022. /**
  11023. * If the ray hits a sphere
  11024. * @param sphere the bounding sphere to check
  11025. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11026. * @returns true if it hits the sphere
  11027. */
  11028. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11029. /**
  11030. * If the ray hits a triange
  11031. * @param vertex0 triangle vertex
  11032. * @param vertex1 triangle vertex
  11033. * @param vertex2 triangle vertex
  11034. * @returns intersection information if hit
  11035. */
  11036. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11037. /**
  11038. * Checks if ray intersects a plane
  11039. * @param plane the plane to check
  11040. * @returns the distance away it was hit
  11041. */
  11042. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11043. /**
  11044. * Calculate the intercept of a ray on a given axis
  11045. * @param axis to check 'x' | 'y' | 'z'
  11046. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11047. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11048. */
  11049. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11050. /**
  11051. * Checks if ray intersects a mesh
  11052. * @param mesh the mesh to check
  11053. * @param fastCheck if only the bounding box should checked
  11054. * @returns picking info of the intersecton
  11055. */
  11056. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11057. /**
  11058. * Checks if ray intersects a mesh
  11059. * @param meshes the meshes to check
  11060. * @param fastCheck if only the bounding box should checked
  11061. * @param results array to store result in
  11062. * @returns Array of picking infos
  11063. */
  11064. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11065. private _comparePickingInfo;
  11066. private static smallnum;
  11067. private static rayl;
  11068. /**
  11069. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11070. * @param sega the first point of the segment to test the intersection against
  11071. * @param segb the second point of the segment to test the intersection against
  11072. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11073. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11074. */
  11075. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11076. /**
  11077. * Update the ray from viewport position
  11078. * @param x position
  11079. * @param y y position
  11080. * @param viewportWidth viewport width
  11081. * @param viewportHeight viewport height
  11082. * @param world world matrix
  11083. * @param view view matrix
  11084. * @param projection projection matrix
  11085. * @returns this ray updated
  11086. */
  11087. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11088. /**
  11089. * Creates a ray with origin and direction of 0,0,0
  11090. * @returns the new ray
  11091. */
  11092. static Zero(): Ray;
  11093. /**
  11094. * Creates a new ray from screen space and viewport
  11095. * @param x position
  11096. * @param y y position
  11097. * @param viewportWidth viewport width
  11098. * @param viewportHeight viewport height
  11099. * @param world world matrix
  11100. * @param view view matrix
  11101. * @param projection projection matrix
  11102. * @returns new ray
  11103. */
  11104. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11105. /**
  11106. * 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
  11107. * transformed to the given world matrix.
  11108. * @param origin The origin point
  11109. * @param end The end point
  11110. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11111. * @returns the new ray
  11112. */
  11113. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11114. /**
  11115. * Transforms a ray by a matrix
  11116. * @param ray ray to transform
  11117. * @param matrix matrix to apply
  11118. * @returns the resulting new ray
  11119. */
  11120. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11121. /**
  11122. * Transforms a ray by a matrix
  11123. * @param ray ray to transform
  11124. * @param matrix matrix to apply
  11125. * @param result ray to store result in
  11126. */
  11127. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11128. /**
  11129. * Unproject a ray from screen space to object space
  11130. * @param sourceX defines the screen space x coordinate to use
  11131. * @param sourceY defines the screen space y coordinate to use
  11132. * @param viewportWidth defines the current width of the viewport
  11133. * @param viewportHeight defines the current height of the viewport
  11134. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11135. * @param view defines the view matrix to use
  11136. * @param projection defines the projection matrix to use
  11137. */
  11138. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11139. }
  11140. /**
  11141. * Type used to define predicate used to select faces when a mesh intersection is detected
  11142. */
  11143. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11144. module "babylonjs/scene" {
  11145. interface Scene {
  11146. /** @hidden */
  11147. _tempPickingRay: Nullable<Ray>;
  11148. /** @hidden */
  11149. _cachedRayForTransform: Ray;
  11150. /** @hidden */
  11151. _pickWithRayInverseMatrix: Matrix;
  11152. /** @hidden */
  11153. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11154. /** @hidden */
  11155. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11156. }
  11157. }
  11158. }
  11159. declare module "babylonjs/sceneComponent" {
  11160. import { Scene } from "babylonjs/scene";
  11161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11163. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11164. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11165. import { Nullable } from "babylonjs/types";
  11166. import { Camera } from "babylonjs/Cameras/camera";
  11167. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11168. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11169. import { AbstractScene } from "babylonjs/abstractScene";
  11170. /**
  11171. * Groups all the scene component constants in one place to ease maintenance.
  11172. * @hidden
  11173. */
  11174. export class SceneComponentConstants {
  11175. static readonly NAME_EFFECTLAYER: string;
  11176. static readonly NAME_LAYER: string;
  11177. static readonly NAME_LENSFLARESYSTEM: string;
  11178. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11179. static readonly NAME_PARTICLESYSTEM: string;
  11180. static readonly NAME_GAMEPAD: string;
  11181. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11182. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11183. static readonly NAME_DEPTHRENDERER: string;
  11184. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11185. static readonly NAME_SPRITE: string;
  11186. static readonly NAME_OUTLINERENDERER: string;
  11187. static readonly NAME_PROCEDURALTEXTURE: string;
  11188. static readonly NAME_SHADOWGENERATOR: string;
  11189. static readonly NAME_OCTREE: string;
  11190. static readonly NAME_PHYSICSENGINE: string;
  11191. static readonly NAME_AUDIO: string;
  11192. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11193. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11194. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11195. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11196. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11197. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11198. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11199. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11200. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11201. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11202. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11203. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11204. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11205. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11206. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11207. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11208. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11209. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11210. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11211. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11212. static readonly STEP_AFTERRENDER_AUDIO: number;
  11213. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11214. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11215. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11216. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11217. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11218. static readonly STEP_POINTERMOVE_SPRITE: number;
  11219. static readonly STEP_POINTERDOWN_SPRITE: number;
  11220. static readonly STEP_POINTERUP_SPRITE: number;
  11221. }
  11222. /**
  11223. * This represents a scene component.
  11224. *
  11225. * This is used to decouple the dependency the scene is having on the different workloads like
  11226. * layers, post processes...
  11227. */
  11228. export interface ISceneComponent {
  11229. /**
  11230. * The name of the component. Each component must have a unique name.
  11231. */
  11232. name: string;
  11233. /**
  11234. * The scene the component belongs to.
  11235. */
  11236. scene: Scene;
  11237. /**
  11238. * Register the component to one instance of a scene.
  11239. */
  11240. register(): void;
  11241. /**
  11242. * Rebuilds the elements related to this component in case of
  11243. * context lost for instance.
  11244. */
  11245. rebuild(): void;
  11246. /**
  11247. * Disposes the component and the associated ressources.
  11248. */
  11249. dispose(): void;
  11250. }
  11251. /**
  11252. * This represents a SERIALIZABLE scene component.
  11253. *
  11254. * This extends Scene Component to add Serialization methods on top.
  11255. */
  11256. export interface ISceneSerializableComponent extends ISceneComponent {
  11257. /**
  11258. * Adds all the elements from the container to the scene
  11259. * @param container the container holding the elements
  11260. */
  11261. addFromContainer(container: AbstractScene): void;
  11262. /**
  11263. * Removes all the elements in the container from the scene
  11264. * @param container contains the elements to remove
  11265. * @param dispose if the removed element should be disposed (default: false)
  11266. */
  11267. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11268. /**
  11269. * Serializes the component data to the specified json object
  11270. * @param serializationObject The object to serialize to
  11271. */
  11272. serialize(serializationObject: any): void;
  11273. }
  11274. /**
  11275. * Strong typing of a Mesh related stage step action
  11276. */
  11277. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11278. /**
  11279. * Strong typing of a Evaluate Sub Mesh related stage step action
  11280. */
  11281. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11282. /**
  11283. * Strong typing of a Active Mesh related stage step action
  11284. */
  11285. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11286. /**
  11287. * Strong typing of a Camera related stage step action
  11288. */
  11289. export type CameraStageAction = (camera: Camera) => void;
  11290. /**
  11291. * Strong typing of a Camera Frame buffer related stage step action
  11292. */
  11293. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11294. /**
  11295. * Strong typing of a Render Target related stage step action
  11296. */
  11297. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11298. /**
  11299. * Strong typing of a RenderingGroup related stage step action
  11300. */
  11301. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11302. /**
  11303. * Strong typing of a Mesh Render related stage step action
  11304. */
  11305. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11306. /**
  11307. * Strong typing of a simple stage step action
  11308. */
  11309. export type SimpleStageAction = () => void;
  11310. /**
  11311. * Strong typing of a render target action.
  11312. */
  11313. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11314. /**
  11315. * Strong typing of a pointer move action.
  11316. */
  11317. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11318. /**
  11319. * Strong typing of a pointer up/down action.
  11320. */
  11321. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11322. /**
  11323. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11324. * @hidden
  11325. */
  11326. export class Stage<T extends Function> extends Array<{
  11327. index: number;
  11328. component: ISceneComponent;
  11329. action: T;
  11330. }> {
  11331. /**
  11332. * Hide ctor from the rest of the world.
  11333. * @param items The items to add.
  11334. */
  11335. private constructor();
  11336. /**
  11337. * Creates a new Stage.
  11338. * @returns A new instance of a Stage
  11339. */
  11340. static Create<T extends Function>(): Stage<T>;
  11341. /**
  11342. * Registers a step in an ordered way in the targeted stage.
  11343. * @param index Defines the position to register the step in
  11344. * @param component Defines the component attached to the step
  11345. * @param action Defines the action to launch during the step
  11346. */
  11347. registerStep(index: number, component: ISceneComponent, action: T): void;
  11348. /**
  11349. * Clears all the steps from the stage.
  11350. */
  11351. clear(): void;
  11352. }
  11353. }
  11354. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11355. import { Nullable } from "babylonjs/types";
  11356. import { Observable } from "babylonjs/Misc/observable";
  11357. import { Scene } from "babylonjs/scene";
  11358. import { Sprite } from "babylonjs/Sprites/sprite";
  11359. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11360. import { Ray } from "babylonjs/Culling/ray";
  11361. import { Camera } from "babylonjs/Cameras/camera";
  11362. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11363. import { ISceneComponent } from "babylonjs/sceneComponent";
  11364. module "babylonjs/scene" {
  11365. interface Scene {
  11366. /** @hidden */
  11367. _pointerOverSprite: Nullable<Sprite>;
  11368. /** @hidden */
  11369. _pickedDownSprite: Nullable<Sprite>;
  11370. /** @hidden */
  11371. _tempSpritePickingRay: Nullable<Ray>;
  11372. /**
  11373. * All of the sprite managers added to this scene
  11374. * @see http://doc.babylonjs.com/babylon101/sprites
  11375. */
  11376. spriteManagers: Array<ISpriteManager>;
  11377. /**
  11378. * An event triggered when sprites rendering is about to start
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11382. /**
  11383. * An event triggered when sprites rendering is done
  11384. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11385. */
  11386. onAfterSpritesRenderingObservable: Observable<Scene>;
  11387. /** @hidden */
  11388. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11389. /** Launch a ray to try to pick a sprite in the scene
  11390. * @param x position on screen
  11391. * @param y position on screen
  11392. * @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
  11393. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11394. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11395. * @returns a PickingInfo
  11396. */
  11397. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11398. /** Use the given ray to pick a sprite in the scene
  11399. * @param ray The ray (in world space) to use to pick meshes
  11400. * @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
  11401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11402. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11403. * @returns a PickingInfo
  11404. */
  11405. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11406. /** @hidden */
  11407. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11408. /** Launch a ray to try to pick sprites in the scene
  11409. * @param x position on screen
  11410. * @param y position on screen
  11411. * @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
  11412. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11413. * @returns a PickingInfo array
  11414. */
  11415. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11416. /** Use the given ray to pick sprites in the scene
  11417. * @param ray The ray (in world space) to use to pick meshes
  11418. * @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
  11419. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11420. * @returns a PickingInfo array
  11421. */
  11422. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11423. /**
  11424. * Force the sprite under the pointer
  11425. * @param sprite defines the sprite to use
  11426. */
  11427. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11428. /**
  11429. * Gets the sprite under the pointer
  11430. * @returns a Sprite or null if no sprite is under the pointer
  11431. */
  11432. getPointerOverSprite(): Nullable<Sprite>;
  11433. }
  11434. }
  11435. /**
  11436. * Defines the sprite scene component responsible to manage sprites
  11437. * in a given scene.
  11438. */
  11439. export class SpriteSceneComponent implements ISceneComponent {
  11440. /**
  11441. * The component name helpfull to identify the component in the list of scene components.
  11442. */
  11443. readonly name: string;
  11444. /**
  11445. * The scene the component belongs to.
  11446. */
  11447. scene: Scene;
  11448. /** @hidden */
  11449. private _spritePredicate;
  11450. /**
  11451. * Creates a new instance of the component for the given scene
  11452. * @param scene Defines the scene to register the component in
  11453. */
  11454. constructor(scene: Scene);
  11455. /**
  11456. * Registers the component in a given scene
  11457. */
  11458. register(): void;
  11459. /**
  11460. * Rebuilds the elements related to this component in case of
  11461. * context lost for instance.
  11462. */
  11463. rebuild(): void;
  11464. /**
  11465. * Disposes the component and the associated ressources.
  11466. */
  11467. dispose(): void;
  11468. private _pickSpriteButKeepRay;
  11469. private _pointerMove;
  11470. private _pointerDown;
  11471. private _pointerUp;
  11472. }
  11473. }
  11474. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11475. /** @hidden */
  11476. export var fogFragmentDeclaration: {
  11477. name: string;
  11478. shader: string;
  11479. };
  11480. }
  11481. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11482. /** @hidden */
  11483. export var fogFragment: {
  11484. name: string;
  11485. shader: string;
  11486. };
  11487. }
  11488. declare module "babylonjs/Shaders/sprites.fragment" {
  11489. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11490. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11491. /** @hidden */
  11492. export var spritesPixelShader: {
  11493. name: string;
  11494. shader: string;
  11495. };
  11496. }
  11497. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11498. /** @hidden */
  11499. export var fogVertexDeclaration: {
  11500. name: string;
  11501. shader: string;
  11502. };
  11503. }
  11504. declare module "babylonjs/Shaders/sprites.vertex" {
  11505. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11506. /** @hidden */
  11507. export var spritesVertexShader: {
  11508. name: string;
  11509. shader: string;
  11510. };
  11511. }
  11512. declare module "babylonjs/Sprites/spriteManager" {
  11513. import { IDisposable, Scene } from "babylonjs/scene";
  11514. import { Nullable } from "babylonjs/types";
  11515. import { Observable } from "babylonjs/Misc/observable";
  11516. import { Sprite } from "babylonjs/Sprites/sprite";
  11517. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11518. import { Camera } from "babylonjs/Cameras/camera";
  11519. import { Texture } from "babylonjs/Materials/Textures/texture";
  11520. import "babylonjs/Shaders/sprites.fragment";
  11521. import "babylonjs/Shaders/sprites.vertex";
  11522. import { Ray } from "babylonjs/Culling/ray";
  11523. /**
  11524. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11525. */
  11526. export interface ISpriteManager extends IDisposable {
  11527. /**
  11528. * Restricts the camera to viewing objects with the same layerMask.
  11529. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11530. */
  11531. layerMask: number;
  11532. /**
  11533. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11534. */
  11535. isPickable: boolean;
  11536. /**
  11537. * Specifies the rendering group id for this mesh (0 by default)
  11538. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11539. */
  11540. renderingGroupId: number;
  11541. /**
  11542. * Defines the list of sprites managed by the manager.
  11543. */
  11544. sprites: Array<Sprite>;
  11545. /**
  11546. * Tests the intersection of a sprite with a specific ray.
  11547. * @param ray The ray we are sending to test the collision
  11548. * @param camera The camera space we are sending rays in
  11549. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11550. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11551. * @returns picking info or null.
  11552. */
  11553. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11554. /**
  11555. * Intersects the sprites with a ray
  11556. * @param ray defines the ray to intersect with
  11557. * @param camera defines the current active camera
  11558. * @param predicate defines a predicate used to select candidate sprites
  11559. * @returns null if no hit or a PickingInfo array
  11560. */
  11561. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11562. /**
  11563. * Renders the list of sprites on screen.
  11564. */
  11565. render(): void;
  11566. }
  11567. /**
  11568. * Class used to manage multiple sprites on the same spritesheet
  11569. * @see http://doc.babylonjs.com/babylon101/sprites
  11570. */
  11571. export class SpriteManager implements ISpriteManager {
  11572. /** defines the manager's name */
  11573. name: string;
  11574. /** Gets the list of sprites */
  11575. sprites: Sprite[];
  11576. /** Gets or sets the rendering group id (0 by default) */
  11577. renderingGroupId: number;
  11578. /** Gets or sets camera layer mask */
  11579. layerMask: number;
  11580. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11581. fogEnabled: boolean;
  11582. /** Gets or sets a boolean indicating if the sprites are pickable */
  11583. isPickable: boolean;
  11584. /** Defines the default width of a cell in the spritesheet */
  11585. cellWidth: number;
  11586. /** Defines the default height of a cell in the spritesheet */
  11587. cellHeight: number;
  11588. /** Associative array from JSON sprite data file */
  11589. private _cellData;
  11590. /** Array of sprite names from JSON sprite data file */
  11591. private _spriteMap;
  11592. /** True when packed cell data from JSON file is ready*/
  11593. private _packedAndReady;
  11594. /**
  11595. * An event triggered when the manager is disposed.
  11596. */
  11597. onDisposeObservable: Observable<SpriteManager>;
  11598. private _onDisposeObserver;
  11599. /**
  11600. * Callback called when the manager is disposed
  11601. */
  11602. onDispose: () => void;
  11603. private _capacity;
  11604. private _fromPacked;
  11605. private _spriteTexture;
  11606. private _epsilon;
  11607. private _scene;
  11608. private _vertexData;
  11609. private _buffer;
  11610. private _vertexBuffers;
  11611. private _indexBuffer;
  11612. private _effectBase;
  11613. private _effectFog;
  11614. /**
  11615. * Gets or sets the spritesheet texture
  11616. */
  11617. texture: Texture;
  11618. /**
  11619. * Creates a new sprite manager
  11620. * @param name defines the manager's name
  11621. * @param imgUrl defines the sprite sheet url
  11622. * @param capacity defines the maximum allowed number of sprites
  11623. * @param cellSize defines the size of a sprite cell
  11624. * @param scene defines the hosting scene
  11625. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11626. * @param samplingMode defines the smapling mode to use with spritesheet
  11627. * @param fromPacked set to false; do not alter
  11628. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11629. */
  11630. constructor(
  11631. /** defines the manager's name */
  11632. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11633. private _makePacked;
  11634. private _appendSpriteVertex;
  11635. /**
  11636. * Intersects the sprites with a ray
  11637. * @param ray defines the ray to intersect with
  11638. * @param camera defines the current active camera
  11639. * @param predicate defines a predicate used to select candidate sprites
  11640. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11641. * @returns null if no hit or a PickingInfo
  11642. */
  11643. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11644. /**
  11645. * Intersects the sprites with a ray
  11646. * @param ray defines the ray to intersect with
  11647. * @param camera defines the current active camera
  11648. * @param predicate defines a predicate used to select candidate sprites
  11649. * @returns null if no hit or a PickingInfo array
  11650. */
  11651. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11652. /**
  11653. * Render all child sprites
  11654. */
  11655. render(): void;
  11656. /**
  11657. * Release associated resources
  11658. */
  11659. dispose(): void;
  11660. }
  11661. }
  11662. declare module "babylonjs/Sprites/sprite" {
  11663. import { Vector3 } from "babylonjs/Maths/math.vector";
  11664. import { Nullable } from "babylonjs/types";
  11665. import { ActionManager } from "babylonjs/Actions/actionManager";
  11666. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11667. import { Color4 } from "babylonjs/Maths/math.color";
  11668. /**
  11669. * Class used to represent a sprite
  11670. * @see http://doc.babylonjs.com/babylon101/sprites
  11671. */
  11672. export class Sprite {
  11673. /** defines the name */
  11674. name: string;
  11675. /** Gets or sets the current world position */
  11676. position: Vector3;
  11677. /** Gets or sets the main color */
  11678. color: Color4;
  11679. /** Gets or sets the width */
  11680. width: number;
  11681. /** Gets or sets the height */
  11682. height: number;
  11683. /** Gets or sets rotation angle */
  11684. angle: number;
  11685. /** Gets or sets the cell index in the sprite sheet */
  11686. cellIndex: number;
  11687. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11688. cellRef: string;
  11689. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11690. invertU: number;
  11691. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11692. invertV: number;
  11693. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11694. disposeWhenFinishedAnimating: boolean;
  11695. /** Gets the list of attached animations */
  11696. animations: Animation[];
  11697. /** Gets or sets a boolean indicating if the sprite can be picked */
  11698. isPickable: boolean;
  11699. /**
  11700. * Gets or sets the associated action manager
  11701. */
  11702. actionManager: Nullable<ActionManager>;
  11703. private _animationStarted;
  11704. private _loopAnimation;
  11705. private _fromIndex;
  11706. private _toIndex;
  11707. private _delay;
  11708. private _direction;
  11709. private _manager;
  11710. private _time;
  11711. private _onAnimationEnd;
  11712. /**
  11713. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11714. */
  11715. isVisible: boolean;
  11716. /**
  11717. * Gets or sets the sprite size
  11718. */
  11719. size: number;
  11720. /**
  11721. * Creates a new Sprite
  11722. * @param name defines the name
  11723. * @param manager defines the manager
  11724. */
  11725. constructor(
  11726. /** defines the name */
  11727. name: string, manager: ISpriteManager);
  11728. /**
  11729. * Starts an animation
  11730. * @param from defines the initial key
  11731. * @param to defines the end key
  11732. * @param loop defines if the animation must loop
  11733. * @param delay defines the start delay (in ms)
  11734. * @param onAnimationEnd defines a callback to call when animation ends
  11735. */
  11736. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11737. /** Stops current animation (if any) */
  11738. stopAnimation(): void;
  11739. /** @hidden */
  11740. _animate(deltaTime: number): void;
  11741. /** Release associated resources */
  11742. dispose(): void;
  11743. }
  11744. }
  11745. declare module "babylonjs/Collisions/pickingInfo" {
  11746. import { Nullable } from "babylonjs/types";
  11747. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11749. import { Sprite } from "babylonjs/Sprites/sprite";
  11750. import { Ray } from "babylonjs/Culling/ray";
  11751. /**
  11752. * Information about the result of picking within a scene
  11753. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11754. */
  11755. export class PickingInfo {
  11756. /** @hidden */
  11757. _pickingUnavailable: boolean;
  11758. /**
  11759. * If the pick collided with an object
  11760. */
  11761. hit: boolean;
  11762. /**
  11763. * Distance away where the pick collided
  11764. */
  11765. distance: number;
  11766. /**
  11767. * The location of pick collision
  11768. */
  11769. pickedPoint: Nullable<Vector3>;
  11770. /**
  11771. * The mesh corresponding the the pick collision
  11772. */
  11773. pickedMesh: Nullable<AbstractMesh>;
  11774. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11775. bu: number;
  11776. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11777. bv: number;
  11778. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11779. faceId: number;
  11780. /** Id of the the submesh that was picked */
  11781. subMeshId: number;
  11782. /** If a sprite was picked, this will be the sprite the pick collided with */
  11783. pickedSprite: Nullable<Sprite>;
  11784. /**
  11785. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11786. */
  11787. originMesh: Nullable<AbstractMesh>;
  11788. /**
  11789. * The ray that was used to perform the picking.
  11790. */
  11791. ray: Nullable<Ray>;
  11792. /**
  11793. * Gets the normal correspodning to the face the pick collided with
  11794. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11795. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11796. * @returns The normal correspodning to the face the pick collided with
  11797. */
  11798. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11799. /**
  11800. * Gets the texture coordinates of where the pick occured
  11801. * @returns the vector containing the coordnates of the texture
  11802. */
  11803. getTextureCoordinates(): Nullable<Vector2>;
  11804. }
  11805. }
  11806. declare module "babylonjs/Events/pointerEvents" {
  11807. import { Nullable } from "babylonjs/types";
  11808. import { Vector2 } from "babylonjs/Maths/math.vector";
  11809. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11810. import { Ray } from "babylonjs/Culling/ray";
  11811. /**
  11812. * Gather the list of pointer event types as constants.
  11813. */
  11814. export class PointerEventTypes {
  11815. /**
  11816. * 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.
  11817. */
  11818. static readonly POINTERDOWN: number;
  11819. /**
  11820. * The pointerup event is fired when a pointer is no longer active.
  11821. */
  11822. static readonly POINTERUP: number;
  11823. /**
  11824. * The pointermove event is fired when a pointer changes coordinates.
  11825. */
  11826. static readonly POINTERMOVE: number;
  11827. /**
  11828. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11829. */
  11830. static readonly POINTERWHEEL: number;
  11831. /**
  11832. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11833. */
  11834. static readonly POINTERPICK: number;
  11835. /**
  11836. * The pointertap event is fired when a the object has been touched and released without drag.
  11837. */
  11838. static readonly POINTERTAP: number;
  11839. /**
  11840. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11841. */
  11842. static readonly POINTERDOUBLETAP: number;
  11843. }
  11844. /**
  11845. * Base class of pointer info types.
  11846. */
  11847. export class PointerInfoBase {
  11848. /**
  11849. * Defines the type of event (PointerEventTypes)
  11850. */
  11851. type: number;
  11852. /**
  11853. * Defines the related dom event
  11854. */
  11855. event: PointerEvent | MouseWheelEvent;
  11856. /**
  11857. * Instantiates the base class of pointers info.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. */
  11861. constructor(
  11862. /**
  11863. * Defines the type of event (PointerEventTypes)
  11864. */
  11865. type: number,
  11866. /**
  11867. * Defines the related dom event
  11868. */
  11869. event: PointerEvent | MouseWheelEvent);
  11870. }
  11871. /**
  11872. * This class is used to store pointer related info for the onPrePointerObservable event.
  11873. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11874. */
  11875. export class PointerInfoPre extends PointerInfoBase {
  11876. /**
  11877. * Ray from a pointer if availible (eg. 6dof controller)
  11878. */
  11879. ray: Nullable<Ray>;
  11880. /**
  11881. * Defines the local position of the pointer on the canvas.
  11882. */
  11883. localPosition: Vector2;
  11884. /**
  11885. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11886. */
  11887. skipOnPointerObservable: boolean;
  11888. /**
  11889. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11890. * @param type Defines the type of event (PointerEventTypes)
  11891. * @param event Defines the related dom event
  11892. * @param localX Defines the local x coordinates of the pointer when the event occured
  11893. * @param localY Defines the local y coordinates of the pointer when the event occured
  11894. */
  11895. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11896. }
  11897. /**
  11898. * This type contains all the data related to a pointer event in Babylon.js.
  11899. * 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.
  11900. */
  11901. export class PointerInfo extends PointerInfoBase {
  11902. /**
  11903. * Defines the picking info associated to the info (if any)\
  11904. */
  11905. pickInfo: Nullable<PickingInfo>;
  11906. /**
  11907. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11908. * @param type Defines the type of event (PointerEventTypes)
  11909. * @param event Defines the related dom event
  11910. * @param pickInfo Defines the picking info associated to the info (if any)\
  11911. */
  11912. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11913. /**
  11914. * Defines the picking info associated to the info (if any)\
  11915. */
  11916. pickInfo: Nullable<PickingInfo>);
  11917. }
  11918. /**
  11919. * Data relating to a touch event on the screen.
  11920. */
  11921. export interface PointerTouch {
  11922. /**
  11923. * X coordinate of touch.
  11924. */
  11925. x: number;
  11926. /**
  11927. * Y coordinate of touch.
  11928. */
  11929. y: number;
  11930. /**
  11931. * Id of touch. Unique for each finger.
  11932. */
  11933. pointerId: number;
  11934. /**
  11935. * Event type passed from DOM.
  11936. */
  11937. type: any;
  11938. }
  11939. }
  11940. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11941. import { Observable } from "babylonjs/Misc/observable";
  11942. import { Nullable } from "babylonjs/types";
  11943. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11944. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11945. /**
  11946. * Manage the mouse inputs to control the movement of a free camera.
  11947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11948. */
  11949. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11950. /**
  11951. * Define if touch is enabled in the mouse input
  11952. */
  11953. touchEnabled: boolean;
  11954. /**
  11955. * Defines the camera the input is attached to.
  11956. */
  11957. camera: FreeCamera;
  11958. /**
  11959. * Defines the buttons associated with the input to handle camera move.
  11960. */
  11961. buttons: number[];
  11962. /**
  11963. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11964. */
  11965. angularSensibility: number;
  11966. private _pointerInput;
  11967. private _onMouseMove;
  11968. private _observer;
  11969. private previousPosition;
  11970. /**
  11971. * Observable for when a pointer move event occurs containing the move offset
  11972. */
  11973. onPointerMovedObservable: Observable<{
  11974. offsetX: number;
  11975. offsetY: number;
  11976. }>;
  11977. /**
  11978. * @hidden
  11979. * If the camera should be rotated automatically based on pointer movement
  11980. */
  11981. _allowCameraRotation: boolean;
  11982. /**
  11983. * Manage the mouse inputs to control the movement of a free camera.
  11984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11985. * @param touchEnabled Defines if touch is enabled or not
  11986. */
  11987. constructor(
  11988. /**
  11989. * Define if touch is enabled in the mouse input
  11990. */
  11991. touchEnabled?: boolean);
  11992. /**
  11993. * Attach the input controls to a specific dom element to get the input from.
  11994. * @param element Defines the element the controls should be listened from
  11995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11996. */
  11997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11998. /**
  11999. * Called on JS contextmenu event.
  12000. * Override this method to provide functionality.
  12001. */
  12002. protected onContextMenu(evt: PointerEvent): void;
  12003. /**
  12004. * Detach the current controls from the specified dom element.
  12005. * @param element Defines the element to stop listening the inputs from
  12006. */
  12007. detachControl(element: Nullable<HTMLElement>): void;
  12008. /**
  12009. * Gets the class name of the current intput.
  12010. * @returns the class name
  12011. */
  12012. getClassName(): string;
  12013. /**
  12014. * Get the friendly name associated with the input class.
  12015. * @returns the input friendly name
  12016. */
  12017. getSimpleName(): string;
  12018. }
  12019. }
  12020. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12021. import { Nullable } from "babylonjs/types";
  12022. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12023. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12024. /**
  12025. * Manage the touch inputs to control the movement of a free camera.
  12026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12027. */
  12028. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12029. /**
  12030. * Defines the camera the input is attached to.
  12031. */
  12032. camera: FreeCamera;
  12033. /**
  12034. * Defines the touch sensibility for rotation.
  12035. * The higher the faster.
  12036. */
  12037. touchAngularSensibility: number;
  12038. /**
  12039. * Defines the touch sensibility for move.
  12040. * The higher the faster.
  12041. */
  12042. touchMoveSensibility: number;
  12043. private _offsetX;
  12044. private _offsetY;
  12045. private _pointerPressed;
  12046. private _pointerInput;
  12047. private _observer;
  12048. private _onLostFocus;
  12049. /**
  12050. * Attach the input controls to a specific dom element to get the input from.
  12051. * @param element Defines the element the controls should be listened from
  12052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12053. */
  12054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12055. /**
  12056. * Detach the current controls from the specified dom element.
  12057. * @param element Defines the element to stop listening the inputs from
  12058. */
  12059. detachControl(element: Nullable<HTMLElement>): void;
  12060. /**
  12061. * Update the current camera state depending on the inputs that have been used this frame.
  12062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12063. */
  12064. checkInputs(): void;
  12065. /**
  12066. * Gets the class name of the current intput.
  12067. * @returns the class name
  12068. */
  12069. getClassName(): string;
  12070. /**
  12071. * Get the friendly name associated with the input class.
  12072. * @returns the input friendly name
  12073. */
  12074. getSimpleName(): string;
  12075. }
  12076. }
  12077. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12078. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12079. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12080. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12081. import { Nullable } from "babylonjs/types";
  12082. /**
  12083. * Default Inputs manager for the FreeCamera.
  12084. * It groups all the default supported inputs for ease of use.
  12085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12086. */
  12087. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12088. /**
  12089. * @hidden
  12090. */
  12091. _mouseInput: Nullable<FreeCameraMouseInput>;
  12092. /**
  12093. * Instantiates a new FreeCameraInputsManager.
  12094. * @param camera Defines the camera the inputs belong to
  12095. */
  12096. constructor(camera: FreeCamera);
  12097. /**
  12098. * Add keyboard input support to the input manager.
  12099. * @returns the current input manager
  12100. */
  12101. addKeyboard(): FreeCameraInputsManager;
  12102. /**
  12103. * Add mouse input support to the input manager.
  12104. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12105. * @returns the current input manager
  12106. */
  12107. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12108. /**
  12109. * Removes the mouse input support from the manager
  12110. * @returns the current input manager
  12111. */
  12112. removeMouse(): FreeCameraInputsManager;
  12113. /**
  12114. * Add touch input support to the input manager.
  12115. * @returns the current input manager
  12116. */
  12117. addTouch(): FreeCameraInputsManager;
  12118. /**
  12119. * Remove all attached input methods from a camera
  12120. */
  12121. clear(): void;
  12122. }
  12123. }
  12124. declare module "babylonjs/Cameras/freeCamera" {
  12125. import { Vector3 } from "babylonjs/Maths/math.vector";
  12126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12127. import { Scene } from "babylonjs/scene";
  12128. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12129. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12130. /**
  12131. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12132. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12133. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12134. */
  12135. export class FreeCamera extends TargetCamera {
  12136. /**
  12137. * Define the collision ellipsoid of the camera.
  12138. * This is helpful to simulate a camera body like the player body around the camera
  12139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12140. */
  12141. ellipsoid: Vector3;
  12142. /**
  12143. * Define an offset for the position of the ellipsoid around the camera.
  12144. * This can be helpful to determine the center of the body near the gravity center of the body
  12145. * instead of its head.
  12146. */
  12147. ellipsoidOffset: Vector3;
  12148. /**
  12149. * Enable or disable collisions of the camera with the rest of the scene objects.
  12150. */
  12151. checkCollisions: boolean;
  12152. /**
  12153. * Enable or disable gravity on the camera.
  12154. */
  12155. applyGravity: boolean;
  12156. /**
  12157. * Define the input manager associated to the camera.
  12158. */
  12159. inputs: FreeCameraInputsManager;
  12160. /**
  12161. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12162. * Higher values reduce sensitivity.
  12163. */
  12164. /**
  12165. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12166. * Higher values reduce sensitivity.
  12167. */
  12168. angularSensibility: number;
  12169. /**
  12170. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12171. */
  12172. keysUp: number[];
  12173. /**
  12174. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12175. */
  12176. keysDown: number[];
  12177. /**
  12178. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12179. */
  12180. keysLeft: number[];
  12181. /**
  12182. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12183. */
  12184. keysRight: number[];
  12185. /**
  12186. * Event raised when the camera collide with a mesh in the scene.
  12187. */
  12188. onCollide: (collidedMesh: AbstractMesh) => void;
  12189. private _collider;
  12190. private _needMoveForGravity;
  12191. private _oldPosition;
  12192. private _diffPosition;
  12193. private _newPosition;
  12194. /** @hidden */
  12195. _localDirection: Vector3;
  12196. /** @hidden */
  12197. _transformedDirection: Vector3;
  12198. /**
  12199. * Instantiates a Free Camera.
  12200. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12201. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12202. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12203. * @param name Define the name of the camera in the scene
  12204. * @param position Define the start position of the camera in the scene
  12205. * @param scene Define the scene the camera belongs to
  12206. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12207. */
  12208. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12209. /**
  12210. * Attached controls to the current camera.
  12211. * @param element Defines the element the controls should be listened from
  12212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12213. */
  12214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12215. /**
  12216. * Detach the current controls from the camera.
  12217. * The camera will stop reacting to inputs.
  12218. * @param element Defines the element to stop listening the inputs from
  12219. */
  12220. detachControl(element: HTMLElement): void;
  12221. private _collisionMask;
  12222. /**
  12223. * Define a collision mask to limit the list of object the camera can collide with
  12224. */
  12225. collisionMask: number;
  12226. /** @hidden */
  12227. _collideWithWorld(displacement: Vector3): void;
  12228. private _onCollisionPositionChange;
  12229. /** @hidden */
  12230. _checkInputs(): void;
  12231. /** @hidden */
  12232. _decideIfNeedsToMove(): boolean;
  12233. /** @hidden */
  12234. _updatePosition(): void;
  12235. /**
  12236. * Destroy the camera and release the current resources hold by it.
  12237. */
  12238. dispose(): void;
  12239. /**
  12240. * Gets the current object class name.
  12241. * @return the class name
  12242. */
  12243. getClassName(): string;
  12244. }
  12245. }
  12246. declare module "babylonjs/Gamepads/gamepad" {
  12247. import { Observable } from "babylonjs/Misc/observable";
  12248. /**
  12249. * Represents a gamepad control stick position
  12250. */
  12251. export class StickValues {
  12252. /**
  12253. * The x component of the control stick
  12254. */
  12255. x: number;
  12256. /**
  12257. * The y component of the control stick
  12258. */
  12259. y: number;
  12260. /**
  12261. * Initializes the gamepad x and y control stick values
  12262. * @param x The x component of the gamepad control stick value
  12263. * @param y The y component of the gamepad control stick value
  12264. */
  12265. constructor(
  12266. /**
  12267. * The x component of the control stick
  12268. */
  12269. x: number,
  12270. /**
  12271. * The y component of the control stick
  12272. */
  12273. y: number);
  12274. }
  12275. /**
  12276. * An interface which manages callbacks for gamepad button changes
  12277. */
  12278. export interface GamepadButtonChanges {
  12279. /**
  12280. * Called when a gamepad has been changed
  12281. */
  12282. changed: boolean;
  12283. /**
  12284. * Called when a gamepad press event has been triggered
  12285. */
  12286. pressChanged: boolean;
  12287. /**
  12288. * Called when a touch event has been triggered
  12289. */
  12290. touchChanged: boolean;
  12291. /**
  12292. * Called when a value has changed
  12293. */
  12294. valueChanged: boolean;
  12295. }
  12296. /**
  12297. * Represents a gamepad
  12298. */
  12299. export class Gamepad {
  12300. /**
  12301. * The id of the gamepad
  12302. */
  12303. id: string;
  12304. /**
  12305. * The index of the gamepad
  12306. */
  12307. index: number;
  12308. /**
  12309. * The browser gamepad
  12310. */
  12311. browserGamepad: any;
  12312. /**
  12313. * Specifies what type of gamepad this represents
  12314. */
  12315. type: number;
  12316. private _leftStick;
  12317. private _rightStick;
  12318. /** @hidden */
  12319. _isConnected: boolean;
  12320. private _leftStickAxisX;
  12321. private _leftStickAxisY;
  12322. private _rightStickAxisX;
  12323. private _rightStickAxisY;
  12324. /**
  12325. * Triggered when the left control stick has been changed
  12326. */
  12327. private _onleftstickchanged;
  12328. /**
  12329. * Triggered when the right control stick has been changed
  12330. */
  12331. private _onrightstickchanged;
  12332. /**
  12333. * Represents a gamepad controller
  12334. */
  12335. static GAMEPAD: number;
  12336. /**
  12337. * Represents a generic controller
  12338. */
  12339. static GENERIC: number;
  12340. /**
  12341. * Represents an XBox controller
  12342. */
  12343. static XBOX: number;
  12344. /**
  12345. * Represents a pose-enabled controller
  12346. */
  12347. static POSE_ENABLED: number;
  12348. /**
  12349. * Represents an Dual Shock controller
  12350. */
  12351. static DUALSHOCK: number;
  12352. /**
  12353. * Specifies whether the left control stick should be Y-inverted
  12354. */
  12355. protected _invertLeftStickY: boolean;
  12356. /**
  12357. * Specifies if the gamepad has been connected
  12358. */
  12359. readonly isConnected: boolean;
  12360. /**
  12361. * Initializes the gamepad
  12362. * @param id The id of the gamepad
  12363. * @param index The index of the gamepad
  12364. * @param browserGamepad The browser gamepad
  12365. * @param leftStickX The x component of the left joystick
  12366. * @param leftStickY The y component of the left joystick
  12367. * @param rightStickX The x component of the right joystick
  12368. * @param rightStickY The y component of the right joystick
  12369. */
  12370. constructor(
  12371. /**
  12372. * The id of the gamepad
  12373. */
  12374. id: string,
  12375. /**
  12376. * The index of the gamepad
  12377. */
  12378. index: number,
  12379. /**
  12380. * The browser gamepad
  12381. */
  12382. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12383. /**
  12384. * Callback triggered when the left joystick has changed
  12385. * @param callback
  12386. */
  12387. onleftstickchanged(callback: (values: StickValues) => void): void;
  12388. /**
  12389. * Callback triggered when the right joystick has changed
  12390. * @param callback
  12391. */
  12392. onrightstickchanged(callback: (values: StickValues) => void): void;
  12393. /**
  12394. * Gets the left joystick
  12395. */
  12396. /**
  12397. * Sets the left joystick values
  12398. */
  12399. leftStick: StickValues;
  12400. /**
  12401. * Gets the right joystick
  12402. */
  12403. /**
  12404. * Sets the right joystick value
  12405. */
  12406. rightStick: StickValues;
  12407. /**
  12408. * Updates the gamepad joystick positions
  12409. */
  12410. update(): void;
  12411. /**
  12412. * Disposes the gamepad
  12413. */
  12414. dispose(): void;
  12415. }
  12416. /**
  12417. * Represents a generic gamepad
  12418. */
  12419. export class GenericPad extends Gamepad {
  12420. private _buttons;
  12421. private _onbuttondown;
  12422. private _onbuttonup;
  12423. /**
  12424. * Observable triggered when a button has been pressed
  12425. */
  12426. onButtonDownObservable: Observable<number>;
  12427. /**
  12428. * Observable triggered when a button has been released
  12429. */
  12430. onButtonUpObservable: Observable<number>;
  12431. /**
  12432. * Callback triggered when a button has been pressed
  12433. * @param callback Called when a button has been pressed
  12434. */
  12435. onbuttondown(callback: (buttonPressed: number) => void): void;
  12436. /**
  12437. * Callback triggered when a button has been released
  12438. * @param callback Called when a button has been released
  12439. */
  12440. onbuttonup(callback: (buttonReleased: number) => void): void;
  12441. /**
  12442. * Initializes the generic gamepad
  12443. * @param id The id of the generic gamepad
  12444. * @param index The index of the generic gamepad
  12445. * @param browserGamepad The browser gamepad
  12446. */
  12447. constructor(id: string, index: number, browserGamepad: any);
  12448. private _setButtonValue;
  12449. /**
  12450. * Updates the generic gamepad
  12451. */
  12452. update(): void;
  12453. /**
  12454. * Disposes the generic gamepad
  12455. */
  12456. dispose(): void;
  12457. }
  12458. }
  12459. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12460. import { Nullable } from "babylonjs/types";
  12461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12462. import { Scene } from "babylonjs/scene";
  12463. module "babylonjs/Engines/engine" {
  12464. interface Engine {
  12465. /**
  12466. * Creates a raw texture
  12467. * @param data defines the data to store in the texture
  12468. * @param width defines the width of the texture
  12469. * @param height defines the height of the texture
  12470. * @param format defines the format of the data
  12471. * @param generateMipMaps defines if the engine should generate the mip levels
  12472. * @param invertY defines if data must be stored with Y axis inverted
  12473. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12474. * @param compression defines the compression used (null by default)
  12475. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12476. * @returns the raw texture inside an InternalTexture
  12477. */
  12478. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12479. /**
  12480. * Update a raw texture
  12481. * @param texture defines the texture to update
  12482. * @param data defines the data to store in the texture
  12483. * @param format defines the format of the data
  12484. * @param invertY defines if data must be stored with Y axis inverted
  12485. */
  12486. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12487. /**
  12488. * Update a raw texture
  12489. * @param texture defines the texture to update
  12490. * @param data defines the data to store in the texture
  12491. * @param format defines the format of the data
  12492. * @param invertY defines if data must be stored with Y axis inverted
  12493. * @param compression defines the compression used (null by default)
  12494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12495. */
  12496. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12497. /**
  12498. * Creates a new raw cube texture
  12499. * @param data defines the array of data to use to create each face
  12500. * @param size defines the size of the textures
  12501. * @param format defines the format of the data
  12502. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12503. * @param generateMipMaps defines if the engine should generate the mip levels
  12504. * @param invertY defines if data must be stored with Y axis inverted
  12505. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12506. * @param compression defines the compression used (null by default)
  12507. * @returns the cube texture as an InternalTexture
  12508. */
  12509. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12510. /**
  12511. * Update a raw cube texture
  12512. * @param texture defines the texture to udpdate
  12513. * @param data defines the data to store
  12514. * @param format defines the data format
  12515. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12516. * @param invertY defines if data must be stored with Y axis inverted
  12517. */
  12518. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12519. /**
  12520. * Update a raw cube texture
  12521. * @param texture defines the texture to udpdate
  12522. * @param data defines the data to store
  12523. * @param format defines the data format
  12524. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12525. * @param invertY defines if data must be stored with Y axis inverted
  12526. * @param compression defines the compression used (null by default)
  12527. */
  12528. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12529. /**
  12530. * Update a raw cube texture
  12531. * @param texture defines the texture to udpdate
  12532. * @param data defines the data to store
  12533. * @param format defines the data format
  12534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12535. * @param invertY defines if data must be stored with Y axis inverted
  12536. * @param compression defines the compression used (null by default)
  12537. * @param level defines which level of the texture to update
  12538. */
  12539. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12540. /**
  12541. * Creates a new raw cube texture from a specified url
  12542. * @param url defines the url where the data is located
  12543. * @param scene defines the current scene
  12544. * @param size defines the size of the textures
  12545. * @param format defines the format of the data
  12546. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12547. * @param noMipmap defines if the engine should avoid generating the mip levels
  12548. * @param callback defines a callback used to extract texture data from loaded data
  12549. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12550. * @param onLoad defines a callback called when texture is loaded
  12551. * @param onError defines a callback called if there is an error
  12552. * @returns the cube texture as an InternalTexture
  12553. */
  12554. 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;
  12555. /**
  12556. * Creates a new raw cube texture from a specified url
  12557. * @param url defines the url where the data is located
  12558. * @param scene defines the current scene
  12559. * @param size defines the size of the textures
  12560. * @param format defines the format of the data
  12561. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12562. * @param noMipmap defines if the engine should avoid generating the mip levels
  12563. * @param callback defines a callback used to extract texture data from loaded data
  12564. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12565. * @param onLoad defines a callback called when texture is loaded
  12566. * @param onError defines a callback called if there is an error
  12567. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12568. * @param invertY defines if data must be stored with Y axis inverted
  12569. * @returns the cube texture as an InternalTexture
  12570. */
  12571. 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;
  12572. /**
  12573. * Creates a new raw 3D texture
  12574. * @param data defines the data used to create the texture
  12575. * @param width defines the width of the texture
  12576. * @param height defines the height of the texture
  12577. * @param depth defines the depth of the texture
  12578. * @param format defines the format of the texture
  12579. * @param generateMipMaps defines if the engine must generate mip levels
  12580. * @param invertY defines if data must be stored with Y axis inverted
  12581. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12582. * @param compression defines the compressed used (can be null)
  12583. * @param textureType defines the compressed used (can be null)
  12584. * @returns a new raw 3D texture (stored in an InternalTexture)
  12585. */
  12586. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12587. /**
  12588. * Update a raw 3D texture
  12589. * @param texture defines the texture to update
  12590. * @param data defines the data to store
  12591. * @param format defines the data format
  12592. * @param invertY defines if data must be stored with Y axis inverted
  12593. */
  12594. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12595. /**
  12596. * Update a raw 3D texture
  12597. * @param texture defines the texture to update
  12598. * @param data defines the data to store
  12599. * @param format defines the data format
  12600. * @param invertY defines if data must be stored with Y axis inverted
  12601. * @param compression defines the used compression (can be null)
  12602. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12603. */
  12604. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12605. }
  12606. }
  12607. }
  12608. declare module "babylonjs/Materials/Textures/rawTexture" {
  12609. import { Scene } from "babylonjs/scene";
  12610. import { Texture } from "babylonjs/Materials/Textures/texture";
  12611. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12612. /**
  12613. * Raw texture can help creating a texture directly from an array of data.
  12614. * This can be super useful if you either get the data from an uncompressed source or
  12615. * if you wish to create your texture pixel by pixel.
  12616. */
  12617. export class RawTexture extends Texture {
  12618. /**
  12619. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12620. */
  12621. format: number;
  12622. private _engine;
  12623. /**
  12624. * Instantiates a new RawTexture.
  12625. * Raw texture can help creating a texture directly from an array of data.
  12626. * This can be super useful if you either get the data from an uncompressed source or
  12627. * if you wish to create your texture pixel by pixel.
  12628. * @param data define the array of data to use to create the texture
  12629. * @param width define the width of the texture
  12630. * @param height define the height of the texture
  12631. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12632. * @param scene define the scene the texture belongs to
  12633. * @param generateMipMaps define whether mip maps should be generated or not
  12634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12636. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12637. */
  12638. constructor(data: ArrayBufferView, width: number, height: number,
  12639. /**
  12640. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12641. */
  12642. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12643. /**
  12644. * Updates the texture underlying data.
  12645. * @param data Define the new data of the texture
  12646. */
  12647. update(data: ArrayBufferView): void;
  12648. /**
  12649. * Creates a luminance texture from some data.
  12650. * @param data Define the texture data
  12651. * @param width Define the width of the texture
  12652. * @param height Define the height of the texture
  12653. * @param scene Define the scene the texture belongs to
  12654. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12655. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12656. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12657. * @returns the luminance texture
  12658. */
  12659. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12660. /**
  12661. * Creates a luminance alpha texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @returns the luminance alpha texture
  12670. */
  12671. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12672. /**
  12673. * Creates an alpha texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @returns the alpha texture
  12682. */
  12683. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12684. /**
  12685. * Creates a RGB texture from some data.
  12686. * @param data Define the texture data
  12687. * @param width Define the width of the texture
  12688. * @param height Define the height of the texture
  12689. * @param scene Define the scene the texture belongs to
  12690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12693. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12694. * @returns the RGB alpha texture
  12695. */
  12696. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12697. /**
  12698. * Creates a RGBA texture from some data.
  12699. * @param data Define the texture data
  12700. * @param width Define the width of the texture
  12701. * @param height Define the height of the texture
  12702. * @param scene Define the scene the texture belongs to
  12703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12706. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12707. * @returns the RGBA texture
  12708. */
  12709. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12710. /**
  12711. * Creates a R texture from some data.
  12712. * @param data Define the texture data
  12713. * @param width Define the width of the texture
  12714. * @param height Define the height of the texture
  12715. * @param scene Define the scene the texture belongs to
  12716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12719. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12720. * @returns the R texture
  12721. */
  12722. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12723. }
  12724. }
  12725. declare module "babylonjs/Maths/math.size" {
  12726. /**
  12727. * Interface for the size containing width and height
  12728. */
  12729. export interface ISize {
  12730. /**
  12731. * Width
  12732. */
  12733. width: number;
  12734. /**
  12735. * Heighht
  12736. */
  12737. height: number;
  12738. }
  12739. /**
  12740. * Size containing widht and height
  12741. */
  12742. export class Size implements ISize {
  12743. /**
  12744. * Width
  12745. */
  12746. width: number;
  12747. /**
  12748. * Height
  12749. */
  12750. height: number;
  12751. /**
  12752. * Creates a Size object from the given width and height (floats).
  12753. * @param width width of the new size
  12754. * @param height height of the new size
  12755. */
  12756. constructor(width: number, height: number);
  12757. /**
  12758. * Returns a string with the Size width and height
  12759. * @returns a string with the Size width and height
  12760. */
  12761. toString(): string;
  12762. /**
  12763. * "Size"
  12764. * @returns the string "Size"
  12765. */
  12766. getClassName(): string;
  12767. /**
  12768. * Returns the Size hash code.
  12769. * @returns a hash code for a unique width and height
  12770. */
  12771. getHashCode(): number;
  12772. /**
  12773. * Updates the current size from the given one.
  12774. * @param src the given size
  12775. */
  12776. copyFrom(src: Size): void;
  12777. /**
  12778. * Updates in place the current Size from the given floats.
  12779. * @param width width of the new size
  12780. * @param height height of the new size
  12781. * @returns the updated Size.
  12782. */
  12783. copyFromFloats(width: number, height: number): Size;
  12784. /**
  12785. * Updates in place the current Size from the given floats.
  12786. * @param width width to set
  12787. * @param height height to set
  12788. * @returns the updated Size.
  12789. */
  12790. set(width: number, height: number): Size;
  12791. /**
  12792. * Multiplies the width and height by numbers
  12793. * @param w factor to multiple the width by
  12794. * @param h factor to multiple the height by
  12795. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12796. */
  12797. multiplyByFloats(w: number, h: number): Size;
  12798. /**
  12799. * Clones the size
  12800. * @returns a new Size copied from the given one.
  12801. */
  12802. clone(): Size;
  12803. /**
  12804. * True if the current Size and the given one width and height are strictly equal.
  12805. * @param other the other size to compare against
  12806. * @returns True if the current Size and the given one width and height are strictly equal.
  12807. */
  12808. equals(other: Size): boolean;
  12809. /**
  12810. * The surface of the Size : width * height (float).
  12811. */
  12812. readonly surface: number;
  12813. /**
  12814. * Create a new size of zero
  12815. * @returns a new Size set to (0.0, 0.0)
  12816. */
  12817. static Zero(): Size;
  12818. /**
  12819. * Sums the width and height of two sizes
  12820. * @param otherSize size to add to this size
  12821. * @returns a new Size set as the addition result of the current Size and the given one.
  12822. */
  12823. add(otherSize: Size): Size;
  12824. /**
  12825. * Subtracts the width and height of two
  12826. * @param otherSize size to subtract to this size
  12827. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12828. */
  12829. subtract(otherSize: Size): Size;
  12830. /**
  12831. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12832. * @param start starting size to lerp between
  12833. * @param end end size to lerp between
  12834. * @param amount amount to lerp between the start and end values
  12835. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12836. */
  12837. static Lerp(start: Size, end: Size, amount: number): Size;
  12838. }
  12839. }
  12840. declare module "babylonjs/Animations/runtimeAnimation" {
  12841. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12842. import { Animatable } from "babylonjs/Animations/animatable";
  12843. import { Scene } from "babylonjs/scene";
  12844. /**
  12845. * Defines a runtime animation
  12846. */
  12847. export class RuntimeAnimation {
  12848. private _events;
  12849. /**
  12850. * The current frame of the runtime animation
  12851. */
  12852. private _currentFrame;
  12853. /**
  12854. * The animation used by the runtime animation
  12855. */
  12856. private _animation;
  12857. /**
  12858. * The target of the runtime animation
  12859. */
  12860. private _target;
  12861. /**
  12862. * The initiating animatable
  12863. */
  12864. private _host;
  12865. /**
  12866. * The original value of the runtime animation
  12867. */
  12868. private _originalValue;
  12869. /**
  12870. * The original blend value of the runtime animation
  12871. */
  12872. private _originalBlendValue;
  12873. /**
  12874. * The offsets cache of the runtime animation
  12875. */
  12876. private _offsetsCache;
  12877. /**
  12878. * The high limits cache of the runtime animation
  12879. */
  12880. private _highLimitsCache;
  12881. /**
  12882. * Specifies if the runtime animation has been stopped
  12883. */
  12884. private _stopped;
  12885. /**
  12886. * The blending factor of the runtime animation
  12887. */
  12888. private _blendingFactor;
  12889. /**
  12890. * The BabylonJS scene
  12891. */
  12892. private _scene;
  12893. /**
  12894. * The current value of the runtime animation
  12895. */
  12896. private _currentValue;
  12897. /** @hidden */
  12898. _animationState: _IAnimationState;
  12899. /**
  12900. * The active target of the runtime animation
  12901. */
  12902. private _activeTargets;
  12903. private _currentActiveTarget;
  12904. private _directTarget;
  12905. /**
  12906. * The target path of the runtime animation
  12907. */
  12908. private _targetPath;
  12909. /**
  12910. * The weight of the runtime animation
  12911. */
  12912. private _weight;
  12913. /**
  12914. * The ratio offset of the runtime animation
  12915. */
  12916. private _ratioOffset;
  12917. /**
  12918. * The previous delay of the runtime animation
  12919. */
  12920. private _previousDelay;
  12921. /**
  12922. * The previous ratio of the runtime animation
  12923. */
  12924. private _previousRatio;
  12925. private _enableBlending;
  12926. private _keys;
  12927. private _minFrame;
  12928. private _maxFrame;
  12929. private _minValue;
  12930. private _maxValue;
  12931. private _targetIsArray;
  12932. /**
  12933. * Gets the current frame of the runtime animation
  12934. */
  12935. readonly currentFrame: number;
  12936. /**
  12937. * Gets the weight of the runtime animation
  12938. */
  12939. readonly weight: number;
  12940. /**
  12941. * Gets the current value of the runtime animation
  12942. */
  12943. readonly currentValue: any;
  12944. /**
  12945. * Gets the target path of the runtime animation
  12946. */
  12947. readonly targetPath: string;
  12948. /**
  12949. * Gets the actual target of the runtime animation
  12950. */
  12951. readonly target: any;
  12952. /** @hidden */
  12953. _onLoop: () => void;
  12954. /**
  12955. * Create a new RuntimeAnimation object
  12956. * @param target defines the target of the animation
  12957. * @param animation defines the source animation object
  12958. * @param scene defines the hosting scene
  12959. * @param host defines the initiating Animatable
  12960. */
  12961. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12962. private _preparePath;
  12963. /**
  12964. * Gets the animation from the runtime animation
  12965. */
  12966. readonly animation: Animation;
  12967. /**
  12968. * Resets the runtime animation to the beginning
  12969. * @param restoreOriginal defines whether to restore the target property to the original value
  12970. */
  12971. reset(restoreOriginal?: boolean): void;
  12972. /**
  12973. * Specifies if the runtime animation is stopped
  12974. * @returns Boolean specifying if the runtime animation is stopped
  12975. */
  12976. isStopped(): boolean;
  12977. /**
  12978. * Disposes of the runtime animation
  12979. */
  12980. dispose(): void;
  12981. /**
  12982. * Apply the interpolated value to the target
  12983. * @param currentValue defines the value computed by the animation
  12984. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12985. */
  12986. setValue(currentValue: any, weight: number): void;
  12987. private _getOriginalValues;
  12988. private _setValue;
  12989. /**
  12990. * Gets the loop pmode of the runtime animation
  12991. * @returns Loop Mode
  12992. */
  12993. private _getCorrectLoopMode;
  12994. /**
  12995. * Move the current animation to a given frame
  12996. * @param frame defines the frame to move to
  12997. */
  12998. goToFrame(frame: number): void;
  12999. /**
  13000. * @hidden Internal use only
  13001. */
  13002. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13003. /**
  13004. * Execute the current animation
  13005. * @param delay defines the delay to add to the current frame
  13006. * @param from defines the lower bound of the animation range
  13007. * @param to defines the upper bound of the animation range
  13008. * @param loop defines if the current animation must loop
  13009. * @param speedRatio defines the current speed ratio
  13010. * @param weight defines the weight of the animation (default is -1 so no weight)
  13011. * @param onLoop optional callback called when animation loops
  13012. * @returns a boolean indicating if the animation is running
  13013. */
  13014. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13015. }
  13016. }
  13017. declare module "babylonjs/Animations/animatable" {
  13018. import { Animation } from "babylonjs/Animations/animation";
  13019. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13020. import { Nullable } from "babylonjs/types";
  13021. import { Observable } from "babylonjs/Misc/observable";
  13022. import { Scene } from "babylonjs/scene";
  13023. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13024. import { Node } from "babylonjs/node";
  13025. /**
  13026. * Class used to store an actual running animation
  13027. */
  13028. export class Animatable {
  13029. /** defines the target object */
  13030. target: any;
  13031. /** defines the starting frame number (default is 0) */
  13032. fromFrame: number;
  13033. /** defines the ending frame number (default is 100) */
  13034. toFrame: number;
  13035. /** defines if the animation must loop (default is false) */
  13036. loopAnimation: boolean;
  13037. /** defines a callback to call when animation ends if it is not looping */
  13038. onAnimationEnd?: (() => void) | null | undefined;
  13039. /** defines a callback to call when animation loops */
  13040. onAnimationLoop?: (() => void) | null | undefined;
  13041. private _localDelayOffset;
  13042. private _pausedDelay;
  13043. private _runtimeAnimations;
  13044. private _paused;
  13045. private _scene;
  13046. private _speedRatio;
  13047. private _weight;
  13048. private _syncRoot;
  13049. /**
  13050. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13051. * This will only apply for non looping animation (default is true)
  13052. */
  13053. disposeOnEnd: boolean;
  13054. /**
  13055. * Gets a boolean indicating if the animation has started
  13056. */
  13057. animationStarted: boolean;
  13058. /**
  13059. * Observer raised when the animation ends
  13060. */
  13061. onAnimationEndObservable: Observable<Animatable>;
  13062. /**
  13063. * Observer raised when the animation loops
  13064. */
  13065. onAnimationLoopObservable: Observable<Animatable>;
  13066. /**
  13067. * Gets the root Animatable used to synchronize and normalize animations
  13068. */
  13069. readonly syncRoot: Nullable<Animatable>;
  13070. /**
  13071. * Gets the current frame of the first RuntimeAnimation
  13072. * Used to synchronize Animatables
  13073. */
  13074. readonly masterFrame: number;
  13075. /**
  13076. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13077. */
  13078. weight: number;
  13079. /**
  13080. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13081. */
  13082. speedRatio: number;
  13083. /**
  13084. * Creates a new Animatable
  13085. * @param scene defines the hosting scene
  13086. * @param target defines the target object
  13087. * @param fromFrame defines the starting frame number (default is 0)
  13088. * @param toFrame defines the ending frame number (default is 100)
  13089. * @param loopAnimation defines if the animation must loop (default is false)
  13090. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13091. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13092. * @param animations defines a group of animation to add to the new Animatable
  13093. * @param onAnimationLoop defines a callback to call when animation loops
  13094. */
  13095. constructor(scene: Scene,
  13096. /** defines the target object */
  13097. target: any,
  13098. /** defines the starting frame number (default is 0) */
  13099. fromFrame?: number,
  13100. /** defines the ending frame number (default is 100) */
  13101. toFrame?: number,
  13102. /** defines if the animation must loop (default is false) */
  13103. loopAnimation?: boolean, speedRatio?: number,
  13104. /** defines a callback to call when animation ends if it is not looping */
  13105. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13106. /** defines a callback to call when animation loops */
  13107. onAnimationLoop?: (() => void) | null | undefined);
  13108. /**
  13109. * Synchronize and normalize current Animatable with a source Animatable
  13110. * This is useful when using animation weights and when animations are not of the same length
  13111. * @param root defines the root Animatable to synchronize with
  13112. * @returns the current Animatable
  13113. */
  13114. syncWith(root: Animatable): Animatable;
  13115. /**
  13116. * Gets the list of runtime animations
  13117. * @returns an array of RuntimeAnimation
  13118. */
  13119. getAnimations(): RuntimeAnimation[];
  13120. /**
  13121. * Adds more animations to the current animatable
  13122. * @param target defines the target of the animations
  13123. * @param animations defines the new animations to add
  13124. */
  13125. appendAnimations(target: any, animations: Animation[]): void;
  13126. /**
  13127. * Gets the source animation for a specific property
  13128. * @param property defines the propertyu to look for
  13129. * @returns null or the source animation for the given property
  13130. */
  13131. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13132. /**
  13133. * Gets the runtime animation for a specific property
  13134. * @param property defines the propertyu to look for
  13135. * @returns null or the runtime animation for the given property
  13136. */
  13137. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13138. /**
  13139. * Resets the animatable to its original state
  13140. */
  13141. reset(): void;
  13142. /**
  13143. * Allows the animatable to blend with current running animations
  13144. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13145. * @param blendingSpeed defines the blending speed to use
  13146. */
  13147. enableBlending(blendingSpeed: number): void;
  13148. /**
  13149. * Disable animation blending
  13150. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13151. */
  13152. disableBlending(): void;
  13153. /**
  13154. * Jump directly to a given frame
  13155. * @param frame defines the frame to jump to
  13156. */
  13157. goToFrame(frame: number): void;
  13158. /**
  13159. * Pause the animation
  13160. */
  13161. pause(): void;
  13162. /**
  13163. * Restart the animation
  13164. */
  13165. restart(): void;
  13166. private _raiseOnAnimationEnd;
  13167. /**
  13168. * Stop and delete the current animation
  13169. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13170. * @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)
  13171. */
  13172. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13173. /**
  13174. * Wait asynchronously for the animation to end
  13175. * @returns a promise which will be fullfilled when the animation ends
  13176. */
  13177. waitAsync(): Promise<Animatable>;
  13178. /** @hidden */
  13179. _animate(delay: number): boolean;
  13180. }
  13181. module "babylonjs/scene" {
  13182. interface Scene {
  13183. /** @hidden */
  13184. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13185. /** @hidden */
  13186. _processLateAnimationBindingsForMatrices(holder: {
  13187. totalWeight: number;
  13188. animations: RuntimeAnimation[];
  13189. originalValue: Matrix;
  13190. }): any;
  13191. /** @hidden */
  13192. _processLateAnimationBindingsForQuaternions(holder: {
  13193. totalWeight: number;
  13194. animations: RuntimeAnimation[];
  13195. originalValue: Quaternion;
  13196. }, refQuaternion: Quaternion): Quaternion;
  13197. /** @hidden */
  13198. _processLateAnimationBindings(): void;
  13199. /**
  13200. * Will start the animation sequence of a given target
  13201. * @param target defines the target
  13202. * @param from defines from which frame should animation start
  13203. * @param to defines until which frame should animation run.
  13204. * @param weight defines the weight to apply to the animation (1.0 by default)
  13205. * @param loop defines if the animation loops
  13206. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13207. * @param onAnimationEnd defines the function to be executed when the animation ends
  13208. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13209. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13210. * @param onAnimationLoop defines the callback to call when an animation loops
  13211. * @returns the animatable object created for this animation
  13212. */
  13213. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13214. /**
  13215. * Will start the animation sequence of a given target
  13216. * @param target defines the target
  13217. * @param from defines from which frame should animation start
  13218. * @param to defines until which frame should animation run.
  13219. * @param loop defines if the animation loops
  13220. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13221. * @param onAnimationEnd defines the function to be executed when the animation ends
  13222. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13223. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13224. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13225. * @param onAnimationLoop defines the callback to call when an animation loops
  13226. * @returns the animatable object created for this animation
  13227. */
  13228. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13229. /**
  13230. * Will start the animation sequence of a given target and its hierarchy
  13231. * @param target defines the target
  13232. * @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.
  13233. * @param from defines from which frame should animation start
  13234. * @param to defines until which frame should animation run.
  13235. * @param loop defines if the animation loops
  13236. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13237. * @param onAnimationEnd defines the function to be executed when the animation ends
  13238. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13239. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13240. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13241. * @param onAnimationLoop defines the callback to call when an animation loops
  13242. * @returns the list of created animatables
  13243. */
  13244. 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[];
  13245. /**
  13246. * Begin a new animation on a given node
  13247. * @param target defines the target where the animation will take place
  13248. * @param animations defines the list of animations to start
  13249. * @param from defines the initial value
  13250. * @param to defines the final value
  13251. * @param loop defines if you want animation to loop (off by default)
  13252. * @param speedRatio defines the speed ratio to apply to all animations
  13253. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13254. * @param onAnimationLoop defines the callback to call when an animation loops
  13255. * @returns the list of created animatables
  13256. */
  13257. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13258. /**
  13259. * Begin a new animation on a given node and its hierarchy
  13260. * @param target defines the root node where the animation will take place
  13261. * @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.
  13262. * @param animations defines the list of animations to start
  13263. * @param from defines the initial value
  13264. * @param to defines the final value
  13265. * @param loop defines if you want animation to loop (off by default)
  13266. * @param speedRatio defines the speed ratio to apply to all animations
  13267. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13268. * @param onAnimationLoop defines the callback to call when an animation loops
  13269. * @returns the list of animatables created for all nodes
  13270. */
  13271. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13272. /**
  13273. * Gets the animatable associated with a specific target
  13274. * @param target defines the target of the animatable
  13275. * @returns the required animatable if found
  13276. */
  13277. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13278. /**
  13279. * Gets all animatables associated with a given target
  13280. * @param target defines the target to look animatables for
  13281. * @returns an array of Animatables
  13282. */
  13283. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13284. /**
  13285. * Stops and removes all animations that have been applied to the scene
  13286. */
  13287. stopAllAnimations(): void;
  13288. }
  13289. }
  13290. module "babylonjs/Bones/bone" {
  13291. interface Bone {
  13292. /**
  13293. * Copy an animation range from another bone
  13294. * @param source defines the source bone
  13295. * @param rangeName defines the range name to copy
  13296. * @param frameOffset defines the frame offset
  13297. * @param rescaleAsRequired defines if rescaling must be applied if required
  13298. * @param skelDimensionsRatio defines the scaling ratio
  13299. * @returns true if operation was successful
  13300. */
  13301. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13302. }
  13303. }
  13304. }
  13305. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13306. /**
  13307. * Class used to override all child animations of a given target
  13308. */
  13309. export class AnimationPropertiesOverride {
  13310. /**
  13311. * Gets or sets a value indicating if animation blending must be used
  13312. */
  13313. enableBlending: boolean;
  13314. /**
  13315. * Gets or sets the blending speed to use when enableBlending is true
  13316. */
  13317. blendingSpeed: number;
  13318. /**
  13319. * Gets or sets the default loop mode to use
  13320. */
  13321. loopMode: number;
  13322. }
  13323. }
  13324. declare module "babylonjs/Bones/skeleton" {
  13325. import { Bone } from "babylonjs/Bones/bone";
  13326. import { Observable } from "babylonjs/Misc/observable";
  13327. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13328. import { Scene } from "babylonjs/scene";
  13329. import { Nullable } from "babylonjs/types";
  13330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13331. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13332. import { Animatable } from "babylonjs/Animations/animatable";
  13333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13334. import { Animation } from "babylonjs/Animations/animation";
  13335. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13336. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13337. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13338. /**
  13339. * Class used to handle skinning animations
  13340. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13341. */
  13342. export class Skeleton implements IAnimatable {
  13343. /** defines the skeleton name */
  13344. name: string;
  13345. /** defines the skeleton Id */
  13346. id: string;
  13347. /**
  13348. * Defines the list of child bones
  13349. */
  13350. bones: Bone[];
  13351. /**
  13352. * Defines an estimate of the dimension of the skeleton at rest
  13353. */
  13354. dimensionsAtRest: Vector3;
  13355. /**
  13356. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13357. */
  13358. needInitialSkinMatrix: boolean;
  13359. /**
  13360. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13361. */
  13362. overrideMesh: Nullable<AbstractMesh>;
  13363. /**
  13364. * Gets the list of animations attached to this skeleton
  13365. */
  13366. animations: Array<Animation>;
  13367. private _scene;
  13368. private _isDirty;
  13369. private _transformMatrices;
  13370. private _transformMatrixTexture;
  13371. private _meshesWithPoseMatrix;
  13372. private _animatables;
  13373. private _identity;
  13374. private _synchronizedWithMesh;
  13375. private _ranges;
  13376. private _lastAbsoluteTransformsUpdateId;
  13377. private _canUseTextureForBones;
  13378. private _uniqueId;
  13379. /** @hidden */
  13380. _numBonesWithLinkedTransformNode: number;
  13381. /** @hidden */
  13382. _hasWaitingData: Nullable<boolean>;
  13383. /**
  13384. * Specifies if the skeleton should be serialized
  13385. */
  13386. doNotSerialize: boolean;
  13387. private _useTextureToStoreBoneMatrices;
  13388. /**
  13389. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13390. * Please note that this option is not available if the hardware does not support it
  13391. */
  13392. useTextureToStoreBoneMatrices: boolean;
  13393. private _animationPropertiesOverride;
  13394. /**
  13395. * Gets or sets the animation properties override
  13396. */
  13397. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13398. /**
  13399. * List of inspectable custom properties (used by the Inspector)
  13400. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13401. */
  13402. inspectableCustomProperties: IInspectable[];
  13403. /**
  13404. * An observable triggered before computing the skeleton's matrices
  13405. */
  13406. onBeforeComputeObservable: Observable<Skeleton>;
  13407. /**
  13408. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13409. */
  13410. readonly isUsingTextureForMatrices: boolean;
  13411. /**
  13412. * Gets the unique ID of this skeleton
  13413. */
  13414. readonly uniqueId: number;
  13415. /**
  13416. * Creates a new skeleton
  13417. * @param name defines the skeleton name
  13418. * @param id defines the skeleton Id
  13419. * @param scene defines the hosting scene
  13420. */
  13421. constructor(
  13422. /** defines the skeleton name */
  13423. name: string,
  13424. /** defines the skeleton Id */
  13425. id: string, scene: Scene);
  13426. /**
  13427. * Gets the current object class name.
  13428. * @return the class name
  13429. */
  13430. getClassName(): string;
  13431. /**
  13432. * Returns an array containing the root bones
  13433. * @returns an array containing the root bones
  13434. */
  13435. getChildren(): Array<Bone>;
  13436. /**
  13437. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13438. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13439. * @returns a Float32Array containing matrices data
  13440. */
  13441. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13442. /**
  13443. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13444. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13445. * @returns a raw texture containing the data
  13446. */
  13447. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13448. /**
  13449. * Gets the current hosting scene
  13450. * @returns a scene object
  13451. */
  13452. getScene(): Scene;
  13453. /**
  13454. * Gets a string representing the current skeleton data
  13455. * @param fullDetails defines a boolean indicating if we want a verbose version
  13456. * @returns a string representing the current skeleton data
  13457. */
  13458. toString(fullDetails?: boolean): string;
  13459. /**
  13460. * Get bone's index searching by name
  13461. * @param name defines bone's name to search for
  13462. * @return the indice of the bone. Returns -1 if not found
  13463. */
  13464. getBoneIndexByName(name: string): number;
  13465. /**
  13466. * Creater a new animation range
  13467. * @param name defines the name of the range
  13468. * @param from defines the start key
  13469. * @param to defines the end key
  13470. */
  13471. createAnimationRange(name: string, from: number, to: number): void;
  13472. /**
  13473. * Delete a specific animation range
  13474. * @param name defines the name of the range
  13475. * @param deleteFrames defines if frames must be removed as well
  13476. */
  13477. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13478. /**
  13479. * Gets a specific animation range
  13480. * @param name defines the name of the range to look for
  13481. * @returns the requested animation range or null if not found
  13482. */
  13483. getAnimationRange(name: string): Nullable<AnimationRange>;
  13484. /**
  13485. * Gets the list of all animation ranges defined on this skeleton
  13486. * @returns an array
  13487. */
  13488. getAnimationRanges(): Nullable<AnimationRange>[];
  13489. /**
  13490. * Copy animation range from a source skeleton.
  13491. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13492. * @param source defines the source skeleton
  13493. * @param name defines the name of the range to copy
  13494. * @param rescaleAsRequired defines if rescaling must be applied if required
  13495. * @returns true if operation was successful
  13496. */
  13497. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13498. /**
  13499. * Forces the skeleton to go to rest pose
  13500. */
  13501. returnToRest(): void;
  13502. private _getHighestAnimationFrame;
  13503. /**
  13504. * Begin a specific animation range
  13505. * @param name defines the name of the range to start
  13506. * @param loop defines if looping must be turned on (false by default)
  13507. * @param speedRatio defines the speed ratio to apply (1 by default)
  13508. * @param onAnimationEnd defines a callback which will be called when animation will end
  13509. * @returns a new animatable
  13510. */
  13511. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13512. /** @hidden */
  13513. _markAsDirty(): void;
  13514. /** @hidden */
  13515. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13516. /** @hidden */
  13517. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13518. private _computeTransformMatrices;
  13519. /**
  13520. * Build all resources required to render a skeleton
  13521. */
  13522. prepare(): void;
  13523. /**
  13524. * Gets the list of animatables currently running for this skeleton
  13525. * @returns an array of animatables
  13526. */
  13527. getAnimatables(): IAnimatable[];
  13528. /**
  13529. * Clone the current skeleton
  13530. * @param name defines the name of the new skeleton
  13531. * @param id defines the id of the new skeleton
  13532. * @returns the new skeleton
  13533. */
  13534. clone(name: string, id: string): Skeleton;
  13535. /**
  13536. * Enable animation blending for this skeleton
  13537. * @param blendingSpeed defines the blending speed to apply
  13538. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13539. */
  13540. enableBlending(blendingSpeed?: number): void;
  13541. /**
  13542. * Releases all resources associated with the current skeleton
  13543. */
  13544. dispose(): void;
  13545. /**
  13546. * Serialize the skeleton in a JSON object
  13547. * @returns a JSON object
  13548. */
  13549. serialize(): any;
  13550. /**
  13551. * Creates a new skeleton from serialized data
  13552. * @param parsedSkeleton defines the serialized data
  13553. * @param scene defines the hosting scene
  13554. * @returns a new skeleton
  13555. */
  13556. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13557. /**
  13558. * Compute all node absolute transforms
  13559. * @param forceUpdate defines if computation must be done even if cache is up to date
  13560. */
  13561. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13562. /**
  13563. * Gets the root pose matrix
  13564. * @returns a matrix
  13565. */
  13566. getPoseMatrix(): Nullable<Matrix>;
  13567. /**
  13568. * Sorts bones per internal index
  13569. */
  13570. sortBones(): void;
  13571. private _sortBones;
  13572. }
  13573. }
  13574. declare module "babylonjs/Bones/bone" {
  13575. import { Skeleton } from "babylonjs/Bones/skeleton";
  13576. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13577. import { Nullable } from "babylonjs/types";
  13578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13579. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13580. import { Node } from "babylonjs/node";
  13581. import { Space } from "babylonjs/Maths/math.axis";
  13582. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13583. /**
  13584. * Class used to store bone information
  13585. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13586. */
  13587. export class Bone extends Node {
  13588. /**
  13589. * defines the bone name
  13590. */
  13591. name: string;
  13592. private static _tmpVecs;
  13593. private static _tmpQuat;
  13594. private static _tmpMats;
  13595. /**
  13596. * Gets the list of child bones
  13597. */
  13598. children: Bone[];
  13599. /** Gets the animations associated with this bone */
  13600. animations: import("babylonjs/Animations/animation").Animation[];
  13601. /**
  13602. * Gets or sets bone length
  13603. */
  13604. length: number;
  13605. /**
  13606. * @hidden Internal only
  13607. * Set this value to map this bone to a different index in the transform matrices
  13608. * Set this value to -1 to exclude the bone from the transform matrices
  13609. */
  13610. _index: Nullable<number>;
  13611. private _skeleton;
  13612. private _localMatrix;
  13613. private _restPose;
  13614. private _baseMatrix;
  13615. private _absoluteTransform;
  13616. private _invertedAbsoluteTransform;
  13617. private _parent;
  13618. private _scalingDeterminant;
  13619. private _worldTransform;
  13620. private _localScaling;
  13621. private _localRotation;
  13622. private _localPosition;
  13623. private _needToDecompose;
  13624. private _needToCompose;
  13625. /** @hidden */
  13626. _linkedTransformNode: Nullable<TransformNode>;
  13627. /** @hidden */
  13628. _waitingTransformNodeId: Nullable<string>;
  13629. /** @hidden */
  13630. /** @hidden */
  13631. _matrix: Matrix;
  13632. /**
  13633. * Create a new bone
  13634. * @param name defines the bone name
  13635. * @param skeleton defines the parent skeleton
  13636. * @param parentBone defines the parent (can be null if the bone is the root)
  13637. * @param localMatrix defines the local matrix
  13638. * @param restPose defines the rest pose matrix
  13639. * @param baseMatrix defines the base matrix
  13640. * @param index defines index of the bone in the hiearchy
  13641. */
  13642. constructor(
  13643. /**
  13644. * defines the bone name
  13645. */
  13646. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13647. /**
  13648. * Gets the current object class name.
  13649. * @return the class name
  13650. */
  13651. getClassName(): string;
  13652. /**
  13653. * Gets the parent skeleton
  13654. * @returns a skeleton
  13655. */
  13656. getSkeleton(): Skeleton;
  13657. /**
  13658. * Gets parent bone
  13659. * @returns a bone or null if the bone is the root of the bone hierarchy
  13660. */
  13661. getParent(): Nullable<Bone>;
  13662. /**
  13663. * Returns an array containing the root bones
  13664. * @returns an array containing the root bones
  13665. */
  13666. getChildren(): Array<Bone>;
  13667. /**
  13668. * Sets the parent bone
  13669. * @param parent defines the parent (can be null if the bone is the root)
  13670. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13671. */
  13672. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13673. /**
  13674. * Gets the local matrix
  13675. * @returns a matrix
  13676. */
  13677. getLocalMatrix(): Matrix;
  13678. /**
  13679. * Gets the base matrix (initial matrix which remains unchanged)
  13680. * @returns a matrix
  13681. */
  13682. getBaseMatrix(): Matrix;
  13683. /**
  13684. * Gets the rest pose matrix
  13685. * @returns a matrix
  13686. */
  13687. getRestPose(): Matrix;
  13688. /**
  13689. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13690. */
  13691. getWorldMatrix(): Matrix;
  13692. /**
  13693. * Sets the local matrix to rest pose matrix
  13694. */
  13695. returnToRest(): void;
  13696. /**
  13697. * Gets the inverse of the absolute transform matrix.
  13698. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13699. * @returns a matrix
  13700. */
  13701. getInvertedAbsoluteTransform(): Matrix;
  13702. /**
  13703. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13704. * @returns a matrix
  13705. */
  13706. getAbsoluteTransform(): Matrix;
  13707. /**
  13708. * Links with the given transform node.
  13709. * The local matrix of this bone is copied from the transform node every frame.
  13710. * @param transformNode defines the transform node to link to
  13711. */
  13712. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13713. /**
  13714. * Gets the node used to drive the bone's transformation
  13715. * @returns a transform node or null
  13716. */
  13717. getTransformNode(): Nullable<TransformNode>;
  13718. /** Gets or sets current position (in local space) */
  13719. position: Vector3;
  13720. /** Gets or sets current rotation (in local space) */
  13721. rotation: Vector3;
  13722. /** Gets or sets current rotation quaternion (in local space) */
  13723. rotationQuaternion: Quaternion;
  13724. /** Gets or sets current scaling (in local space) */
  13725. scaling: Vector3;
  13726. /**
  13727. * Gets the animation properties override
  13728. */
  13729. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13730. private _decompose;
  13731. private _compose;
  13732. /**
  13733. * Update the base and local matrices
  13734. * @param matrix defines the new base or local matrix
  13735. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13736. * @param updateLocalMatrix defines if the local matrix should be updated
  13737. */
  13738. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13739. /** @hidden */
  13740. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13741. /**
  13742. * Flag the bone as dirty (Forcing it to update everything)
  13743. */
  13744. markAsDirty(): void;
  13745. /** @hidden */
  13746. _markAsDirtyAndCompose(): void;
  13747. private _markAsDirtyAndDecompose;
  13748. /**
  13749. * Translate the bone in local or world space
  13750. * @param vec The amount to translate the bone
  13751. * @param space The space that the translation is in
  13752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13753. */
  13754. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13755. /**
  13756. * Set the postion of the bone in local or world space
  13757. * @param position The position to set the bone
  13758. * @param space The space that the position is in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Set the absolute position of the bone (world space)
  13764. * @param position The position to set the bone
  13765. * @param mesh The mesh that this bone is attached to
  13766. */
  13767. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13768. /**
  13769. * Scale the bone on the x, y and z axes (in local space)
  13770. * @param x The amount to scale the bone on the x axis
  13771. * @param y The amount to scale the bone on the y axis
  13772. * @param z The amount to scale the bone on the z axis
  13773. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13774. */
  13775. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13776. /**
  13777. * Set the bone scaling in local space
  13778. * @param scale defines the scaling vector
  13779. */
  13780. setScale(scale: Vector3): void;
  13781. /**
  13782. * Gets the current scaling in local space
  13783. * @returns the current scaling vector
  13784. */
  13785. getScale(): Vector3;
  13786. /**
  13787. * Gets the current scaling in local space and stores it in a target vector
  13788. * @param result defines the target vector
  13789. */
  13790. getScaleToRef(result: Vector3): void;
  13791. /**
  13792. * Set the yaw, pitch, and roll of the bone in local or world space
  13793. * @param yaw The rotation of the bone on the y axis
  13794. * @param pitch The rotation of the bone on the x axis
  13795. * @param roll The rotation of the bone on the z axis
  13796. * @param space The space that the axes of rotation are in
  13797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13798. */
  13799. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13800. /**
  13801. * Add a rotation to the bone on an axis in local or world space
  13802. * @param axis The axis to rotate the bone on
  13803. * @param amount The amount to rotate the bone
  13804. * @param space The space that the axis is in
  13805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13806. */
  13807. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13808. /**
  13809. * Set the rotation of the bone to a particular axis angle in local or world space
  13810. * @param axis The axis to rotate the bone on
  13811. * @param angle The angle that the bone should be rotated to
  13812. * @param space The space that the axis is in
  13813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13814. */
  13815. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13816. /**
  13817. * Set the euler rotation of the bone in local of world space
  13818. * @param rotation The euler rotation that the bone should be set to
  13819. * @param space The space that the rotation is in
  13820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13821. */
  13822. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13823. /**
  13824. * Set the quaternion rotation of the bone in local of world space
  13825. * @param quat The quaternion rotation that the bone should be set to
  13826. * @param space The space that the rotation is in
  13827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13828. */
  13829. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13830. /**
  13831. * Set the rotation matrix of the bone in local of world space
  13832. * @param rotMat The rotation matrix that the bone should be set to
  13833. * @param space The space that the rotation is in
  13834. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13835. */
  13836. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13837. private _rotateWithMatrix;
  13838. private _getNegativeRotationToRef;
  13839. /**
  13840. * Get the position of the bone in local or world space
  13841. * @param space The space that the returned position is in
  13842. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13843. * @returns The position of the bone
  13844. */
  13845. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13846. /**
  13847. * Copy the position of the bone to a vector3 in local or world space
  13848. * @param space The space that the returned position is in
  13849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13850. * @param result The vector3 to copy the position to
  13851. */
  13852. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13853. /**
  13854. * Get the absolute position of the bone (world space)
  13855. * @param mesh The mesh that this bone is attached to
  13856. * @returns The absolute position of the bone
  13857. */
  13858. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13859. /**
  13860. * Copy the absolute position of the bone (world space) to the result param
  13861. * @param mesh The mesh that this bone is attached to
  13862. * @param result The vector3 to copy the absolute position to
  13863. */
  13864. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13865. /**
  13866. * Compute the absolute transforms of this bone and its children
  13867. */
  13868. computeAbsoluteTransforms(): void;
  13869. /**
  13870. * Get the world direction from an axis that is in the local space of the bone
  13871. * @param localAxis The local direction that is used to compute the world direction
  13872. * @param mesh The mesh that this bone is attached to
  13873. * @returns The world direction
  13874. */
  13875. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13876. /**
  13877. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13878. * @param localAxis The local direction that is used to compute the world direction
  13879. * @param mesh The mesh that this bone is attached to
  13880. * @param result The vector3 that the world direction will be copied to
  13881. */
  13882. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13883. /**
  13884. * Get the euler rotation of the bone in local or world space
  13885. * @param space The space that the rotation should be in
  13886. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13887. * @returns The euler rotation
  13888. */
  13889. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13890. /**
  13891. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13892. * @param space The space that the rotation should be in
  13893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13894. * @param result The vector3 that the rotation should be copied to
  13895. */
  13896. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13897. /**
  13898. * Get the quaternion rotation of the bone in either local or world space
  13899. * @param space The space that the rotation should be in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. * @returns The quaternion rotation
  13902. */
  13903. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13904. /**
  13905. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13906. * @param space The space that the rotation should be in
  13907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13908. * @param result The quaternion that the rotation should be copied to
  13909. */
  13910. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13911. /**
  13912. * Get the rotation matrix of the bone in local or world space
  13913. * @param space The space that the rotation should be in
  13914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13915. * @returns The rotation matrix
  13916. */
  13917. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13918. /**
  13919. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13920. * @param space The space that the rotation should be in
  13921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13922. * @param result The quaternion that the rotation should be copied to
  13923. */
  13924. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13925. /**
  13926. * Get the world position of a point that is in the local space of the bone
  13927. * @param position The local position
  13928. * @param mesh The mesh that this bone is attached to
  13929. * @returns The world position
  13930. */
  13931. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13932. /**
  13933. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13934. * @param position The local position
  13935. * @param mesh The mesh that this bone is attached to
  13936. * @param result The vector3 that the world position should be copied to
  13937. */
  13938. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13939. /**
  13940. * Get the local position of a point that is in world space
  13941. * @param position The world position
  13942. * @param mesh The mesh that this bone is attached to
  13943. * @returns The local position
  13944. */
  13945. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13946. /**
  13947. * Get the local position of a point that is in world space and copy it to the result param
  13948. * @param position The world position
  13949. * @param mesh The mesh that this bone is attached to
  13950. * @param result The vector3 that the local position should be copied to
  13951. */
  13952. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13953. }
  13954. }
  13955. declare module "babylonjs/Meshes/transformNode" {
  13956. import { DeepImmutable } from "babylonjs/types";
  13957. import { Observable } from "babylonjs/Misc/observable";
  13958. import { Nullable } from "babylonjs/types";
  13959. import { Camera } from "babylonjs/Cameras/camera";
  13960. import { Scene } from "babylonjs/scene";
  13961. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13962. import { Node } from "babylonjs/node";
  13963. import { Bone } from "babylonjs/Bones/bone";
  13964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13965. import { Space } from "babylonjs/Maths/math.axis";
  13966. /**
  13967. * 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.
  13968. * @see https://doc.babylonjs.com/how_to/transformnode
  13969. */
  13970. export class TransformNode extends Node {
  13971. /**
  13972. * Object will not rotate to face the camera
  13973. */
  13974. static BILLBOARDMODE_NONE: number;
  13975. /**
  13976. * Object will rotate to face the camera but only on the x axis
  13977. */
  13978. static BILLBOARDMODE_X: number;
  13979. /**
  13980. * Object will rotate to face the camera but only on the y axis
  13981. */
  13982. static BILLBOARDMODE_Y: number;
  13983. /**
  13984. * Object will rotate to face the camera but only on the z axis
  13985. */
  13986. static BILLBOARDMODE_Z: number;
  13987. /**
  13988. * Object will rotate to face the camera
  13989. */
  13990. static BILLBOARDMODE_ALL: number;
  13991. /**
  13992. * Object will rotate to face the camera's position instead of orientation
  13993. */
  13994. static BILLBOARDMODE_USE_POSITION: number;
  13995. private _forward;
  13996. private _forwardInverted;
  13997. private _up;
  13998. private _right;
  13999. private _rightInverted;
  14000. private _position;
  14001. private _rotation;
  14002. private _rotationQuaternion;
  14003. protected _scaling: Vector3;
  14004. protected _isDirty: boolean;
  14005. private _transformToBoneReferal;
  14006. private _isAbsoluteSynced;
  14007. private _billboardMode;
  14008. /**
  14009. * Gets or sets the billboard mode. Default is 0.
  14010. *
  14011. * | Value | Type | Description |
  14012. * | --- | --- | --- |
  14013. * | 0 | BILLBOARDMODE_NONE | |
  14014. * | 1 | BILLBOARDMODE_X | |
  14015. * | 2 | BILLBOARDMODE_Y | |
  14016. * | 4 | BILLBOARDMODE_Z | |
  14017. * | 7 | BILLBOARDMODE_ALL | |
  14018. *
  14019. */
  14020. billboardMode: number;
  14021. private _preserveParentRotationForBillboard;
  14022. /**
  14023. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14024. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14025. */
  14026. preserveParentRotationForBillboard: boolean;
  14027. /**
  14028. * 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
  14029. */
  14030. scalingDeterminant: number;
  14031. private _infiniteDistance;
  14032. /**
  14033. * Gets or sets the distance of the object to max, often used by skybox
  14034. */
  14035. infiniteDistance: boolean;
  14036. /**
  14037. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14038. * By default the system will update normals to compensate
  14039. */
  14040. ignoreNonUniformScaling: boolean;
  14041. /**
  14042. * 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
  14043. */
  14044. reIntegrateRotationIntoRotationQuaternion: boolean;
  14045. /** @hidden */
  14046. _poseMatrix: Nullable<Matrix>;
  14047. /** @hidden */
  14048. _localMatrix: Matrix;
  14049. private _usePivotMatrix;
  14050. private _absolutePosition;
  14051. private _absoluteScaling;
  14052. private _absoluteRotationQuaternion;
  14053. private _pivotMatrix;
  14054. private _pivotMatrixInverse;
  14055. protected _postMultiplyPivotMatrix: boolean;
  14056. protected _isWorldMatrixFrozen: boolean;
  14057. /** @hidden */
  14058. _indexInSceneTransformNodesArray: number;
  14059. /**
  14060. * An event triggered after the world matrix is updated
  14061. */
  14062. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14063. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14064. /**
  14065. * Gets a string identifying the name of the class
  14066. * @returns "TransformNode" string
  14067. */
  14068. getClassName(): string;
  14069. /**
  14070. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14071. */
  14072. position: Vector3;
  14073. /**
  14074. * 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)).
  14075. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14076. */
  14077. rotation: Vector3;
  14078. /**
  14079. * 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)).
  14080. */
  14081. scaling: Vector3;
  14082. /**
  14083. * 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).
  14084. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14085. */
  14086. rotationQuaternion: Nullable<Quaternion>;
  14087. /**
  14088. * The forward direction of that transform in world space.
  14089. */
  14090. readonly forward: Vector3;
  14091. /**
  14092. * The up direction of that transform in world space.
  14093. */
  14094. readonly up: Vector3;
  14095. /**
  14096. * The right direction of that transform in world space.
  14097. */
  14098. readonly right: Vector3;
  14099. /**
  14100. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14101. * @param matrix the matrix to copy the pose from
  14102. * @returns this TransformNode.
  14103. */
  14104. updatePoseMatrix(matrix: Matrix): TransformNode;
  14105. /**
  14106. * Returns the mesh Pose matrix.
  14107. * @returns the pose matrix
  14108. */
  14109. getPoseMatrix(): Matrix;
  14110. /** @hidden */
  14111. _isSynchronized(): boolean;
  14112. /** @hidden */
  14113. _initCache(): void;
  14114. /**
  14115. * Flag the transform node as dirty (Forcing it to update everything)
  14116. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14117. * @returns this transform node
  14118. */
  14119. markAsDirty(property: string): TransformNode;
  14120. /**
  14121. * Returns the current mesh absolute position.
  14122. * Returns a Vector3.
  14123. */
  14124. readonly absolutePosition: Vector3;
  14125. /**
  14126. * Returns the current mesh absolute scaling.
  14127. * Returns a Vector3.
  14128. */
  14129. readonly absoluteScaling: Vector3;
  14130. /**
  14131. * Returns the current mesh absolute rotation.
  14132. * Returns a Quaternion.
  14133. */
  14134. readonly absoluteRotationQuaternion: Quaternion;
  14135. /**
  14136. * Sets a new matrix to apply before all other transformation
  14137. * @param matrix defines the transform matrix
  14138. * @returns the current TransformNode
  14139. */
  14140. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14141. /**
  14142. * Sets a new pivot matrix to the current node
  14143. * @param matrix defines the new pivot matrix to use
  14144. * @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
  14145. * @returns the current TransformNode
  14146. */
  14147. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14148. /**
  14149. * Returns the mesh pivot matrix.
  14150. * Default : Identity.
  14151. * @returns the matrix
  14152. */
  14153. getPivotMatrix(): Matrix;
  14154. /**
  14155. * Instantiate (when possible) or clone that node with its hierarchy
  14156. * @param newParent defines the new parent to use for the instance (or clone)
  14157. * @returns an instance (or a clone) of the current node with its hiearchy
  14158. */
  14159. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14160. /**
  14161. * Prevents the World matrix to be computed any longer
  14162. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14163. * @returns the TransformNode.
  14164. */
  14165. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14166. /**
  14167. * Allows back the World matrix computation.
  14168. * @returns the TransformNode.
  14169. */
  14170. unfreezeWorldMatrix(): this;
  14171. /**
  14172. * True if the World matrix has been frozen.
  14173. */
  14174. readonly isWorldMatrixFrozen: boolean;
  14175. /**
  14176. * Retuns the mesh absolute position in the World.
  14177. * @returns a Vector3.
  14178. */
  14179. getAbsolutePosition(): Vector3;
  14180. /**
  14181. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14182. * @param absolutePosition the absolute position to set
  14183. * @returns the TransformNode.
  14184. */
  14185. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14186. /**
  14187. * Sets the mesh position in its local space.
  14188. * @param vector3 the position to set in localspace
  14189. * @returns the TransformNode.
  14190. */
  14191. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14192. /**
  14193. * Returns the mesh position in the local space from the current World matrix values.
  14194. * @returns a new Vector3.
  14195. */
  14196. getPositionExpressedInLocalSpace(): Vector3;
  14197. /**
  14198. * Translates the mesh along the passed Vector3 in its local space.
  14199. * @param vector3 the distance to translate in localspace
  14200. * @returns the TransformNode.
  14201. */
  14202. locallyTranslate(vector3: Vector3): TransformNode;
  14203. private static _lookAtVectorCache;
  14204. /**
  14205. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14206. * @param targetPoint the position (must be in same space as current mesh) to look at
  14207. * @param yawCor optional yaw (y-axis) correction in radians
  14208. * @param pitchCor optional pitch (x-axis) correction in radians
  14209. * @param rollCor optional roll (z-axis) correction in radians
  14210. * @param space the choosen space of the target
  14211. * @returns the TransformNode.
  14212. */
  14213. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14214. /**
  14215. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14216. * This Vector3 is expressed in the World space.
  14217. * @param localAxis axis to rotate
  14218. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14219. */
  14220. getDirection(localAxis: Vector3): Vector3;
  14221. /**
  14222. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14223. * localAxis is expressed in the mesh local space.
  14224. * result is computed in the Wordl space from the mesh World matrix.
  14225. * @param localAxis axis to rotate
  14226. * @param result the resulting transformnode
  14227. * @returns this TransformNode.
  14228. */
  14229. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14230. /**
  14231. * Sets this transform node rotation to the given local axis.
  14232. * @param localAxis the axis in local space
  14233. * @param yawCor optional yaw (y-axis) correction in radians
  14234. * @param pitchCor optional pitch (x-axis) correction in radians
  14235. * @param rollCor optional roll (z-axis) correction in radians
  14236. * @returns this TransformNode
  14237. */
  14238. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14239. /**
  14240. * Sets a new pivot point to the current node
  14241. * @param point defines the new pivot point to use
  14242. * @param space defines if the point is in world or local space (local by default)
  14243. * @returns the current TransformNode
  14244. */
  14245. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14246. /**
  14247. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14248. * @returns the pivot point
  14249. */
  14250. getPivotPoint(): Vector3;
  14251. /**
  14252. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14253. * @param result the vector3 to store the result
  14254. * @returns this TransformNode.
  14255. */
  14256. getPivotPointToRef(result: Vector3): TransformNode;
  14257. /**
  14258. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14259. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14260. */
  14261. getAbsolutePivotPoint(): Vector3;
  14262. /**
  14263. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14264. * @param result vector3 to store the result
  14265. * @returns this TransformNode.
  14266. */
  14267. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14268. /**
  14269. * Defines the passed node as the parent of the current node.
  14270. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14271. * @see https://doc.babylonjs.com/how_to/parenting
  14272. * @param node the node ot set as the parent
  14273. * @returns this TransformNode.
  14274. */
  14275. setParent(node: Nullable<Node>): TransformNode;
  14276. private _nonUniformScaling;
  14277. /**
  14278. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14279. */
  14280. readonly nonUniformScaling: boolean;
  14281. /** @hidden */
  14282. _updateNonUniformScalingState(value: boolean): boolean;
  14283. /**
  14284. * Attach the current TransformNode to another TransformNode associated with a bone
  14285. * @param bone Bone affecting the TransformNode
  14286. * @param affectedTransformNode TransformNode associated with the bone
  14287. * @returns this object
  14288. */
  14289. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14290. /**
  14291. * Detach the transform node if its associated with a bone
  14292. * @returns this object
  14293. */
  14294. detachFromBone(): TransformNode;
  14295. private static _rotationAxisCache;
  14296. /**
  14297. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14298. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14299. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14300. * The passed axis is also normalized.
  14301. * @param axis the axis to rotate around
  14302. * @param amount the amount to rotate in radians
  14303. * @param space Space to rotate in (Default: local)
  14304. * @returns the TransformNode.
  14305. */
  14306. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14307. /**
  14308. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14309. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14310. * The passed axis is also normalized. .
  14311. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14312. * @param point the point to rotate around
  14313. * @param axis the axis to rotate around
  14314. * @param amount the amount to rotate in radians
  14315. * @returns the TransformNode
  14316. */
  14317. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14318. /**
  14319. * Translates the mesh along the axis vector for the passed distance in the given space.
  14320. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14321. * @param axis the axis to translate in
  14322. * @param distance the distance to translate
  14323. * @param space Space to rotate in (Default: local)
  14324. * @returns the TransformNode.
  14325. */
  14326. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14327. /**
  14328. * Adds a rotation step to the mesh current rotation.
  14329. * x, y, z are Euler angles expressed in radians.
  14330. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14331. * This means this rotation is made in the mesh local space only.
  14332. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14333. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14334. * ```javascript
  14335. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14336. * ```
  14337. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14338. * 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.
  14339. * @param x Rotation to add
  14340. * @param y Rotation to add
  14341. * @param z Rotation to add
  14342. * @returns the TransformNode.
  14343. */
  14344. addRotation(x: number, y: number, z: number): TransformNode;
  14345. /**
  14346. * @hidden
  14347. */
  14348. protected _getEffectiveParent(): Nullable<Node>;
  14349. /**
  14350. * Computes the world matrix of the node
  14351. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14352. * @returns the world matrix
  14353. */
  14354. computeWorldMatrix(force?: boolean): Matrix;
  14355. protected _afterComputeWorldMatrix(): void;
  14356. /**
  14357. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14358. * @param func callback function to add
  14359. *
  14360. * @returns the TransformNode.
  14361. */
  14362. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14363. /**
  14364. * Removes a registered callback function.
  14365. * @param func callback function to remove
  14366. * @returns the TransformNode.
  14367. */
  14368. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14369. /**
  14370. * Gets the position of the current mesh in camera space
  14371. * @param camera defines the camera to use
  14372. * @returns a position
  14373. */
  14374. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14375. /**
  14376. * Returns the distance from the mesh to the active camera
  14377. * @param camera defines the camera to use
  14378. * @returns the distance
  14379. */
  14380. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14381. /**
  14382. * Clone the current transform node
  14383. * @param name Name of the new clone
  14384. * @param newParent New parent for the clone
  14385. * @param doNotCloneChildren Do not clone children hierarchy
  14386. * @returns the new transform node
  14387. */
  14388. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14389. /**
  14390. * Serializes the objects information.
  14391. * @param currentSerializationObject defines the object to serialize in
  14392. * @returns the serialized object
  14393. */
  14394. serialize(currentSerializationObject?: any): any;
  14395. /**
  14396. * Returns a new TransformNode object parsed from the source provided.
  14397. * @param parsedTransformNode is the source.
  14398. * @param scene the scne the object belongs to
  14399. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14400. * @returns a new TransformNode object parsed from the source provided.
  14401. */
  14402. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14403. /**
  14404. * Get all child-transformNodes of this node
  14405. * @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
  14406. * @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
  14407. * @returns an array of TransformNode
  14408. */
  14409. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14410. /**
  14411. * Releases resources associated with this transform node.
  14412. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14413. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14414. */
  14415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14416. /**
  14417. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14418. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14419. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14420. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14421. * @returns the current mesh
  14422. */
  14423. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14424. private _syncAbsoluteScalingAndRotation;
  14425. }
  14426. }
  14427. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14428. import { Observable } from "babylonjs/Misc/observable";
  14429. import { Nullable } from "babylonjs/types";
  14430. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14433. import { Ray } from "babylonjs/Culling/ray";
  14434. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14435. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14436. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14437. /**
  14438. * Defines the types of pose enabled controllers that are supported
  14439. */
  14440. export enum PoseEnabledControllerType {
  14441. /**
  14442. * HTC Vive
  14443. */
  14444. VIVE = 0,
  14445. /**
  14446. * Oculus Rift
  14447. */
  14448. OCULUS = 1,
  14449. /**
  14450. * Windows mixed reality
  14451. */
  14452. WINDOWS = 2,
  14453. /**
  14454. * Samsung gear VR
  14455. */
  14456. GEAR_VR = 3,
  14457. /**
  14458. * Google Daydream
  14459. */
  14460. DAYDREAM = 4,
  14461. /**
  14462. * Generic
  14463. */
  14464. GENERIC = 5
  14465. }
  14466. /**
  14467. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14468. */
  14469. export interface MutableGamepadButton {
  14470. /**
  14471. * Value of the button/trigger
  14472. */
  14473. value: number;
  14474. /**
  14475. * If the button/trigger is currently touched
  14476. */
  14477. touched: boolean;
  14478. /**
  14479. * If the button/trigger is currently pressed
  14480. */
  14481. pressed: boolean;
  14482. }
  14483. /**
  14484. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14485. * @hidden
  14486. */
  14487. export interface ExtendedGamepadButton extends GamepadButton {
  14488. /**
  14489. * If the button/trigger is currently pressed
  14490. */
  14491. readonly pressed: boolean;
  14492. /**
  14493. * If the button/trigger is currently touched
  14494. */
  14495. readonly touched: boolean;
  14496. /**
  14497. * Value of the button/trigger
  14498. */
  14499. readonly value: number;
  14500. }
  14501. /** @hidden */
  14502. export interface _GamePadFactory {
  14503. /**
  14504. * Returns wether or not the current gamepad can be created for this type of controller.
  14505. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14506. * @returns true if it can be created, otherwise false
  14507. */
  14508. canCreate(gamepadInfo: any): boolean;
  14509. /**
  14510. * Creates a new instance of the Gamepad.
  14511. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14512. * @returns the new gamepad instance
  14513. */
  14514. create(gamepadInfo: any): Gamepad;
  14515. }
  14516. /**
  14517. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14518. */
  14519. export class PoseEnabledControllerHelper {
  14520. /** @hidden */
  14521. static _ControllerFactories: _GamePadFactory[];
  14522. /** @hidden */
  14523. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14524. /**
  14525. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14526. * @param vrGamepad the gamepad to initialized
  14527. * @returns a vr controller of the type the gamepad identified as
  14528. */
  14529. static InitiateController(vrGamepad: any): Gamepad;
  14530. }
  14531. /**
  14532. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14533. */
  14534. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14535. /**
  14536. * If the controller is used in a webXR session
  14537. */
  14538. isXR: boolean;
  14539. private _deviceRoomPosition;
  14540. private _deviceRoomRotationQuaternion;
  14541. /**
  14542. * The device position in babylon space
  14543. */
  14544. devicePosition: Vector3;
  14545. /**
  14546. * The device rotation in babylon space
  14547. */
  14548. deviceRotationQuaternion: Quaternion;
  14549. /**
  14550. * The scale factor of the device in babylon space
  14551. */
  14552. deviceScaleFactor: number;
  14553. /**
  14554. * (Likely devicePosition should be used instead) The device position in its room space
  14555. */
  14556. position: Vector3;
  14557. /**
  14558. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14559. */
  14560. rotationQuaternion: Quaternion;
  14561. /**
  14562. * The type of controller (Eg. Windows mixed reality)
  14563. */
  14564. controllerType: PoseEnabledControllerType;
  14565. protected _calculatedPosition: Vector3;
  14566. private _calculatedRotation;
  14567. /**
  14568. * The raw pose from the device
  14569. */
  14570. rawPose: DevicePose;
  14571. private _trackPosition;
  14572. private _maxRotationDistFromHeadset;
  14573. private _draggedRoomRotation;
  14574. /**
  14575. * @hidden
  14576. */
  14577. _disableTrackPosition(fixedPosition: Vector3): void;
  14578. /**
  14579. * Internal, the mesh attached to the controller
  14580. * @hidden
  14581. */
  14582. _mesh: Nullable<AbstractMesh>;
  14583. private _poseControlledCamera;
  14584. private _leftHandSystemQuaternion;
  14585. /**
  14586. * Internal, matrix used to convert room space to babylon space
  14587. * @hidden
  14588. */
  14589. _deviceToWorld: Matrix;
  14590. /**
  14591. * Node to be used when casting a ray from the controller
  14592. * @hidden
  14593. */
  14594. _pointingPoseNode: Nullable<TransformNode>;
  14595. /**
  14596. * Name of the child mesh that can be used to cast a ray from the controller
  14597. */
  14598. static readonly POINTING_POSE: string;
  14599. /**
  14600. * Creates a new PoseEnabledController from a gamepad
  14601. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14602. */
  14603. constructor(browserGamepad: any);
  14604. private _workingMatrix;
  14605. /**
  14606. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14607. */
  14608. update(): void;
  14609. /**
  14610. * Updates only the pose device and mesh without doing any button event checking
  14611. */
  14612. protected _updatePoseAndMesh(): void;
  14613. /**
  14614. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14615. * @param poseData raw pose fromthe device
  14616. */
  14617. updateFromDevice(poseData: DevicePose): void;
  14618. /**
  14619. * @hidden
  14620. */
  14621. _meshAttachedObservable: Observable<AbstractMesh>;
  14622. /**
  14623. * Attaches a mesh to the controller
  14624. * @param mesh the mesh to be attached
  14625. */
  14626. attachToMesh(mesh: AbstractMesh): void;
  14627. /**
  14628. * Attaches the controllers mesh to a camera
  14629. * @param camera the camera the mesh should be attached to
  14630. */
  14631. attachToPoseControlledCamera(camera: TargetCamera): void;
  14632. /**
  14633. * Disposes of the controller
  14634. */
  14635. dispose(): void;
  14636. /**
  14637. * The mesh that is attached to the controller
  14638. */
  14639. readonly mesh: Nullable<AbstractMesh>;
  14640. /**
  14641. * Gets the ray of the controller in the direction the controller is pointing
  14642. * @param length the length the resulting ray should be
  14643. * @returns a ray in the direction the controller is pointing
  14644. */
  14645. getForwardRay(length?: number): Ray;
  14646. }
  14647. }
  14648. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14649. import { Observable } from "babylonjs/Misc/observable";
  14650. import { Scene } from "babylonjs/scene";
  14651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14652. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14653. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14654. /**
  14655. * Defines the WebVRController object that represents controllers tracked in 3D space
  14656. */
  14657. export abstract class WebVRController extends PoseEnabledController {
  14658. /**
  14659. * Internal, the default controller model for the controller
  14660. */
  14661. protected _defaultModel: AbstractMesh;
  14662. /**
  14663. * Fired when the trigger state has changed
  14664. */
  14665. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14666. /**
  14667. * Fired when the main button state has changed
  14668. */
  14669. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14670. /**
  14671. * Fired when the secondary button state has changed
  14672. */
  14673. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14674. /**
  14675. * Fired when the pad state has changed
  14676. */
  14677. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14678. /**
  14679. * Fired when controllers stick values have changed
  14680. */
  14681. onPadValuesChangedObservable: Observable<StickValues>;
  14682. /**
  14683. * Array of button availible on the controller
  14684. */
  14685. protected _buttons: Array<MutableGamepadButton>;
  14686. private _onButtonStateChange;
  14687. /**
  14688. * Fired when a controller button's state has changed
  14689. * @param callback the callback containing the button that was modified
  14690. */
  14691. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14692. /**
  14693. * X and Y axis corresponding to the controllers joystick
  14694. */
  14695. pad: StickValues;
  14696. /**
  14697. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14698. */
  14699. hand: string;
  14700. /**
  14701. * The default controller model for the controller
  14702. */
  14703. readonly defaultModel: AbstractMesh;
  14704. /**
  14705. * Creates a new WebVRController from a gamepad
  14706. * @param vrGamepad the gamepad that the WebVRController should be created from
  14707. */
  14708. constructor(vrGamepad: any);
  14709. /**
  14710. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14711. */
  14712. update(): void;
  14713. /**
  14714. * Function to be called when a button is modified
  14715. */
  14716. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14717. /**
  14718. * Loads a mesh and attaches it to the controller
  14719. * @param scene the scene the mesh should be added to
  14720. * @param meshLoaded callback for when the mesh has been loaded
  14721. */
  14722. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14723. private _setButtonValue;
  14724. private _changes;
  14725. private _checkChanges;
  14726. /**
  14727. * Disposes of th webVRCOntroller
  14728. */
  14729. dispose(): void;
  14730. }
  14731. }
  14732. declare module "babylonjs/Lights/hemisphericLight" {
  14733. import { Nullable } from "babylonjs/types";
  14734. import { Scene } from "babylonjs/scene";
  14735. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14736. import { Color3 } from "babylonjs/Maths/math.color";
  14737. import { Effect } from "babylonjs/Materials/effect";
  14738. import { Light } from "babylonjs/Lights/light";
  14739. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14740. /**
  14741. * The HemisphericLight simulates the ambient environment light,
  14742. * so the passed direction is the light reflection direction, not the incoming direction.
  14743. */
  14744. export class HemisphericLight extends Light {
  14745. /**
  14746. * The groundColor is the light in the opposite direction to the one specified during creation.
  14747. * 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.
  14748. */
  14749. groundColor: Color3;
  14750. /**
  14751. * The light reflection direction, not the incoming direction.
  14752. */
  14753. direction: Vector3;
  14754. /**
  14755. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14756. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14757. * The HemisphericLight can't cast shadows.
  14758. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14759. * @param name The friendly name of the light
  14760. * @param direction The direction of the light reflection
  14761. * @param scene The scene the light belongs to
  14762. */
  14763. constructor(name: string, direction: Vector3, scene: Scene);
  14764. protected _buildUniformLayout(): void;
  14765. /**
  14766. * Returns the string "HemisphericLight".
  14767. * @return The class name
  14768. */
  14769. getClassName(): string;
  14770. /**
  14771. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14772. * Returns the updated direction.
  14773. * @param target The target the direction should point to
  14774. * @return The computed direction
  14775. */
  14776. setDirectionToTarget(target: Vector3): Vector3;
  14777. /**
  14778. * Returns the shadow generator associated to the light.
  14779. * @returns Always null for hemispheric lights because it does not support shadows.
  14780. */
  14781. getShadowGenerator(): Nullable<IShadowGenerator>;
  14782. /**
  14783. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14784. * @param effect The effect to update
  14785. * @param lightIndex The index of the light in the effect to update
  14786. * @returns The hemispheric light
  14787. */
  14788. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14789. /**
  14790. * Computes the world matrix of the node
  14791. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14792. * @param useWasUpdatedFlag defines a reserved property
  14793. * @returns the world matrix
  14794. */
  14795. computeWorldMatrix(): Matrix;
  14796. /**
  14797. * Returns the integer 3.
  14798. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14799. */
  14800. getTypeID(): number;
  14801. /**
  14802. * Prepares the list of defines specific to the light type.
  14803. * @param defines the list of defines
  14804. * @param lightIndex defines the index of the light for the effect
  14805. */
  14806. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14807. }
  14808. }
  14809. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14810. /** @hidden */
  14811. export var vrMultiviewToSingleviewPixelShader: {
  14812. name: string;
  14813. shader: string;
  14814. };
  14815. }
  14816. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14817. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14818. import { Scene } from "babylonjs/scene";
  14819. /**
  14820. * Renders to multiple views with a single draw call
  14821. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14822. */
  14823. export class MultiviewRenderTarget extends RenderTargetTexture {
  14824. /**
  14825. * Creates a multiview render target
  14826. * @param scene scene used with the render target
  14827. * @param size the size of the render target (used for each view)
  14828. */
  14829. constructor(scene: Scene, size?: number | {
  14830. width: number;
  14831. height: number;
  14832. } | {
  14833. ratio: number;
  14834. });
  14835. /**
  14836. * @hidden
  14837. * @param faceIndex the face index, if its a cube texture
  14838. */
  14839. _bindFrameBuffer(faceIndex?: number): void;
  14840. /**
  14841. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14842. * @returns the view count
  14843. */
  14844. getViewCount(): number;
  14845. }
  14846. }
  14847. declare module "babylonjs/Maths/math.frustum" {
  14848. import { Matrix } from "babylonjs/Maths/math.vector";
  14849. import { DeepImmutable } from "babylonjs/types";
  14850. import { Plane } from "babylonjs/Maths/math.plane";
  14851. /**
  14852. * Reprasents a camera frustum
  14853. */
  14854. export class Frustum {
  14855. /**
  14856. * Gets the planes representing the frustum
  14857. * @param transform matrix to be applied to the returned planes
  14858. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14859. */
  14860. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14861. /**
  14862. * Gets the near frustum plane transformed by the transform matrix
  14863. * @param transform transformation matrix to be applied to the resulting frustum plane
  14864. * @param frustumPlane the resuling frustum plane
  14865. */
  14866. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14867. /**
  14868. * Gets the far frustum plane transformed by the transform matrix
  14869. * @param transform transformation matrix to be applied to the resulting frustum plane
  14870. * @param frustumPlane the resuling frustum plane
  14871. */
  14872. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14873. /**
  14874. * Gets the left frustum plane transformed by the transform matrix
  14875. * @param transform transformation matrix to be applied to the resulting frustum plane
  14876. * @param frustumPlane the resuling frustum plane
  14877. */
  14878. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14879. /**
  14880. * Gets the right frustum plane transformed by the transform matrix
  14881. * @param transform transformation matrix to be applied to the resulting frustum plane
  14882. * @param frustumPlane the resuling frustum plane
  14883. */
  14884. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14885. /**
  14886. * Gets the top frustum plane transformed by the transform matrix
  14887. * @param transform transformation matrix to be applied to the resulting frustum plane
  14888. * @param frustumPlane the resuling frustum plane
  14889. */
  14890. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14891. /**
  14892. * Gets the bottom frustum plane transformed by the transform matrix
  14893. * @param transform transformation matrix to be applied to the resulting frustum plane
  14894. * @param frustumPlane the resuling frustum plane
  14895. */
  14896. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14897. /**
  14898. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14899. * @param transform transformation matrix to be applied to the resulting frustum planes
  14900. * @param frustumPlanes the resuling frustum planes
  14901. */
  14902. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14903. }
  14904. }
  14905. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14906. import { Camera } from "babylonjs/Cameras/camera";
  14907. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14908. import { Nullable } from "babylonjs/types";
  14909. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14910. import { Matrix } from "babylonjs/Maths/math.vector";
  14911. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14912. module "babylonjs/Engines/engine" {
  14913. interface Engine {
  14914. /**
  14915. * Creates a new multiview render target
  14916. * @param width defines the width of the texture
  14917. * @param height defines the height of the texture
  14918. * @returns the created multiview texture
  14919. */
  14920. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14921. /**
  14922. * Binds a multiview framebuffer to be drawn to
  14923. * @param multiviewTexture texture to bind
  14924. */
  14925. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14926. }
  14927. }
  14928. module "babylonjs/Cameras/camera" {
  14929. interface Camera {
  14930. /**
  14931. * @hidden
  14932. * 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)
  14933. */
  14934. _useMultiviewToSingleView: boolean;
  14935. /**
  14936. * @hidden
  14937. * 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)
  14938. */
  14939. _multiviewTexture: Nullable<RenderTargetTexture>;
  14940. /**
  14941. * @hidden
  14942. * ensures the multiview texture of the camera exists and has the specified width/height
  14943. * @param width height to set on the multiview texture
  14944. * @param height width to set on the multiview texture
  14945. */
  14946. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14947. }
  14948. }
  14949. module "babylonjs/scene" {
  14950. interface Scene {
  14951. /** @hidden */
  14952. _transformMatrixR: Matrix;
  14953. /** @hidden */
  14954. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14955. /** @hidden */
  14956. _createMultiviewUbo(): void;
  14957. /** @hidden */
  14958. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14959. /** @hidden */
  14960. _renderMultiviewToSingleView(camera: Camera): void;
  14961. }
  14962. }
  14963. }
  14964. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14965. import { Camera } from "babylonjs/Cameras/camera";
  14966. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14967. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14968. import "babylonjs/Engines/Extensions/engine.multiview";
  14969. /**
  14970. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14971. * This will not be used for webXR as it supports displaying texture arrays directly
  14972. */
  14973. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14974. /**
  14975. * Initializes a VRMultiviewToSingleview
  14976. * @param name name of the post process
  14977. * @param camera camera to be applied to
  14978. * @param scaleFactor scaling factor to the size of the output texture
  14979. */
  14980. constructor(name: string, camera: Camera, scaleFactor: number);
  14981. }
  14982. }
  14983. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14984. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14985. import { Nullable } from "babylonjs/types";
  14986. import { Size } from "babylonjs/Maths/math.size";
  14987. import { Observable } from "babylonjs/Misc/observable";
  14988. module "babylonjs/Engines/engine" {
  14989. interface Engine {
  14990. /** @hidden */
  14991. _vrDisplay: any;
  14992. /** @hidden */
  14993. _vrSupported: boolean;
  14994. /** @hidden */
  14995. _oldSize: Size;
  14996. /** @hidden */
  14997. _oldHardwareScaleFactor: number;
  14998. /** @hidden */
  14999. _vrExclusivePointerMode: boolean;
  15000. /** @hidden */
  15001. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15002. /** @hidden */
  15003. _onVRDisplayPointerRestricted: () => void;
  15004. /** @hidden */
  15005. _onVRDisplayPointerUnrestricted: () => void;
  15006. /** @hidden */
  15007. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15008. /** @hidden */
  15009. _onVrDisplayDisconnect: Nullable<() => void>;
  15010. /** @hidden */
  15011. _onVrDisplayPresentChange: Nullable<() => void>;
  15012. /**
  15013. * Observable signaled when VR display mode changes
  15014. */
  15015. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15016. /**
  15017. * Observable signaled when VR request present is complete
  15018. */
  15019. onVRRequestPresentComplete: Observable<boolean>;
  15020. /**
  15021. * Observable signaled when VR request present starts
  15022. */
  15023. onVRRequestPresentStart: Observable<Engine>;
  15024. /**
  15025. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15026. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15027. */
  15028. isInVRExclusivePointerMode: boolean;
  15029. /**
  15030. * Gets a boolean indicating if a webVR device was detected
  15031. * @returns true if a webVR device was detected
  15032. */
  15033. isVRDevicePresent(): boolean;
  15034. /**
  15035. * Gets the current webVR device
  15036. * @returns the current webVR device (or null)
  15037. */
  15038. getVRDevice(): any;
  15039. /**
  15040. * Initializes a webVR display and starts listening to display change events
  15041. * The onVRDisplayChangedObservable will be notified upon these changes
  15042. * @returns A promise containing a VRDisplay and if vr is supported
  15043. */
  15044. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15045. /** @hidden */
  15046. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15047. /**
  15048. * Call this function to switch to webVR mode
  15049. * Will do nothing if webVR is not supported or if there is no webVR device
  15050. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15051. */
  15052. enableVR(): void;
  15053. /** @hidden */
  15054. _onVRFullScreenTriggered(): void;
  15055. }
  15056. }
  15057. }
  15058. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15059. import { Nullable } from "babylonjs/types";
  15060. import { Observable } from "babylonjs/Misc/observable";
  15061. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15062. import { Scene } from "babylonjs/scene";
  15063. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15064. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15065. import { Node } from "babylonjs/node";
  15066. import { Ray } from "babylonjs/Culling/ray";
  15067. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15068. import "babylonjs/Engines/Extensions/engine.webVR";
  15069. /**
  15070. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15071. * IMPORTANT!! The data is right-hand data.
  15072. * @export
  15073. * @interface DevicePose
  15074. */
  15075. export interface DevicePose {
  15076. /**
  15077. * The position of the device, values in array are [x,y,z].
  15078. */
  15079. readonly position: Nullable<Float32Array>;
  15080. /**
  15081. * The linearVelocity of the device, values in array are [x,y,z].
  15082. */
  15083. readonly linearVelocity: Nullable<Float32Array>;
  15084. /**
  15085. * The linearAcceleration of the device, values in array are [x,y,z].
  15086. */
  15087. readonly linearAcceleration: Nullable<Float32Array>;
  15088. /**
  15089. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15090. */
  15091. readonly orientation: Nullable<Float32Array>;
  15092. /**
  15093. * The angularVelocity of the device, values in array are [x,y,z].
  15094. */
  15095. readonly angularVelocity: Nullable<Float32Array>;
  15096. /**
  15097. * The angularAcceleration of the device, values in array are [x,y,z].
  15098. */
  15099. readonly angularAcceleration: Nullable<Float32Array>;
  15100. }
  15101. /**
  15102. * Interface representing a pose controlled object in Babylon.
  15103. * A pose controlled object has both regular pose values as well as pose values
  15104. * from an external device such as a VR head mounted display
  15105. */
  15106. export interface PoseControlled {
  15107. /**
  15108. * The position of the object in babylon space.
  15109. */
  15110. position: Vector3;
  15111. /**
  15112. * The rotation quaternion of the object in babylon space.
  15113. */
  15114. rotationQuaternion: Quaternion;
  15115. /**
  15116. * The position of the device in babylon space.
  15117. */
  15118. devicePosition?: Vector3;
  15119. /**
  15120. * The rotation quaternion of the device in babylon space.
  15121. */
  15122. deviceRotationQuaternion: Quaternion;
  15123. /**
  15124. * The raw pose coming from the device.
  15125. */
  15126. rawPose: Nullable<DevicePose>;
  15127. /**
  15128. * The scale of the device to be used when translating from device space to babylon space.
  15129. */
  15130. deviceScaleFactor: number;
  15131. /**
  15132. * Updates the poseControlled values based on the input device pose.
  15133. * @param poseData the pose data to update the object with
  15134. */
  15135. updateFromDevice(poseData: DevicePose): void;
  15136. }
  15137. /**
  15138. * Set of options to customize the webVRCamera
  15139. */
  15140. export interface WebVROptions {
  15141. /**
  15142. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15143. */
  15144. trackPosition?: boolean;
  15145. /**
  15146. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15147. */
  15148. positionScale?: number;
  15149. /**
  15150. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15151. */
  15152. displayName?: string;
  15153. /**
  15154. * Should the native controller meshes be initialized. (default: true)
  15155. */
  15156. controllerMeshes?: boolean;
  15157. /**
  15158. * Creating a default HemiLight only on controllers. (default: true)
  15159. */
  15160. defaultLightingOnControllers?: boolean;
  15161. /**
  15162. * If you don't want to use the default VR button of the helper. (default: false)
  15163. */
  15164. useCustomVRButton?: boolean;
  15165. /**
  15166. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15167. */
  15168. customVRButton?: HTMLButtonElement;
  15169. /**
  15170. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15171. */
  15172. rayLength?: number;
  15173. /**
  15174. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15175. */
  15176. defaultHeight?: number;
  15177. /**
  15178. * If multiview should be used if availible (default: false)
  15179. */
  15180. useMultiview?: boolean;
  15181. }
  15182. /**
  15183. * This represents a WebVR camera.
  15184. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15185. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15186. */
  15187. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15188. private webVROptions;
  15189. /**
  15190. * @hidden
  15191. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15192. */
  15193. _vrDevice: any;
  15194. /**
  15195. * The rawPose of the vrDevice.
  15196. */
  15197. rawPose: Nullable<DevicePose>;
  15198. private _onVREnabled;
  15199. private _specsVersion;
  15200. private _attached;
  15201. private _frameData;
  15202. protected _descendants: Array<Node>;
  15203. private _deviceRoomPosition;
  15204. /** @hidden */
  15205. _deviceRoomRotationQuaternion: Quaternion;
  15206. private _standingMatrix;
  15207. /**
  15208. * Represents device position in babylon space.
  15209. */
  15210. devicePosition: Vector3;
  15211. /**
  15212. * Represents device rotation in babylon space.
  15213. */
  15214. deviceRotationQuaternion: Quaternion;
  15215. /**
  15216. * The scale of the device to be used when translating from device space to babylon space.
  15217. */
  15218. deviceScaleFactor: number;
  15219. private _deviceToWorld;
  15220. private _worldToDevice;
  15221. /**
  15222. * References to the webVR controllers for the vrDevice.
  15223. */
  15224. controllers: Array<WebVRController>;
  15225. /**
  15226. * Emits an event when a controller is attached.
  15227. */
  15228. onControllersAttachedObservable: Observable<WebVRController[]>;
  15229. /**
  15230. * Emits an event when a controller's mesh has been loaded;
  15231. */
  15232. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15233. /**
  15234. * Emits an event when the HMD's pose has been updated.
  15235. */
  15236. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15237. private _poseSet;
  15238. /**
  15239. * If the rig cameras be used as parent instead of this camera.
  15240. */
  15241. rigParenting: boolean;
  15242. private _lightOnControllers;
  15243. private _defaultHeight?;
  15244. /**
  15245. * Instantiates a WebVRFreeCamera.
  15246. * @param name The name of the WebVRFreeCamera
  15247. * @param position The starting anchor position for the camera
  15248. * @param scene The scene the camera belongs to
  15249. * @param webVROptions a set of customizable options for the webVRCamera
  15250. */
  15251. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15252. /**
  15253. * Gets the device distance from the ground in meters.
  15254. * @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.
  15255. */
  15256. deviceDistanceToRoomGround(): number;
  15257. /**
  15258. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15259. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15260. */
  15261. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15262. /**
  15263. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15264. * @returns A promise with a boolean set to if the standing matrix is supported.
  15265. */
  15266. useStandingMatrixAsync(): Promise<boolean>;
  15267. /**
  15268. * Disposes the camera
  15269. */
  15270. dispose(): void;
  15271. /**
  15272. * Gets a vrController by name.
  15273. * @param name The name of the controller to retreive
  15274. * @returns the controller matching the name specified or null if not found
  15275. */
  15276. getControllerByName(name: string): Nullable<WebVRController>;
  15277. private _leftController;
  15278. /**
  15279. * The controller corresponding to the users left hand.
  15280. */
  15281. readonly leftController: Nullable<WebVRController>;
  15282. private _rightController;
  15283. /**
  15284. * The controller corresponding to the users right hand.
  15285. */
  15286. readonly rightController: Nullable<WebVRController>;
  15287. /**
  15288. * Casts a ray forward from the vrCamera's gaze.
  15289. * @param length Length of the ray (default: 100)
  15290. * @returns the ray corresponding to the gaze
  15291. */
  15292. getForwardRay(length?: number): Ray;
  15293. /**
  15294. * @hidden
  15295. * Updates the camera based on device's frame data
  15296. */
  15297. _checkInputs(): void;
  15298. /**
  15299. * Updates the poseControlled values based on the input device pose.
  15300. * @param poseData Pose coming from the device
  15301. */
  15302. updateFromDevice(poseData: DevicePose): void;
  15303. private _htmlElementAttached;
  15304. private _detachIfAttached;
  15305. /**
  15306. * WebVR's attach control will start broadcasting frames to the device.
  15307. * Note that in certain browsers (chrome for example) this function must be called
  15308. * within a user-interaction callback. Example:
  15309. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15310. *
  15311. * @param element html element to attach the vrDevice to
  15312. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15313. */
  15314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15315. /**
  15316. * Detaches the camera from the html element and disables VR
  15317. *
  15318. * @param element html element to detach from
  15319. */
  15320. detachControl(element: HTMLElement): void;
  15321. /**
  15322. * @returns the name of this class
  15323. */
  15324. getClassName(): string;
  15325. /**
  15326. * Calls resetPose on the vrDisplay
  15327. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15328. */
  15329. resetToCurrentRotation(): void;
  15330. /**
  15331. * @hidden
  15332. * Updates the rig cameras (left and right eye)
  15333. */
  15334. _updateRigCameras(): void;
  15335. private _workingVector;
  15336. private _oneVector;
  15337. private _workingMatrix;
  15338. private updateCacheCalled;
  15339. private _correctPositionIfNotTrackPosition;
  15340. /**
  15341. * @hidden
  15342. * Updates the cached values of the camera
  15343. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15344. */
  15345. _updateCache(ignoreParentClass?: boolean): void;
  15346. /**
  15347. * @hidden
  15348. * Get current device position in babylon world
  15349. */
  15350. _computeDevicePosition(): void;
  15351. /**
  15352. * Updates the current device position and rotation in the babylon world
  15353. */
  15354. update(): void;
  15355. /**
  15356. * @hidden
  15357. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15358. * @returns an identity matrix
  15359. */
  15360. _getViewMatrix(): Matrix;
  15361. private _tmpMatrix;
  15362. /**
  15363. * This function is called by the two RIG cameras.
  15364. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15365. * @hidden
  15366. */
  15367. _getWebVRViewMatrix(): Matrix;
  15368. /** @hidden */
  15369. _getWebVRProjectionMatrix(): Matrix;
  15370. private _onGamepadConnectedObserver;
  15371. private _onGamepadDisconnectedObserver;
  15372. private _updateCacheWhenTrackingDisabledObserver;
  15373. /**
  15374. * Initializes the controllers and their meshes
  15375. */
  15376. initControllers(): void;
  15377. }
  15378. }
  15379. declare module "babylonjs/PostProcesses/postProcess" {
  15380. import { Nullable } from "babylonjs/types";
  15381. import { SmartArray } from "babylonjs/Misc/smartArray";
  15382. import { Observable } from "babylonjs/Misc/observable";
  15383. import { Vector2 } from "babylonjs/Maths/math.vector";
  15384. import { Camera } from "babylonjs/Cameras/camera";
  15385. import { Effect } from "babylonjs/Materials/effect";
  15386. import "babylonjs/Shaders/postprocess.vertex";
  15387. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15388. import { Engine } from "babylonjs/Engines/engine";
  15389. import { Color4 } from "babylonjs/Maths/math.color";
  15390. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15391. /**
  15392. * Size options for a post process
  15393. */
  15394. export type PostProcessOptions = {
  15395. width: number;
  15396. height: number;
  15397. };
  15398. /**
  15399. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15400. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15401. */
  15402. export class PostProcess {
  15403. /** Name of the PostProcess. */
  15404. name: string;
  15405. /**
  15406. * Gets or sets the unique id of the post process
  15407. */
  15408. uniqueId: number;
  15409. /**
  15410. * Width of the texture to apply the post process on
  15411. */
  15412. width: number;
  15413. /**
  15414. * Height of the texture to apply the post process on
  15415. */
  15416. height: number;
  15417. /**
  15418. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15419. * @hidden
  15420. */
  15421. _outputTexture: Nullable<InternalTexture>;
  15422. /**
  15423. * Sampling mode used by the shader
  15424. * See https://doc.babylonjs.com/classes/3.1/texture
  15425. */
  15426. renderTargetSamplingMode: number;
  15427. /**
  15428. * Clear color to use when screen clearing
  15429. */
  15430. clearColor: Color4;
  15431. /**
  15432. * If the buffer needs to be cleared before applying the post process. (default: true)
  15433. * Should be set to false if shader will overwrite all previous pixels.
  15434. */
  15435. autoClear: boolean;
  15436. /**
  15437. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15438. */
  15439. alphaMode: number;
  15440. /**
  15441. * Sets the setAlphaBlendConstants of the babylon engine
  15442. */
  15443. alphaConstants: Color4;
  15444. /**
  15445. * Animations to be used for the post processing
  15446. */
  15447. animations: import("babylonjs/Animations/animation").Animation[];
  15448. /**
  15449. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15450. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15451. */
  15452. enablePixelPerfectMode: boolean;
  15453. /**
  15454. * Force the postprocess to be applied without taking in account viewport
  15455. */
  15456. forceFullscreenViewport: boolean;
  15457. /**
  15458. * List of inspectable custom properties (used by the Inspector)
  15459. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15460. */
  15461. inspectableCustomProperties: IInspectable[];
  15462. /**
  15463. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15464. *
  15465. * | Value | Type | Description |
  15466. * | ----- | ----------------------------------- | ----------- |
  15467. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15468. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15469. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15470. *
  15471. */
  15472. scaleMode: number;
  15473. /**
  15474. * Force textures to be a power of two (default: false)
  15475. */
  15476. alwaysForcePOT: boolean;
  15477. private _samples;
  15478. /**
  15479. * Number of sample textures (default: 1)
  15480. */
  15481. samples: number;
  15482. /**
  15483. * Modify the scale of the post process to be the same as the viewport (default: false)
  15484. */
  15485. adaptScaleToCurrentViewport: boolean;
  15486. private _camera;
  15487. private _scene;
  15488. private _engine;
  15489. private _options;
  15490. private _reusable;
  15491. private _textureType;
  15492. /**
  15493. * Smart array of input and output textures for the post process.
  15494. * @hidden
  15495. */
  15496. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15497. /**
  15498. * The index in _textures that corresponds to the output texture.
  15499. * @hidden
  15500. */
  15501. _currentRenderTextureInd: number;
  15502. private _effect;
  15503. private _samplers;
  15504. private _fragmentUrl;
  15505. private _vertexUrl;
  15506. private _parameters;
  15507. private _scaleRatio;
  15508. protected _indexParameters: any;
  15509. private _shareOutputWithPostProcess;
  15510. private _texelSize;
  15511. private _forcedOutputTexture;
  15512. /**
  15513. * Returns the fragment url or shader name used in the post process.
  15514. * @returns the fragment url or name in the shader store.
  15515. */
  15516. getEffectName(): string;
  15517. /**
  15518. * An event triggered when the postprocess is activated.
  15519. */
  15520. onActivateObservable: Observable<Camera>;
  15521. private _onActivateObserver;
  15522. /**
  15523. * A function that is added to the onActivateObservable
  15524. */
  15525. onActivate: Nullable<(camera: Camera) => void>;
  15526. /**
  15527. * An event triggered when the postprocess changes its size.
  15528. */
  15529. onSizeChangedObservable: Observable<PostProcess>;
  15530. private _onSizeChangedObserver;
  15531. /**
  15532. * A function that is added to the onSizeChangedObservable
  15533. */
  15534. onSizeChanged: (postProcess: PostProcess) => void;
  15535. /**
  15536. * An event triggered when the postprocess applies its effect.
  15537. */
  15538. onApplyObservable: Observable<Effect>;
  15539. private _onApplyObserver;
  15540. /**
  15541. * A function that is added to the onApplyObservable
  15542. */
  15543. onApply: (effect: Effect) => void;
  15544. /**
  15545. * An event triggered before rendering the postprocess
  15546. */
  15547. onBeforeRenderObservable: Observable<Effect>;
  15548. private _onBeforeRenderObserver;
  15549. /**
  15550. * A function that is added to the onBeforeRenderObservable
  15551. */
  15552. onBeforeRender: (effect: Effect) => void;
  15553. /**
  15554. * An event triggered after rendering the postprocess
  15555. */
  15556. onAfterRenderObservable: Observable<Effect>;
  15557. private _onAfterRenderObserver;
  15558. /**
  15559. * A function that is added to the onAfterRenderObservable
  15560. */
  15561. onAfterRender: (efect: Effect) => void;
  15562. /**
  15563. * 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
  15564. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15565. */
  15566. inputTexture: InternalTexture;
  15567. /**
  15568. * Gets the camera which post process is applied to.
  15569. * @returns The camera the post process is applied to.
  15570. */
  15571. getCamera(): Camera;
  15572. /**
  15573. * Gets the texel size of the postprocess.
  15574. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15575. */
  15576. readonly texelSize: Vector2;
  15577. /**
  15578. * Creates a new instance PostProcess
  15579. * @param name The name of the PostProcess.
  15580. * @param fragmentUrl The url of the fragment shader to be used.
  15581. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15582. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15583. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15584. * @param camera The camera to apply the render pass to.
  15585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15586. * @param engine The engine which the post process will be applied. (default: current engine)
  15587. * @param reusable If the post process can be reused on the same frame. (default: false)
  15588. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15589. * @param textureType Type of textures used when performing the post process. (default: 0)
  15590. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15591. * @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
  15592. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15593. */
  15594. constructor(
  15595. /** Name of the PostProcess. */
  15596. 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);
  15597. /**
  15598. * Gets a string idenfifying the name of the class
  15599. * @returns "PostProcess" string
  15600. */
  15601. getClassName(): string;
  15602. /**
  15603. * Gets the engine which this post process belongs to.
  15604. * @returns The engine the post process was enabled with.
  15605. */
  15606. getEngine(): Engine;
  15607. /**
  15608. * The effect that is created when initializing the post process.
  15609. * @returns The created effect corresponding the the postprocess.
  15610. */
  15611. getEffect(): Effect;
  15612. /**
  15613. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15614. * @param postProcess The post process to share the output with.
  15615. * @returns This post process.
  15616. */
  15617. shareOutputWith(postProcess: PostProcess): PostProcess;
  15618. /**
  15619. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15620. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15621. */
  15622. useOwnOutput(): void;
  15623. /**
  15624. * Updates the effect with the current post process compile time values and recompiles the shader.
  15625. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15626. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15627. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15628. * @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
  15629. * @param onCompiled Called when the shader has been compiled.
  15630. * @param onError Called if there is an error when compiling a shader.
  15631. */
  15632. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15633. /**
  15634. * The post process is reusable if it can be used multiple times within one frame.
  15635. * @returns If the post process is reusable
  15636. */
  15637. isReusable(): boolean;
  15638. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15639. markTextureDirty(): void;
  15640. /**
  15641. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15642. * 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.
  15643. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15644. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15645. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15646. * @returns The target texture that was bound to be written to.
  15647. */
  15648. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15649. /**
  15650. * If the post process is supported.
  15651. */
  15652. readonly isSupported: boolean;
  15653. /**
  15654. * The aspect ratio of the output texture.
  15655. */
  15656. readonly aspectRatio: number;
  15657. /**
  15658. * Get a value indicating if the post-process is ready to be used
  15659. * @returns true if the post-process is ready (shader is compiled)
  15660. */
  15661. isReady(): boolean;
  15662. /**
  15663. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15664. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15665. */
  15666. apply(): Nullable<Effect>;
  15667. private _disposeTextures;
  15668. /**
  15669. * Disposes the post process.
  15670. * @param camera The camera to dispose the post process on.
  15671. */
  15672. dispose(camera?: Camera): void;
  15673. }
  15674. }
  15675. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15676. /** @hidden */
  15677. export var kernelBlurVaryingDeclaration: {
  15678. name: string;
  15679. shader: string;
  15680. };
  15681. }
  15682. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15683. /** @hidden */
  15684. export var kernelBlurFragment: {
  15685. name: string;
  15686. shader: string;
  15687. };
  15688. }
  15689. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15690. /** @hidden */
  15691. export var kernelBlurFragment2: {
  15692. name: string;
  15693. shader: string;
  15694. };
  15695. }
  15696. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15697. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15698. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15699. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15700. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15701. /** @hidden */
  15702. export var kernelBlurPixelShader: {
  15703. name: string;
  15704. shader: string;
  15705. };
  15706. }
  15707. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15708. /** @hidden */
  15709. export var kernelBlurVertex: {
  15710. name: string;
  15711. shader: string;
  15712. };
  15713. }
  15714. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15715. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15716. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15717. /** @hidden */
  15718. export var kernelBlurVertexShader: {
  15719. name: string;
  15720. shader: string;
  15721. };
  15722. }
  15723. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15724. import { Vector2 } from "babylonjs/Maths/math.vector";
  15725. import { Nullable } from "babylonjs/types";
  15726. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15727. import { Camera } from "babylonjs/Cameras/camera";
  15728. import { Effect } from "babylonjs/Materials/effect";
  15729. import { Engine } from "babylonjs/Engines/engine";
  15730. import "babylonjs/Shaders/kernelBlur.fragment";
  15731. import "babylonjs/Shaders/kernelBlur.vertex";
  15732. /**
  15733. * The Blur Post Process which blurs an image based on a kernel and direction.
  15734. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15735. */
  15736. export class BlurPostProcess extends PostProcess {
  15737. /** The direction in which to blur the image. */
  15738. direction: Vector2;
  15739. private blockCompilation;
  15740. protected _kernel: number;
  15741. protected _idealKernel: number;
  15742. protected _packedFloat: boolean;
  15743. private _staticDefines;
  15744. /**
  15745. * Sets the length in pixels of the blur sample region
  15746. */
  15747. /**
  15748. * Gets the length in pixels of the blur sample region
  15749. */
  15750. kernel: number;
  15751. /**
  15752. * Sets wether or not the blur needs to unpack/repack floats
  15753. */
  15754. /**
  15755. * Gets wether or not the blur is unpacking/repacking floats
  15756. */
  15757. packedFloat: boolean;
  15758. /**
  15759. * Creates a new instance BlurPostProcess
  15760. * @param name The name of the effect.
  15761. * @param direction The direction in which to blur the image.
  15762. * @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.
  15763. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15764. * @param camera The camera to apply the render pass to.
  15765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15766. * @param engine The engine which the post process will be applied. (default: current engine)
  15767. * @param reusable If the post process can be reused on the same frame. (default: false)
  15768. * @param textureType Type of textures used when performing the post process. (default: 0)
  15769. * @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)
  15770. */
  15771. constructor(name: string,
  15772. /** The direction in which to blur the image. */
  15773. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15774. /**
  15775. * Updates the effect with the current post process compile time values and recompiles the shader.
  15776. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15777. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15778. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15779. * @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
  15780. * @param onCompiled Called when the shader has been compiled.
  15781. * @param onError Called if there is an error when compiling a shader.
  15782. */
  15783. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15784. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15785. /**
  15786. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15787. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15788. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15789. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15790. * The gaps between physical kernels are compensated for in the weighting of the samples
  15791. * @param idealKernel Ideal blur kernel.
  15792. * @return Nearest best kernel.
  15793. */
  15794. protected _nearestBestKernel(idealKernel: number): number;
  15795. /**
  15796. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15797. * @param x The point on the Gaussian distribution to sample.
  15798. * @return the value of the Gaussian function at x.
  15799. */
  15800. protected _gaussianWeight(x: number): number;
  15801. /**
  15802. * Generates a string that can be used as a floating point number in GLSL.
  15803. * @param x Value to print.
  15804. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15805. * @return GLSL float string.
  15806. */
  15807. protected _glslFloat(x: number, decimalFigures?: number): string;
  15808. }
  15809. }
  15810. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15811. import { Scene } from "babylonjs/scene";
  15812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15813. import { Plane } from "babylonjs/Maths/math.plane";
  15814. /**
  15815. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15816. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15817. * You can then easily use it as a reflectionTexture on a flat surface.
  15818. * In case the surface is not a plane, please consider relying on reflection probes.
  15819. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15820. */
  15821. export class MirrorTexture extends RenderTargetTexture {
  15822. private scene;
  15823. /**
  15824. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15825. * 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.
  15826. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15827. */
  15828. mirrorPlane: Plane;
  15829. /**
  15830. * Define the blur ratio used to blur the reflection if needed.
  15831. */
  15832. blurRatio: number;
  15833. /**
  15834. * Define the adaptive blur kernel used to blur the reflection if needed.
  15835. * This will autocompute the closest best match for the `blurKernel`
  15836. */
  15837. adaptiveBlurKernel: number;
  15838. /**
  15839. * Define the blur kernel used to blur the reflection if needed.
  15840. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15841. */
  15842. blurKernel: number;
  15843. /**
  15844. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15845. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15846. */
  15847. blurKernelX: number;
  15848. /**
  15849. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15850. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15851. */
  15852. blurKernelY: number;
  15853. private _autoComputeBlurKernel;
  15854. protected _onRatioRescale(): void;
  15855. private _updateGammaSpace;
  15856. private _imageProcessingConfigChangeObserver;
  15857. private _transformMatrix;
  15858. private _mirrorMatrix;
  15859. private _savedViewMatrix;
  15860. private _blurX;
  15861. private _blurY;
  15862. private _adaptiveBlurKernel;
  15863. private _blurKernelX;
  15864. private _blurKernelY;
  15865. private _blurRatio;
  15866. /**
  15867. * Instantiates a Mirror Texture.
  15868. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15869. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15870. * You can then easily use it as a reflectionTexture on a flat surface.
  15871. * In case the surface is not a plane, please consider relying on reflection probes.
  15872. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15873. * @param name
  15874. * @param size
  15875. * @param scene
  15876. * @param generateMipMaps
  15877. * @param type
  15878. * @param samplingMode
  15879. * @param generateDepthBuffer
  15880. */
  15881. constructor(name: string, size: number | {
  15882. width: number;
  15883. height: number;
  15884. } | {
  15885. ratio: number;
  15886. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15887. private _preparePostProcesses;
  15888. /**
  15889. * Clone the mirror texture.
  15890. * @returns the cloned texture
  15891. */
  15892. clone(): MirrorTexture;
  15893. /**
  15894. * Serialize the texture to a JSON representation you could use in Parse later on
  15895. * @returns the serialized JSON representation
  15896. */
  15897. serialize(): any;
  15898. /**
  15899. * Dispose the texture and release its associated resources.
  15900. */
  15901. dispose(): void;
  15902. }
  15903. }
  15904. declare module "babylonjs/Materials/Textures/texture" {
  15905. import { Observable } from "babylonjs/Misc/observable";
  15906. import { Nullable } from "babylonjs/types";
  15907. import { Scene } from "babylonjs/scene";
  15908. import { Matrix } from "babylonjs/Maths/math.vector";
  15909. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15910. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15911. import { Engine } from "babylonjs/Engines/engine";
  15912. /**
  15913. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15914. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15915. */
  15916. export class Texture extends BaseTexture {
  15917. /** @hidden */
  15918. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15919. /** @hidden */
  15920. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15921. /** @hidden */
  15922. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15923. /** nearest is mag = nearest and min = nearest and mip = linear */
  15924. static readonly NEAREST_SAMPLINGMODE: number;
  15925. /** nearest is mag = nearest and min = nearest and mip = linear */
  15926. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15927. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15928. static readonly BILINEAR_SAMPLINGMODE: number;
  15929. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15930. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15931. /** Trilinear is mag = linear and min = linear and mip = linear */
  15932. static readonly TRILINEAR_SAMPLINGMODE: number;
  15933. /** Trilinear is mag = linear and min = linear and mip = linear */
  15934. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15935. /** mag = nearest and min = nearest and mip = nearest */
  15936. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15937. /** mag = nearest and min = linear and mip = nearest */
  15938. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15939. /** mag = nearest and min = linear and mip = linear */
  15940. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15941. /** mag = nearest and min = linear and mip = none */
  15942. static readonly NEAREST_LINEAR: number;
  15943. /** mag = nearest and min = nearest and mip = none */
  15944. static readonly NEAREST_NEAREST: number;
  15945. /** mag = linear and min = nearest and mip = nearest */
  15946. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15947. /** mag = linear and min = nearest and mip = linear */
  15948. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15949. /** mag = linear and min = linear and mip = none */
  15950. static readonly LINEAR_LINEAR: number;
  15951. /** mag = linear and min = nearest and mip = none */
  15952. static readonly LINEAR_NEAREST: number;
  15953. /** Explicit coordinates mode */
  15954. static readonly EXPLICIT_MODE: number;
  15955. /** Spherical coordinates mode */
  15956. static readonly SPHERICAL_MODE: number;
  15957. /** Planar coordinates mode */
  15958. static readonly PLANAR_MODE: number;
  15959. /** Cubic coordinates mode */
  15960. static readonly CUBIC_MODE: number;
  15961. /** Projection coordinates mode */
  15962. static readonly PROJECTION_MODE: number;
  15963. /** Inverse Cubic coordinates mode */
  15964. static readonly SKYBOX_MODE: number;
  15965. /** Inverse Cubic coordinates mode */
  15966. static readonly INVCUBIC_MODE: number;
  15967. /** Equirectangular coordinates mode */
  15968. static readonly EQUIRECTANGULAR_MODE: number;
  15969. /** Equirectangular Fixed coordinates mode */
  15970. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15971. /** Equirectangular Fixed Mirrored coordinates mode */
  15972. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15973. /** Texture is not repeating outside of 0..1 UVs */
  15974. static readonly CLAMP_ADDRESSMODE: number;
  15975. /** Texture is repeating outside of 0..1 UVs */
  15976. static readonly WRAP_ADDRESSMODE: number;
  15977. /** Texture is repeating and mirrored */
  15978. static readonly MIRROR_ADDRESSMODE: number;
  15979. /**
  15980. * 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
  15981. */
  15982. static UseSerializedUrlIfAny: boolean;
  15983. /**
  15984. * Define the url of the texture.
  15985. */
  15986. url: Nullable<string>;
  15987. /**
  15988. * Define an offset on the texture to offset the u coordinates of the UVs
  15989. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15990. */
  15991. uOffset: number;
  15992. /**
  15993. * Define an offset on the texture to offset the v coordinates of the UVs
  15994. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15995. */
  15996. vOffset: number;
  15997. /**
  15998. * Define an offset on the texture to scale the u coordinates of the UVs
  15999. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16000. */
  16001. uScale: number;
  16002. /**
  16003. * Define an offset on the texture to scale the v coordinates of the UVs
  16004. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16005. */
  16006. vScale: number;
  16007. /**
  16008. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16009. * @see http://doc.babylonjs.com/how_to/more_materials
  16010. */
  16011. uAng: number;
  16012. /**
  16013. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16014. * @see http://doc.babylonjs.com/how_to/more_materials
  16015. */
  16016. vAng: number;
  16017. /**
  16018. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16019. * @see http://doc.babylonjs.com/how_to/more_materials
  16020. */
  16021. wAng: number;
  16022. /**
  16023. * Defines the center of rotation (U)
  16024. */
  16025. uRotationCenter: number;
  16026. /**
  16027. * Defines the center of rotation (V)
  16028. */
  16029. vRotationCenter: number;
  16030. /**
  16031. * Defines the center of rotation (W)
  16032. */
  16033. wRotationCenter: number;
  16034. /**
  16035. * Are mip maps generated for this texture or not.
  16036. */
  16037. readonly noMipmap: boolean;
  16038. /**
  16039. * List of inspectable custom properties (used by the Inspector)
  16040. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16041. */
  16042. inspectableCustomProperties: Nullable<IInspectable[]>;
  16043. private _noMipmap;
  16044. /** @hidden */
  16045. _invertY: boolean;
  16046. private _rowGenerationMatrix;
  16047. private _cachedTextureMatrix;
  16048. private _projectionModeMatrix;
  16049. private _t0;
  16050. private _t1;
  16051. private _t2;
  16052. private _cachedUOffset;
  16053. private _cachedVOffset;
  16054. private _cachedUScale;
  16055. private _cachedVScale;
  16056. private _cachedUAng;
  16057. private _cachedVAng;
  16058. private _cachedWAng;
  16059. private _cachedProjectionMatrixId;
  16060. private _cachedCoordinatesMode;
  16061. /** @hidden */
  16062. protected _initialSamplingMode: number;
  16063. /** @hidden */
  16064. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16065. private _deleteBuffer;
  16066. protected _format: Nullable<number>;
  16067. private _delayedOnLoad;
  16068. private _delayedOnError;
  16069. /**
  16070. * Observable triggered once the texture has been loaded.
  16071. */
  16072. onLoadObservable: Observable<Texture>;
  16073. protected _isBlocking: boolean;
  16074. /**
  16075. * Is the texture preventing material to render while loading.
  16076. * If false, a default texture will be used instead of the loading one during the preparation step.
  16077. */
  16078. isBlocking: boolean;
  16079. /**
  16080. * Get the current sampling mode associated with the texture.
  16081. */
  16082. readonly samplingMode: number;
  16083. /**
  16084. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16085. */
  16086. readonly invertY: boolean;
  16087. /**
  16088. * Instantiates a new texture.
  16089. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16090. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16091. * @param url define the url of the picture to load as a texture
  16092. * @param scene define the scene or engine the texture will belong to
  16093. * @param noMipmap define if the texture will require mip maps or not
  16094. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16095. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16096. * @param onLoad define a callback triggered when the texture has been loaded
  16097. * @param onError define a callback triggered when an error occurred during the loading session
  16098. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16099. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16100. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16101. */
  16102. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16103. /**
  16104. * Update the url (and optional buffer) of this texture if url was null during construction.
  16105. * @param url the url of the texture
  16106. * @param buffer the buffer of the texture (defaults to null)
  16107. * @param onLoad callback called when the texture is loaded (defaults to null)
  16108. */
  16109. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16110. /**
  16111. * Finish the loading sequence of a texture flagged as delayed load.
  16112. * @hidden
  16113. */
  16114. delayLoad(): void;
  16115. private _prepareRowForTextureGeneration;
  16116. /**
  16117. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16118. * @returns the transform matrix of the texture.
  16119. */
  16120. getTextureMatrix(): Matrix;
  16121. /**
  16122. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16123. * @returns The reflection texture transform
  16124. */
  16125. getReflectionTextureMatrix(): Matrix;
  16126. /**
  16127. * Clones the texture.
  16128. * @returns the cloned texture
  16129. */
  16130. clone(): Texture;
  16131. /**
  16132. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16133. * @returns The JSON representation of the texture
  16134. */
  16135. serialize(): any;
  16136. /**
  16137. * Get the current class name of the texture useful for serialization or dynamic coding.
  16138. * @returns "Texture"
  16139. */
  16140. getClassName(): string;
  16141. /**
  16142. * Dispose the texture and release its associated resources.
  16143. */
  16144. dispose(): void;
  16145. /**
  16146. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16147. * @param parsedTexture Define the JSON representation of the texture
  16148. * @param scene Define the scene the parsed texture should be instantiated in
  16149. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16150. * @returns The parsed texture if successful
  16151. */
  16152. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16153. /**
  16154. * Creates a texture from its base 64 representation.
  16155. * @param data Define the base64 payload without the data: prefix
  16156. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16157. * @param scene Define the scene the texture should belong to
  16158. * @param noMipmap Forces the texture to not create mip map information if true
  16159. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16160. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16161. * @param onLoad define a callback triggered when the texture has been loaded
  16162. * @param onError define a callback triggered when an error occurred during the loading session
  16163. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16164. * @returns the created texture
  16165. */
  16166. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16167. /**
  16168. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16169. * @param data Define the base64 payload without the data: prefix
  16170. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16171. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16172. * @param scene Define the scene the texture should belong to
  16173. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16174. * @param noMipmap Forces the texture to not create mip map information if true
  16175. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16176. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16177. * @param onLoad define a callback triggered when the texture has been loaded
  16178. * @param onError define a callback triggered when an error occurred during the loading session
  16179. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16180. * @returns the created texture
  16181. */
  16182. 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;
  16183. }
  16184. }
  16185. declare module "babylonjs/PostProcesses/postProcessManager" {
  16186. import { Nullable } from "babylonjs/types";
  16187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16188. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16189. import { Scene } from "babylonjs/scene";
  16190. /**
  16191. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16192. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16193. */
  16194. export class PostProcessManager {
  16195. private _scene;
  16196. private _indexBuffer;
  16197. private _vertexBuffers;
  16198. /**
  16199. * Creates a new instance PostProcess
  16200. * @param scene The scene that the post process is associated with.
  16201. */
  16202. constructor(scene: Scene);
  16203. private _prepareBuffers;
  16204. private _buildIndexBuffer;
  16205. /**
  16206. * Rebuilds the vertex buffers of the manager.
  16207. * @hidden
  16208. */
  16209. _rebuild(): void;
  16210. /**
  16211. * Prepares a frame to be run through a post process.
  16212. * @param sourceTexture The input texture to the post procesess. (default: null)
  16213. * @param postProcesses An array of post processes to be run. (default: null)
  16214. * @returns True if the post processes were able to be run.
  16215. * @hidden
  16216. */
  16217. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16218. /**
  16219. * Manually render a set of post processes to a texture.
  16220. * @param postProcesses An array of post processes to be run.
  16221. * @param targetTexture The target texture to render to.
  16222. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16223. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16224. * @param lodLevel defines which lod of the texture to render to
  16225. */
  16226. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16227. /**
  16228. * Finalize the result of the output of the postprocesses.
  16229. * @param doNotPresent If true the result will not be displayed to the screen.
  16230. * @param targetTexture The target texture to render to.
  16231. * @param faceIndex The index of the face to bind the target texture to.
  16232. * @param postProcesses The array of post processes to render.
  16233. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16234. * @hidden
  16235. */
  16236. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16237. /**
  16238. * Disposes of the post process manager.
  16239. */
  16240. dispose(): void;
  16241. }
  16242. }
  16243. declare module "babylonjs/Misc/gradients" {
  16244. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16245. /** Interface used by value gradients (color, factor, ...) */
  16246. export interface IValueGradient {
  16247. /**
  16248. * Gets or sets the gradient value (between 0 and 1)
  16249. */
  16250. gradient: number;
  16251. }
  16252. /** Class used to store color4 gradient */
  16253. export class ColorGradient implements IValueGradient {
  16254. /**
  16255. * Gets or sets the gradient value (between 0 and 1)
  16256. */
  16257. gradient: number;
  16258. /**
  16259. * Gets or sets first associated color
  16260. */
  16261. color1: Color4;
  16262. /**
  16263. * Gets or sets second associated color
  16264. */
  16265. color2?: Color4;
  16266. /**
  16267. * Will get a color picked randomly between color1 and color2.
  16268. * If color2 is undefined then color1 will be used
  16269. * @param result defines the target Color4 to store the result in
  16270. */
  16271. getColorToRef(result: Color4): void;
  16272. }
  16273. /** Class used to store color 3 gradient */
  16274. export class Color3Gradient implements IValueGradient {
  16275. /**
  16276. * Gets or sets the gradient value (between 0 and 1)
  16277. */
  16278. gradient: number;
  16279. /**
  16280. * Gets or sets the associated color
  16281. */
  16282. color: Color3;
  16283. }
  16284. /** Class used to store factor gradient */
  16285. export class FactorGradient implements IValueGradient {
  16286. /**
  16287. * Gets or sets the gradient value (between 0 and 1)
  16288. */
  16289. gradient: number;
  16290. /**
  16291. * Gets or sets first associated factor
  16292. */
  16293. factor1: number;
  16294. /**
  16295. * Gets or sets second associated factor
  16296. */
  16297. factor2?: number;
  16298. /**
  16299. * Will get a number picked randomly between factor1 and factor2.
  16300. * If factor2 is undefined then factor1 will be used
  16301. * @returns the picked number
  16302. */
  16303. getFactor(): number;
  16304. }
  16305. /**
  16306. * Helper used to simplify some generic gradient tasks
  16307. */
  16308. export class GradientHelper {
  16309. /**
  16310. * Gets the current gradient from an array of IValueGradient
  16311. * @param ratio defines the current ratio to get
  16312. * @param gradients defines the array of IValueGradient
  16313. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16314. */
  16315. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16316. }
  16317. }
  16318. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16319. import { Scene } from "babylonjs/scene";
  16320. import { ISceneComponent } from "babylonjs/sceneComponent";
  16321. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16322. module "babylonjs/abstractScene" {
  16323. interface AbstractScene {
  16324. /**
  16325. * The list of procedural textures added to the scene
  16326. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16327. */
  16328. proceduralTextures: Array<ProceduralTexture>;
  16329. }
  16330. }
  16331. /**
  16332. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16333. * in a given scene.
  16334. */
  16335. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16336. /**
  16337. * The component name helpfull to identify the component in the list of scene components.
  16338. */
  16339. readonly name: string;
  16340. /**
  16341. * The scene the component belongs to.
  16342. */
  16343. scene: Scene;
  16344. /**
  16345. * Creates a new instance of the component for the given scene
  16346. * @param scene Defines the scene to register the component in
  16347. */
  16348. constructor(scene: Scene);
  16349. /**
  16350. * Registers the component in a given scene
  16351. */
  16352. register(): void;
  16353. /**
  16354. * Rebuilds the elements related to this component in case of
  16355. * context lost for instance.
  16356. */
  16357. rebuild(): void;
  16358. /**
  16359. * Disposes the component and the associated ressources.
  16360. */
  16361. dispose(): void;
  16362. private _beforeClear;
  16363. }
  16364. }
  16365. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16366. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16367. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16368. module "babylonjs/Engines/engine" {
  16369. interface Engine {
  16370. /**
  16371. * Creates a new render target cube texture
  16372. * @param size defines the size of the texture
  16373. * @param options defines the options used to create the texture
  16374. * @returns a new render target cube texture stored in an InternalTexture
  16375. */
  16376. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16377. }
  16378. }
  16379. }
  16380. declare module "babylonjs/Shaders/procedural.vertex" {
  16381. /** @hidden */
  16382. export var proceduralVertexShader: {
  16383. name: string;
  16384. shader: string;
  16385. };
  16386. }
  16387. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16388. import { Observable } from "babylonjs/Misc/observable";
  16389. import { Nullable } from "babylonjs/types";
  16390. import { Scene } from "babylonjs/scene";
  16391. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16392. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16393. import { Effect } from "babylonjs/Materials/effect";
  16394. import { Texture } from "babylonjs/Materials/Textures/texture";
  16395. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16396. import "babylonjs/Shaders/procedural.vertex";
  16397. /**
  16398. * 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.
  16399. * This is the base class of any Procedural texture and contains most of the shareable code.
  16400. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16401. */
  16402. export class ProceduralTexture extends Texture {
  16403. isCube: boolean;
  16404. /**
  16405. * Define if the texture is enabled or not (disabled texture will not render)
  16406. */
  16407. isEnabled: boolean;
  16408. /**
  16409. * Define if the texture must be cleared before rendering (default is true)
  16410. */
  16411. autoClear: boolean;
  16412. /**
  16413. * Callback called when the texture is generated
  16414. */
  16415. onGenerated: () => void;
  16416. /**
  16417. * Event raised when the texture is generated
  16418. */
  16419. onGeneratedObservable: Observable<ProceduralTexture>;
  16420. /** @hidden */
  16421. _generateMipMaps: boolean;
  16422. /** @hidden **/
  16423. _effect: Effect;
  16424. /** @hidden */
  16425. _textures: {
  16426. [key: string]: Texture;
  16427. };
  16428. private _size;
  16429. private _currentRefreshId;
  16430. private _refreshRate;
  16431. private _vertexBuffers;
  16432. private _indexBuffer;
  16433. private _uniforms;
  16434. private _samplers;
  16435. private _fragment;
  16436. private _floats;
  16437. private _ints;
  16438. private _floatsArrays;
  16439. private _colors3;
  16440. private _colors4;
  16441. private _vectors2;
  16442. private _vectors3;
  16443. private _matrices;
  16444. private _fallbackTexture;
  16445. private _fallbackTextureUsed;
  16446. private _engine;
  16447. private _cachedDefines;
  16448. private _contentUpdateId;
  16449. private _contentData;
  16450. /**
  16451. * Instantiates a new procedural texture.
  16452. * 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.
  16453. * This is the base class of any Procedural texture and contains most of the shareable code.
  16454. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16455. * @param name Define the name of the texture
  16456. * @param size Define the size of the texture to create
  16457. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16458. * @param scene Define the scene the texture belongs to
  16459. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16460. * @param generateMipMaps Define if the texture should creates mip maps or not
  16461. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16462. */
  16463. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16464. /**
  16465. * The effect that is created when initializing the post process.
  16466. * @returns The created effect corresponding the the postprocess.
  16467. */
  16468. getEffect(): Effect;
  16469. /**
  16470. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16471. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16472. */
  16473. getContent(): Nullable<ArrayBufferView>;
  16474. private _createIndexBuffer;
  16475. /** @hidden */
  16476. _rebuild(): void;
  16477. /**
  16478. * Resets the texture in order to recreate its associated resources.
  16479. * This can be called in case of context loss
  16480. */
  16481. reset(): void;
  16482. protected _getDefines(): string;
  16483. /**
  16484. * Is the texture ready to be used ? (rendered at least once)
  16485. * @returns true if ready, otherwise, false.
  16486. */
  16487. isReady(): boolean;
  16488. /**
  16489. * Resets the refresh counter of the texture and start bak from scratch.
  16490. * Could be useful to regenerate the texture if it is setup to render only once.
  16491. */
  16492. resetRefreshCounter(): void;
  16493. /**
  16494. * Set the fragment shader to use in order to render the texture.
  16495. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16496. */
  16497. setFragment(fragment: any): void;
  16498. /**
  16499. * Define the refresh rate of the texture or the rendering frequency.
  16500. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16501. */
  16502. refreshRate: number;
  16503. /** @hidden */
  16504. _shouldRender(): boolean;
  16505. /**
  16506. * Get the size the texture is rendering at.
  16507. * @returns the size (texture is always squared)
  16508. */
  16509. getRenderSize(): number;
  16510. /**
  16511. * Resize the texture to new value.
  16512. * @param size Define the new size the texture should have
  16513. * @param generateMipMaps Define whether the new texture should create mip maps
  16514. */
  16515. resize(size: number, generateMipMaps: boolean): void;
  16516. private _checkUniform;
  16517. /**
  16518. * Set a texture in the shader program used to render.
  16519. * @param name Define the name of the uniform samplers as defined in the shader
  16520. * @param texture Define the texture to bind to this sampler
  16521. * @return the texture itself allowing "fluent" like uniform updates
  16522. */
  16523. setTexture(name: string, texture: Texture): ProceduralTexture;
  16524. /**
  16525. * Set a float in the shader.
  16526. * @param name Define the name of the uniform as defined in the shader
  16527. * @param value Define the value to give to the uniform
  16528. * @return the texture itself allowing "fluent" like uniform updates
  16529. */
  16530. setFloat(name: string, value: number): ProceduralTexture;
  16531. /**
  16532. * Set a int in the shader.
  16533. * @param name Define the name of the uniform as defined in the shader
  16534. * @param value Define the value to give to the uniform
  16535. * @return the texture itself allowing "fluent" like uniform updates
  16536. */
  16537. setInt(name: string, value: number): ProceduralTexture;
  16538. /**
  16539. * Set an array of floats in the shader.
  16540. * @param name Define the name of the uniform as defined in the shader
  16541. * @param value Define the value to give to the uniform
  16542. * @return the texture itself allowing "fluent" like uniform updates
  16543. */
  16544. setFloats(name: string, value: number[]): ProceduralTexture;
  16545. /**
  16546. * Set a vec3 in the shader from a Color3.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the texture itself allowing "fluent" like uniform updates
  16550. */
  16551. setColor3(name: string, value: Color3): ProceduralTexture;
  16552. /**
  16553. * Set a vec4 in the shader from a Color4.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the texture itself allowing "fluent" like uniform updates
  16557. */
  16558. setColor4(name: string, value: Color4): ProceduralTexture;
  16559. /**
  16560. * Set a vec2 in the shader from a Vector2.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the texture itself allowing "fluent" like uniform updates
  16564. */
  16565. setVector2(name: string, value: Vector2): ProceduralTexture;
  16566. /**
  16567. * Set a vec3 in the shader from a Vector3.
  16568. * @param name Define the name of the uniform as defined in the shader
  16569. * @param value Define the value to give to the uniform
  16570. * @return the texture itself allowing "fluent" like uniform updates
  16571. */
  16572. setVector3(name: string, value: Vector3): ProceduralTexture;
  16573. /**
  16574. * Set a mat4 in the shader from a MAtrix.
  16575. * @param name Define the name of the uniform as defined in the shader
  16576. * @param value Define the value to give to the uniform
  16577. * @return the texture itself allowing "fluent" like uniform updates
  16578. */
  16579. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16580. /**
  16581. * Render the texture to its associated render target.
  16582. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16583. */
  16584. render(useCameraPostProcess?: boolean): void;
  16585. /**
  16586. * Clone the texture.
  16587. * @returns the cloned texture
  16588. */
  16589. clone(): ProceduralTexture;
  16590. /**
  16591. * Dispose the texture and release its asoociated resources.
  16592. */
  16593. dispose(): void;
  16594. }
  16595. }
  16596. declare module "babylonjs/Particles/baseParticleSystem" {
  16597. import { Nullable } from "babylonjs/types";
  16598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16600. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16601. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16602. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16603. import { Scene } from "babylonjs/scene";
  16604. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16605. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16606. import { Texture } from "babylonjs/Materials/Textures/texture";
  16607. import { Color4 } from "babylonjs/Maths/math.color";
  16608. import { Animation } from "babylonjs/Animations/animation";
  16609. /**
  16610. * This represents the base class for particle system in Babylon.
  16611. * 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.
  16612. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16613. * @example https://doc.babylonjs.com/babylon101/particles
  16614. */
  16615. export class BaseParticleSystem {
  16616. /**
  16617. * Source color is added to the destination color without alpha affecting the result
  16618. */
  16619. static BLENDMODE_ONEONE: number;
  16620. /**
  16621. * Blend current color and particle color using particle’s alpha
  16622. */
  16623. static BLENDMODE_STANDARD: number;
  16624. /**
  16625. * Add current color and particle color multiplied by particle’s alpha
  16626. */
  16627. static BLENDMODE_ADD: number;
  16628. /**
  16629. * Multiply current color with particle color
  16630. */
  16631. static BLENDMODE_MULTIPLY: number;
  16632. /**
  16633. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16634. */
  16635. static BLENDMODE_MULTIPLYADD: number;
  16636. /**
  16637. * List of animations used by the particle system.
  16638. */
  16639. animations: Animation[];
  16640. /**
  16641. * The id of the Particle system.
  16642. */
  16643. id: string;
  16644. /**
  16645. * The friendly name of the Particle system.
  16646. */
  16647. name: string;
  16648. /**
  16649. * The rendering group used by the Particle system to chose when to render.
  16650. */
  16651. renderingGroupId: number;
  16652. /**
  16653. * The emitter represents the Mesh or position we are attaching the particle system to.
  16654. */
  16655. emitter: Nullable<AbstractMesh | Vector3>;
  16656. /**
  16657. * The maximum number of particles to emit per frame
  16658. */
  16659. emitRate: number;
  16660. /**
  16661. * If you want to launch only a few particles at once, that can be done, as well.
  16662. */
  16663. manualEmitCount: number;
  16664. /**
  16665. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16666. */
  16667. updateSpeed: number;
  16668. /**
  16669. * The amount of time the particle system is running (depends of the overall update speed).
  16670. */
  16671. targetStopDuration: number;
  16672. /**
  16673. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16674. */
  16675. disposeOnStop: boolean;
  16676. /**
  16677. * Minimum power of emitting particles.
  16678. */
  16679. minEmitPower: number;
  16680. /**
  16681. * Maximum power of emitting particles.
  16682. */
  16683. maxEmitPower: number;
  16684. /**
  16685. * Minimum life time of emitting particles.
  16686. */
  16687. minLifeTime: number;
  16688. /**
  16689. * Maximum life time of emitting particles.
  16690. */
  16691. maxLifeTime: number;
  16692. /**
  16693. * Minimum Size of emitting particles.
  16694. */
  16695. minSize: number;
  16696. /**
  16697. * Maximum Size of emitting particles.
  16698. */
  16699. maxSize: number;
  16700. /**
  16701. * Minimum scale of emitting particles on X axis.
  16702. */
  16703. minScaleX: number;
  16704. /**
  16705. * Maximum scale of emitting particles on X axis.
  16706. */
  16707. maxScaleX: number;
  16708. /**
  16709. * Minimum scale of emitting particles on Y axis.
  16710. */
  16711. minScaleY: number;
  16712. /**
  16713. * Maximum scale of emitting particles on Y axis.
  16714. */
  16715. maxScaleY: number;
  16716. /**
  16717. * Gets or sets the minimal initial rotation in radians.
  16718. */
  16719. minInitialRotation: number;
  16720. /**
  16721. * Gets or sets the maximal initial rotation in radians.
  16722. */
  16723. maxInitialRotation: number;
  16724. /**
  16725. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16726. */
  16727. minAngularSpeed: number;
  16728. /**
  16729. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16730. */
  16731. maxAngularSpeed: number;
  16732. /**
  16733. * The texture used to render each particle. (this can be a spritesheet)
  16734. */
  16735. particleTexture: Nullable<Texture>;
  16736. /**
  16737. * The layer mask we are rendering the particles through.
  16738. */
  16739. layerMask: number;
  16740. /**
  16741. * This can help using your own shader to render the particle system.
  16742. * The according effect will be created
  16743. */
  16744. customShader: any;
  16745. /**
  16746. * By default particle system starts as soon as they are created. This prevents the
  16747. * automatic start to happen and let you decide when to start emitting particles.
  16748. */
  16749. preventAutoStart: boolean;
  16750. private _noiseTexture;
  16751. /**
  16752. * Gets or sets a texture used to add random noise to particle positions
  16753. */
  16754. noiseTexture: Nullable<ProceduralTexture>;
  16755. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16756. noiseStrength: Vector3;
  16757. /**
  16758. * Callback triggered when the particle animation is ending.
  16759. */
  16760. onAnimationEnd: Nullable<() => void>;
  16761. /**
  16762. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16763. */
  16764. blendMode: number;
  16765. /**
  16766. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16767. * to override the particles.
  16768. */
  16769. forceDepthWrite: boolean;
  16770. /** 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 */
  16771. preWarmCycles: number;
  16772. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16773. preWarmStepOffset: number;
  16774. /**
  16775. * 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)
  16776. */
  16777. spriteCellChangeSpeed: number;
  16778. /**
  16779. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16780. */
  16781. startSpriteCellID: number;
  16782. /**
  16783. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16784. */
  16785. endSpriteCellID: number;
  16786. /**
  16787. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16788. */
  16789. spriteCellWidth: number;
  16790. /**
  16791. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16792. */
  16793. spriteCellHeight: number;
  16794. /**
  16795. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16796. */
  16797. spriteRandomStartCell: boolean;
  16798. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16799. translationPivot: Vector2;
  16800. /** @hidden */
  16801. protected _isAnimationSheetEnabled: boolean;
  16802. /**
  16803. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16804. */
  16805. beginAnimationOnStart: boolean;
  16806. /**
  16807. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16808. */
  16809. beginAnimationFrom: number;
  16810. /**
  16811. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16812. */
  16813. beginAnimationTo: number;
  16814. /**
  16815. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16816. */
  16817. beginAnimationLoop: boolean;
  16818. /**
  16819. * Gets or sets a world offset applied to all particles
  16820. */
  16821. worldOffset: Vector3;
  16822. /**
  16823. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16824. */
  16825. isAnimationSheetEnabled: boolean;
  16826. /**
  16827. * Get hosting scene
  16828. * @returns the scene
  16829. */
  16830. getScene(): Scene;
  16831. /**
  16832. * You can use gravity if you want to give an orientation to your particles.
  16833. */
  16834. gravity: Vector3;
  16835. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16836. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16837. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16838. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16839. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16840. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16841. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16842. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16843. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16844. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16845. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16846. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16847. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16848. /**
  16849. * Defines the delay in milliseconds before starting the system (0 by default)
  16850. */
  16851. startDelay: number;
  16852. /**
  16853. * Gets the current list of drag gradients.
  16854. * You must use addDragGradient and removeDragGradient to udpate this list
  16855. * @returns the list of drag gradients
  16856. */
  16857. getDragGradients(): Nullable<Array<FactorGradient>>;
  16858. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16859. limitVelocityDamping: number;
  16860. /**
  16861. * Gets the current list of limit velocity gradients.
  16862. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16863. * @returns the list of limit velocity gradients
  16864. */
  16865. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16866. /**
  16867. * Gets the current list of color gradients.
  16868. * You must use addColorGradient and removeColorGradient to udpate this list
  16869. * @returns the list of color gradients
  16870. */
  16871. getColorGradients(): Nullable<Array<ColorGradient>>;
  16872. /**
  16873. * Gets the current list of size gradients.
  16874. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16875. * @returns the list of size gradients
  16876. */
  16877. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16878. /**
  16879. * Gets the current list of color remap gradients.
  16880. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16881. * @returns the list of color remap gradients
  16882. */
  16883. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16884. /**
  16885. * Gets the current list of alpha remap gradients.
  16886. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16887. * @returns the list of alpha remap gradients
  16888. */
  16889. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16890. /**
  16891. * Gets the current list of life time gradients.
  16892. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16893. * @returns the list of life time gradients
  16894. */
  16895. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16896. /**
  16897. * Gets the current list of angular speed gradients.
  16898. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16899. * @returns the list of angular speed gradients
  16900. */
  16901. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16902. /**
  16903. * Gets the current list of velocity gradients.
  16904. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16905. * @returns the list of velocity gradients
  16906. */
  16907. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16908. /**
  16909. * Gets the current list of start size gradients.
  16910. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16911. * @returns the list of start size gradients
  16912. */
  16913. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16914. /**
  16915. * Gets the current list of emit rate gradients.
  16916. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16917. * @returns the list of emit rate gradients
  16918. */
  16919. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16920. /**
  16921. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16922. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16923. */
  16924. direction1: Vector3;
  16925. /**
  16926. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16927. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16928. */
  16929. direction2: Vector3;
  16930. /**
  16931. * 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.
  16932. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16933. */
  16934. minEmitBox: Vector3;
  16935. /**
  16936. * 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.
  16937. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16938. */
  16939. maxEmitBox: Vector3;
  16940. /**
  16941. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16942. */
  16943. color1: Color4;
  16944. /**
  16945. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16946. */
  16947. color2: Color4;
  16948. /**
  16949. * Color the particle will have at the end of its lifetime
  16950. */
  16951. colorDead: Color4;
  16952. /**
  16953. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16954. */
  16955. textureMask: Color4;
  16956. /**
  16957. * The particle emitter type defines the emitter used by the particle system.
  16958. * It can be for example box, sphere, or cone...
  16959. */
  16960. particleEmitterType: IParticleEmitterType;
  16961. /** @hidden */
  16962. _isSubEmitter: boolean;
  16963. /**
  16964. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16965. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16966. */
  16967. billboardMode: number;
  16968. protected _isBillboardBased: boolean;
  16969. /**
  16970. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16971. */
  16972. isBillboardBased: boolean;
  16973. /**
  16974. * The scene the particle system belongs to.
  16975. */
  16976. protected _scene: Scene;
  16977. /**
  16978. * Local cache of defines for image processing.
  16979. */
  16980. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16981. /**
  16982. * Default configuration related to image processing available in the standard Material.
  16983. */
  16984. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16985. /**
  16986. * Gets the image processing configuration used either in this material.
  16987. */
  16988. /**
  16989. * Sets the Default image processing configuration used either in the this material.
  16990. *
  16991. * If sets to null, the scene one is in use.
  16992. */
  16993. imageProcessingConfiguration: ImageProcessingConfiguration;
  16994. /**
  16995. * Attaches a new image processing configuration to the Standard Material.
  16996. * @param configuration
  16997. */
  16998. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16999. /** @hidden */
  17000. protected _reset(): void;
  17001. /** @hidden */
  17002. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17003. /**
  17004. * Instantiates a particle system.
  17005. * 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.
  17006. * @param name The name of the particle system
  17007. */
  17008. constructor(name: string);
  17009. /**
  17010. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17011. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17012. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17013. * @returns the emitter
  17014. */
  17015. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17016. /**
  17017. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17018. * @param radius The radius of the hemisphere to emit from
  17019. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17020. * @returns the emitter
  17021. */
  17022. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17023. /**
  17024. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17025. * @param radius The radius of the sphere to emit from
  17026. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17027. * @returns the emitter
  17028. */
  17029. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17030. /**
  17031. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17032. * @param radius The radius of the sphere to emit from
  17033. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17034. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17035. * @returns the emitter
  17036. */
  17037. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17038. /**
  17039. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17040. * @param radius The radius of the emission cylinder
  17041. * @param height The height of the emission cylinder
  17042. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17043. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17044. * @returns the emitter
  17045. */
  17046. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17047. /**
  17048. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17049. * @param radius The radius of the cylinder to emit from
  17050. * @param height The height of the emission cylinder
  17051. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17052. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17053. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17054. * @returns the emitter
  17055. */
  17056. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17057. /**
  17058. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17059. * @param radius The radius of the cone to emit from
  17060. * @param angle The base angle of the cone
  17061. * @returns the emitter
  17062. */
  17063. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17064. /**
  17065. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17068. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17069. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17070. * @returns the emitter
  17071. */
  17072. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17073. }
  17074. }
  17075. declare module "babylonjs/Particles/subEmitter" {
  17076. import { Scene } from "babylonjs/scene";
  17077. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17078. /**
  17079. * Type of sub emitter
  17080. */
  17081. export enum SubEmitterType {
  17082. /**
  17083. * Attached to the particle over it's lifetime
  17084. */
  17085. ATTACHED = 0,
  17086. /**
  17087. * Created when the particle dies
  17088. */
  17089. END = 1
  17090. }
  17091. /**
  17092. * Sub emitter class used to emit particles from an existing particle
  17093. */
  17094. export class SubEmitter {
  17095. /**
  17096. * the particle system to be used by the sub emitter
  17097. */
  17098. particleSystem: ParticleSystem;
  17099. /**
  17100. * Type of the submitter (Default: END)
  17101. */
  17102. type: SubEmitterType;
  17103. /**
  17104. * 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)
  17105. * Note: This only is supported when using an emitter of type Mesh
  17106. */
  17107. inheritDirection: boolean;
  17108. /**
  17109. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17110. */
  17111. inheritedVelocityAmount: number;
  17112. /**
  17113. * Creates a sub emitter
  17114. * @param particleSystem the particle system to be used by the sub emitter
  17115. */
  17116. constructor(
  17117. /**
  17118. * the particle system to be used by the sub emitter
  17119. */
  17120. particleSystem: ParticleSystem);
  17121. /**
  17122. * Clones the sub emitter
  17123. * @returns the cloned sub emitter
  17124. */
  17125. clone(): SubEmitter;
  17126. /**
  17127. * Serialize current object to a JSON object
  17128. * @returns the serialized object
  17129. */
  17130. serialize(): any;
  17131. /** @hidden */
  17132. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17133. /**
  17134. * Creates a new SubEmitter from a serialized JSON version
  17135. * @param serializationObject defines the JSON object to read from
  17136. * @param scene defines the hosting scene
  17137. * @param rootUrl defines the rootUrl for data loading
  17138. * @returns a new SubEmitter
  17139. */
  17140. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17141. /** Release associated resources */
  17142. dispose(): void;
  17143. }
  17144. }
  17145. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17146. /** @hidden */
  17147. export var clipPlaneFragmentDeclaration: {
  17148. name: string;
  17149. shader: string;
  17150. };
  17151. }
  17152. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17153. /** @hidden */
  17154. export var imageProcessingDeclaration: {
  17155. name: string;
  17156. shader: string;
  17157. };
  17158. }
  17159. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17160. /** @hidden */
  17161. export var imageProcessingFunctions: {
  17162. name: string;
  17163. shader: string;
  17164. };
  17165. }
  17166. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17167. /** @hidden */
  17168. export var clipPlaneFragment: {
  17169. name: string;
  17170. shader: string;
  17171. };
  17172. }
  17173. declare module "babylonjs/Shaders/particles.fragment" {
  17174. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17175. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17176. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17177. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17178. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17179. /** @hidden */
  17180. export var particlesPixelShader: {
  17181. name: string;
  17182. shader: string;
  17183. };
  17184. }
  17185. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17186. /** @hidden */
  17187. export var clipPlaneVertexDeclaration: {
  17188. name: string;
  17189. shader: string;
  17190. };
  17191. }
  17192. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17193. /** @hidden */
  17194. export var clipPlaneVertex: {
  17195. name: string;
  17196. shader: string;
  17197. };
  17198. }
  17199. declare module "babylonjs/Shaders/particles.vertex" {
  17200. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17202. /** @hidden */
  17203. export var particlesVertexShader: {
  17204. name: string;
  17205. shader: string;
  17206. };
  17207. }
  17208. declare module "babylonjs/Particles/particleSystem" {
  17209. import { Nullable } from "babylonjs/types";
  17210. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17211. import { Observable } from "babylonjs/Misc/observable";
  17212. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17213. import { Effect } from "babylonjs/Materials/effect";
  17214. import { Scene, IDisposable } from "babylonjs/scene";
  17215. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17216. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17217. import { Particle } from "babylonjs/Particles/particle";
  17218. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17219. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17220. import "babylonjs/Shaders/particles.fragment";
  17221. import "babylonjs/Shaders/particles.vertex";
  17222. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17223. /**
  17224. * This represents a particle system in Babylon.
  17225. * 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.
  17226. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17227. * @example https://doc.babylonjs.com/babylon101/particles
  17228. */
  17229. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17230. /**
  17231. * Billboard mode will only apply to Y axis
  17232. */
  17233. static readonly BILLBOARDMODE_Y: number;
  17234. /**
  17235. * Billboard mode will apply to all axes
  17236. */
  17237. static readonly BILLBOARDMODE_ALL: number;
  17238. /**
  17239. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17240. */
  17241. static readonly BILLBOARDMODE_STRETCHED: number;
  17242. /**
  17243. * This function can be defined to provide custom update for active particles.
  17244. * This function will be called instead of regular update (age, position, color, etc.).
  17245. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17246. */
  17247. updateFunction: (particles: Particle[]) => void;
  17248. private _emitterWorldMatrix;
  17249. /**
  17250. * This function can be defined to specify initial direction for every new particle.
  17251. * It by default use the emitterType defined function
  17252. */
  17253. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17254. /**
  17255. * This function can be defined to specify initial position for every new particle.
  17256. * It by default use the emitterType defined function
  17257. */
  17258. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17259. /**
  17260. * @hidden
  17261. */
  17262. _inheritedVelocityOffset: Vector3;
  17263. /**
  17264. * An event triggered when the system is disposed
  17265. */
  17266. onDisposeObservable: Observable<ParticleSystem>;
  17267. private _onDisposeObserver;
  17268. /**
  17269. * Sets a callback that will be triggered when the system is disposed
  17270. */
  17271. onDispose: () => void;
  17272. private _particles;
  17273. private _epsilon;
  17274. private _capacity;
  17275. private _stockParticles;
  17276. private _newPartsExcess;
  17277. private _vertexData;
  17278. private _vertexBuffer;
  17279. private _vertexBuffers;
  17280. private _spriteBuffer;
  17281. private _indexBuffer;
  17282. private _effect;
  17283. private _customEffect;
  17284. private _cachedDefines;
  17285. private _scaledColorStep;
  17286. private _colorDiff;
  17287. private _scaledDirection;
  17288. private _scaledGravity;
  17289. private _currentRenderId;
  17290. private _alive;
  17291. private _useInstancing;
  17292. private _started;
  17293. private _stopped;
  17294. private _actualFrame;
  17295. private _scaledUpdateSpeed;
  17296. private _vertexBufferSize;
  17297. /** @hidden */
  17298. _currentEmitRateGradient: Nullable<FactorGradient>;
  17299. /** @hidden */
  17300. _currentEmitRate1: number;
  17301. /** @hidden */
  17302. _currentEmitRate2: number;
  17303. /** @hidden */
  17304. _currentStartSizeGradient: Nullable<FactorGradient>;
  17305. /** @hidden */
  17306. _currentStartSize1: number;
  17307. /** @hidden */
  17308. _currentStartSize2: number;
  17309. private readonly _rawTextureWidth;
  17310. private _rampGradientsTexture;
  17311. private _useRampGradients;
  17312. /** Gets or sets a boolean indicating that ramp gradients must be used
  17313. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17314. */
  17315. useRampGradients: boolean;
  17316. /**
  17317. * 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.
  17318. * 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: [])
  17319. */
  17320. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17321. private _subEmitters;
  17322. /**
  17323. * @hidden
  17324. * If the particle systems emitter should be disposed when the particle system is disposed
  17325. */
  17326. _disposeEmitterOnDispose: boolean;
  17327. /**
  17328. * The current active Sub-systems, this property is used by the root particle system only.
  17329. */
  17330. activeSubSystems: Array<ParticleSystem>;
  17331. private _rootParticleSystem;
  17332. /**
  17333. * Gets the current list of active particles
  17334. */
  17335. readonly particles: Particle[];
  17336. /**
  17337. * Returns the string "ParticleSystem"
  17338. * @returns a string containing the class name
  17339. */
  17340. getClassName(): string;
  17341. /**
  17342. * Instantiates a particle system.
  17343. * 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.
  17344. * @param name The name of the particle system
  17345. * @param capacity The max number of particles alive at the same time
  17346. * @param scene The scene the particle system belongs to
  17347. * @param customEffect a custom effect used to change the way particles are rendered by default
  17348. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17349. * @param epsilon Offset used to render the particles
  17350. */
  17351. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17352. private _addFactorGradient;
  17353. private _removeFactorGradient;
  17354. /**
  17355. * Adds a new life time gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param factor defines the life time factor to affect to the specified gradient
  17358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17359. * @returns the current particle system
  17360. */
  17361. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17362. /**
  17363. * Remove a specific life time gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Adds a new size gradient
  17370. * @param gradient defines the gradient to use (between 0 and 1)
  17371. * @param factor defines the size factor to affect to the specified gradient
  17372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17373. * @returns the current particle system
  17374. */
  17375. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17376. /**
  17377. * Remove a specific size gradient
  17378. * @param gradient defines the gradient to remove
  17379. * @returns the current particle system
  17380. */
  17381. removeSizeGradient(gradient: number): IParticleSystem;
  17382. /**
  17383. * Adds a new color remap gradient
  17384. * @param gradient defines the gradient to use (between 0 and 1)
  17385. * @param min defines the color remap minimal range
  17386. * @param max defines the color remap maximal range
  17387. * @returns the current particle system
  17388. */
  17389. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17390. /**
  17391. * Remove a specific color remap gradient
  17392. * @param gradient defines the gradient to remove
  17393. * @returns the current particle system
  17394. */
  17395. removeColorRemapGradient(gradient: number): IParticleSystem;
  17396. /**
  17397. * Adds a new alpha remap gradient
  17398. * @param gradient defines the gradient to use (between 0 and 1)
  17399. * @param min defines the alpha remap minimal range
  17400. * @param max defines the alpha remap maximal range
  17401. * @returns the current particle system
  17402. */
  17403. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17404. /**
  17405. * Remove a specific alpha remap gradient
  17406. * @param gradient defines the gradient to remove
  17407. * @returns the current particle system
  17408. */
  17409. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17410. /**
  17411. * Adds a new angular speed gradient
  17412. * @param gradient defines the gradient to use (between 0 and 1)
  17413. * @param factor defines the angular speed to affect to the specified gradient
  17414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17415. * @returns the current particle system
  17416. */
  17417. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17418. /**
  17419. * Remove a specific angular speed gradient
  17420. * @param gradient defines the gradient to remove
  17421. * @returns the current particle system
  17422. */
  17423. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17424. /**
  17425. * Adds a new velocity gradient
  17426. * @param gradient defines the gradient to use (between 0 and 1)
  17427. * @param factor defines the velocity to affect to the specified gradient
  17428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17429. * @returns the current particle system
  17430. */
  17431. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17432. /**
  17433. * Remove a specific velocity gradient
  17434. * @param gradient defines the gradient to remove
  17435. * @returns the current particle system
  17436. */
  17437. removeVelocityGradient(gradient: number): IParticleSystem;
  17438. /**
  17439. * Adds a new limit velocity gradient
  17440. * @param gradient defines the gradient to use (between 0 and 1)
  17441. * @param factor defines the limit velocity value to affect to the specified gradient
  17442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17443. * @returns the current particle system
  17444. */
  17445. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17446. /**
  17447. * Remove a specific limit velocity gradient
  17448. * @param gradient defines the gradient to remove
  17449. * @returns the current particle system
  17450. */
  17451. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17452. /**
  17453. * Adds a new drag gradient
  17454. * @param gradient defines the gradient to use (between 0 and 1)
  17455. * @param factor defines the drag value to affect to the specified gradient
  17456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17457. * @returns the current particle system
  17458. */
  17459. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17460. /**
  17461. * Remove a specific drag gradient
  17462. * @param gradient defines the gradient to remove
  17463. * @returns the current particle system
  17464. */
  17465. removeDragGradient(gradient: number): IParticleSystem;
  17466. /**
  17467. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17468. * @param gradient defines the gradient to use (between 0 and 1)
  17469. * @param factor defines the emit rate value to affect to the specified gradient
  17470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17471. * @returns the current particle system
  17472. */
  17473. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17474. /**
  17475. * Remove a specific emit rate gradient
  17476. * @param gradient defines the gradient to remove
  17477. * @returns the current particle system
  17478. */
  17479. removeEmitRateGradient(gradient: number): IParticleSystem;
  17480. /**
  17481. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17482. * @param gradient defines the gradient to use (between 0 and 1)
  17483. * @param factor defines the start size value to affect to the specified gradient
  17484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17485. * @returns the current particle system
  17486. */
  17487. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17488. /**
  17489. * Remove a specific start size gradient
  17490. * @param gradient defines the gradient to remove
  17491. * @returns the current particle system
  17492. */
  17493. removeStartSizeGradient(gradient: number): IParticleSystem;
  17494. private _createRampGradientTexture;
  17495. /**
  17496. * Gets the current list of ramp gradients.
  17497. * You must use addRampGradient and removeRampGradient to udpate this list
  17498. * @returns the list of ramp gradients
  17499. */
  17500. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17501. /**
  17502. * Adds a new ramp gradient used to remap particle colors
  17503. * @param gradient defines the gradient to use (between 0 and 1)
  17504. * @param color defines the color to affect to the specified gradient
  17505. * @returns the current particle system
  17506. */
  17507. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17508. /**
  17509. * Remove a specific ramp gradient
  17510. * @param gradient defines the gradient to remove
  17511. * @returns the current particle system
  17512. */
  17513. removeRampGradient(gradient: number): ParticleSystem;
  17514. /**
  17515. * Adds a new color gradient
  17516. * @param gradient defines the gradient to use (between 0 and 1)
  17517. * @param color1 defines the color to affect to the specified gradient
  17518. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17519. * @returns this particle system
  17520. */
  17521. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17522. /**
  17523. * Remove a specific color gradient
  17524. * @param gradient defines the gradient to remove
  17525. * @returns this particle system
  17526. */
  17527. removeColorGradient(gradient: number): IParticleSystem;
  17528. private _fetchR;
  17529. protected _reset(): void;
  17530. private _resetEffect;
  17531. private _createVertexBuffers;
  17532. private _createIndexBuffer;
  17533. /**
  17534. * Gets the maximum number of particles active at the same time.
  17535. * @returns The max number of active particles.
  17536. */
  17537. getCapacity(): number;
  17538. /**
  17539. * Gets whether there are still active particles in the system.
  17540. * @returns True if it is alive, otherwise false.
  17541. */
  17542. isAlive(): boolean;
  17543. /**
  17544. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17545. * @returns True if it has been started, otherwise false.
  17546. */
  17547. isStarted(): boolean;
  17548. private _prepareSubEmitterInternalArray;
  17549. /**
  17550. * Starts the particle system and begins to emit
  17551. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17552. */
  17553. start(delay?: number): void;
  17554. /**
  17555. * Stops the particle system.
  17556. * @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.
  17557. */
  17558. stop(stopSubEmitters?: boolean): void;
  17559. /**
  17560. * Remove all active particles
  17561. */
  17562. reset(): void;
  17563. /**
  17564. * @hidden (for internal use only)
  17565. */
  17566. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17567. /**
  17568. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17569. * Its lifetime will start back at 0.
  17570. */
  17571. recycleParticle: (particle: Particle) => void;
  17572. private _stopSubEmitters;
  17573. private _createParticle;
  17574. private _removeFromRoot;
  17575. private _emitFromParticle;
  17576. private _update;
  17577. /** @hidden */
  17578. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17579. /** @hidden */
  17580. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17581. /** @hidden */
  17582. private _getEffect;
  17583. /**
  17584. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17585. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17586. */
  17587. animate(preWarmOnly?: boolean): void;
  17588. private _appendParticleVertices;
  17589. /**
  17590. * Rebuilds the particle system.
  17591. */
  17592. rebuild(): void;
  17593. /**
  17594. * Is this system ready to be used/rendered
  17595. * @return true if the system is ready
  17596. */
  17597. isReady(): boolean;
  17598. private _render;
  17599. /**
  17600. * Renders the particle system in its current state.
  17601. * @returns the current number of particles
  17602. */
  17603. render(): number;
  17604. /**
  17605. * Disposes the particle system and free the associated resources
  17606. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17607. */
  17608. dispose(disposeTexture?: boolean): void;
  17609. /**
  17610. * Clones the particle system.
  17611. * @param name The name of the cloned object
  17612. * @param newEmitter The new emitter to use
  17613. * @returns the cloned particle system
  17614. */
  17615. clone(name: string, newEmitter: any): ParticleSystem;
  17616. /**
  17617. * Serializes the particle system to a JSON object.
  17618. * @returns the JSON object
  17619. */
  17620. serialize(): any;
  17621. /** @hidden */
  17622. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17623. /** @hidden */
  17624. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17625. /**
  17626. * Parses a JSON object to create a particle system.
  17627. * @param parsedParticleSystem The JSON object to parse
  17628. * @param scene The scene to create the particle system in
  17629. * @param rootUrl The root url to use to load external dependencies like texture
  17630. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17631. * @returns the Parsed particle system
  17632. */
  17633. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17634. }
  17635. }
  17636. declare module "babylonjs/Particles/particle" {
  17637. import { Nullable } from "babylonjs/types";
  17638. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17639. import { Color4 } from "babylonjs/Maths/math.color";
  17640. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17641. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17642. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17643. /**
  17644. * A particle represents one of the element emitted by a particle system.
  17645. * This is mainly define by its coordinates, direction, velocity and age.
  17646. */
  17647. export class Particle {
  17648. /**
  17649. * The particle system the particle belongs to.
  17650. */
  17651. particleSystem: ParticleSystem;
  17652. private static _Count;
  17653. /**
  17654. * Unique ID of the particle
  17655. */
  17656. id: number;
  17657. /**
  17658. * The world position of the particle in the scene.
  17659. */
  17660. position: Vector3;
  17661. /**
  17662. * The world direction of the particle in the scene.
  17663. */
  17664. direction: Vector3;
  17665. /**
  17666. * The color of the particle.
  17667. */
  17668. color: Color4;
  17669. /**
  17670. * The color change of the particle per step.
  17671. */
  17672. colorStep: Color4;
  17673. /**
  17674. * Defines how long will the life of the particle be.
  17675. */
  17676. lifeTime: number;
  17677. /**
  17678. * The current age of the particle.
  17679. */
  17680. age: number;
  17681. /**
  17682. * The current size of the particle.
  17683. */
  17684. size: number;
  17685. /**
  17686. * The current scale of the particle.
  17687. */
  17688. scale: Vector2;
  17689. /**
  17690. * The current angle of the particle.
  17691. */
  17692. angle: number;
  17693. /**
  17694. * Defines how fast is the angle changing.
  17695. */
  17696. angularSpeed: number;
  17697. /**
  17698. * Defines the cell index used by the particle to be rendered from a sprite.
  17699. */
  17700. cellIndex: number;
  17701. /**
  17702. * The information required to support color remapping
  17703. */
  17704. remapData: Vector4;
  17705. /** @hidden */
  17706. _randomCellOffset?: number;
  17707. /** @hidden */
  17708. _initialDirection: Nullable<Vector3>;
  17709. /** @hidden */
  17710. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17711. /** @hidden */
  17712. _initialStartSpriteCellID: number;
  17713. /** @hidden */
  17714. _initialEndSpriteCellID: number;
  17715. /** @hidden */
  17716. _currentColorGradient: Nullable<ColorGradient>;
  17717. /** @hidden */
  17718. _currentColor1: Color4;
  17719. /** @hidden */
  17720. _currentColor2: Color4;
  17721. /** @hidden */
  17722. _currentSizeGradient: Nullable<FactorGradient>;
  17723. /** @hidden */
  17724. _currentSize1: number;
  17725. /** @hidden */
  17726. _currentSize2: number;
  17727. /** @hidden */
  17728. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17729. /** @hidden */
  17730. _currentAngularSpeed1: number;
  17731. /** @hidden */
  17732. _currentAngularSpeed2: number;
  17733. /** @hidden */
  17734. _currentVelocityGradient: Nullable<FactorGradient>;
  17735. /** @hidden */
  17736. _currentVelocity1: number;
  17737. /** @hidden */
  17738. _currentVelocity2: number;
  17739. /** @hidden */
  17740. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17741. /** @hidden */
  17742. _currentLimitVelocity1: number;
  17743. /** @hidden */
  17744. _currentLimitVelocity2: number;
  17745. /** @hidden */
  17746. _currentDragGradient: Nullable<FactorGradient>;
  17747. /** @hidden */
  17748. _currentDrag1: number;
  17749. /** @hidden */
  17750. _currentDrag2: number;
  17751. /** @hidden */
  17752. _randomNoiseCoordinates1: Vector3;
  17753. /** @hidden */
  17754. _randomNoiseCoordinates2: Vector3;
  17755. /**
  17756. * Creates a new instance Particle
  17757. * @param particleSystem the particle system the particle belongs to
  17758. */
  17759. constructor(
  17760. /**
  17761. * The particle system the particle belongs to.
  17762. */
  17763. particleSystem: ParticleSystem);
  17764. private updateCellInfoFromSystem;
  17765. /**
  17766. * Defines how the sprite cell index is updated for the particle
  17767. */
  17768. updateCellIndex(): void;
  17769. /** @hidden */
  17770. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17771. /** @hidden */
  17772. _inheritParticleInfoToSubEmitters(): void;
  17773. /** @hidden */
  17774. _reset(): void;
  17775. /**
  17776. * Copy the properties of particle to another one.
  17777. * @param other the particle to copy the information to.
  17778. */
  17779. copyTo(other: Particle): void;
  17780. }
  17781. }
  17782. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17783. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17784. import { Effect } from "babylonjs/Materials/effect";
  17785. import { Particle } from "babylonjs/Particles/particle";
  17786. /**
  17787. * Particle emitter represents a volume emitting particles.
  17788. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17789. */
  17790. export interface IParticleEmitterType {
  17791. /**
  17792. * Called by the particle System when the direction is computed for the created particle.
  17793. * @param worldMatrix is the world matrix of the particle system
  17794. * @param directionToUpdate is the direction vector to update with the result
  17795. * @param particle is the particle we are computed the direction for
  17796. */
  17797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17798. /**
  17799. * Called by the particle System when the position is computed for the created particle.
  17800. * @param worldMatrix is the world matrix of the particle system
  17801. * @param positionToUpdate is the position vector to update with the result
  17802. * @param particle is the particle we are computed the position for
  17803. */
  17804. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17805. /**
  17806. * Clones the current emitter and returns a copy of it
  17807. * @returns the new emitter
  17808. */
  17809. clone(): IParticleEmitterType;
  17810. /**
  17811. * Called by the GPUParticleSystem to setup the update shader
  17812. * @param effect defines the update shader
  17813. */
  17814. applyToShader(effect: Effect): void;
  17815. /**
  17816. * Returns a string to use to update the GPU particles update shader
  17817. * @returns the effect defines string
  17818. */
  17819. getEffectDefines(): string;
  17820. /**
  17821. * Returns a string representing the class name
  17822. * @returns a string containing the class name
  17823. */
  17824. getClassName(): string;
  17825. /**
  17826. * Serializes the particle system to a JSON object.
  17827. * @returns the JSON object
  17828. */
  17829. serialize(): any;
  17830. /**
  17831. * Parse properties from a JSON object
  17832. * @param serializationObject defines the JSON object
  17833. */
  17834. parse(serializationObject: any): void;
  17835. }
  17836. }
  17837. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17838. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17839. import { Effect } from "babylonjs/Materials/effect";
  17840. import { Particle } from "babylonjs/Particles/particle";
  17841. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17842. /**
  17843. * Particle emitter emitting particles from the inside of a box.
  17844. * It emits the particles randomly between 2 given directions.
  17845. */
  17846. export class BoxParticleEmitter implements IParticleEmitterType {
  17847. /**
  17848. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17849. */
  17850. direction1: Vector3;
  17851. /**
  17852. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17853. */
  17854. direction2: Vector3;
  17855. /**
  17856. * 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.
  17857. */
  17858. minEmitBox: Vector3;
  17859. /**
  17860. * 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.
  17861. */
  17862. maxEmitBox: Vector3;
  17863. /**
  17864. * Creates a new instance BoxParticleEmitter
  17865. */
  17866. constructor();
  17867. /**
  17868. * Called by the particle System when the direction is computed for the created particle.
  17869. * @param worldMatrix is the world matrix of the particle system
  17870. * @param directionToUpdate is the direction vector to update with the result
  17871. * @param particle is the particle we are computed the direction for
  17872. */
  17873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17874. /**
  17875. * Called by the particle System when the position is computed for the created particle.
  17876. * @param worldMatrix is the world matrix of the particle system
  17877. * @param positionToUpdate is the position vector to update with the result
  17878. * @param particle is the particle we are computed the position for
  17879. */
  17880. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17881. /**
  17882. * Clones the current emitter and returns a copy of it
  17883. * @returns the new emitter
  17884. */
  17885. clone(): BoxParticleEmitter;
  17886. /**
  17887. * Called by the GPUParticleSystem to setup the update shader
  17888. * @param effect defines the update shader
  17889. */
  17890. applyToShader(effect: Effect): void;
  17891. /**
  17892. * Returns a string to use to update the GPU particles update shader
  17893. * @returns a string containng the defines string
  17894. */
  17895. getEffectDefines(): string;
  17896. /**
  17897. * Returns the string "BoxParticleEmitter"
  17898. * @returns a string containing the class name
  17899. */
  17900. getClassName(): string;
  17901. /**
  17902. * Serializes the particle system to a JSON object.
  17903. * @returns the JSON object
  17904. */
  17905. serialize(): any;
  17906. /**
  17907. * Parse properties from a JSON object
  17908. * @param serializationObject defines the JSON object
  17909. */
  17910. parse(serializationObject: any): void;
  17911. }
  17912. }
  17913. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17914. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17915. import { Effect } from "babylonjs/Materials/effect";
  17916. import { Particle } from "babylonjs/Particles/particle";
  17917. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17918. /**
  17919. * Particle emitter emitting particles from the inside of a cone.
  17920. * It emits the particles alongside the cone volume from the base to the particle.
  17921. * The emission direction might be randomized.
  17922. */
  17923. export class ConeParticleEmitter implements IParticleEmitterType {
  17924. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17925. directionRandomizer: number;
  17926. private _radius;
  17927. private _angle;
  17928. private _height;
  17929. /**
  17930. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17931. */
  17932. radiusRange: number;
  17933. /**
  17934. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17935. */
  17936. heightRange: number;
  17937. /**
  17938. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17939. */
  17940. emitFromSpawnPointOnly: boolean;
  17941. /**
  17942. * Gets or sets the radius of the emission cone
  17943. */
  17944. radius: number;
  17945. /**
  17946. * Gets or sets the angle of the emission cone
  17947. */
  17948. angle: number;
  17949. private _buildHeight;
  17950. /**
  17951. * Creates a new instance ConeParticleEmitter
  17952. * @param radius the radius of the emission cone (1 by default)
  17953. * @param angle the cone base angle (PI by default)
  17954. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17955. */
  17956. constructor(radius?: number, angle?: number,
  17957. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17958. directionRandomizer?: number);
  17959. /**
  17960. * Called by the particle System when the direction is computed for the created particle.
  17961. * @param worldMatrix is the world matrix of the particle system
  17962. * @param directionToUpdate is the direction vector to update with the result
  17963. * @param particle is the particle we are computed the direction for
  17964. */
  17965. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17966. /**
  17967. * Called by the particle System when the position is computed for the created particle.
  17968. * @param worldMatrix is the world matrix of the particle system
  17969. * @param positionToUpdate is the position vector to update with the result
  17970. * @param particle is the particle we are computed the position for
  17971. */
  17972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17973. /**
  17974. * Clones the current emitter and returns a copy of it
  17975. * @returns the new emitter
  17976. */
  17977. clone(): ConeParticleEmitter;
  17978. /**
  17979. * Called by the GPUParticleSystem to setup the update shader
  17980. * @param effect defines the update shader
  17981. */
  17982. applyToShader(effect: Effect): void;
  17983. /**
  17984. * Returns a string to use to update the GPU particles update shader
  17985. * @returns a string containng the defines string
  17986. */
  17987. getEffectDefines(): string;
  17988. /**
  17989. * Returns the string "ConeParticleEmitter"
  17990. * @returns a string containing the class name
  17991. */
  17992. getClassName(): string;
  17993. /**
  17994. * Serializes the particle system to a JSON object.
  17995. * @returns the JSON object
  17996. */
  17997. serialize(): any;
  17998. /**
  17999. * Parse properties from a JSON object
  18000. * @param serializationObject defines the JSON object
  18001. */
  18002. parse(serializationObject: any): void;
  18003. }
  18004. }
  18005. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18006. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18007. import { Effect } from "babylonjs/Materials/effect";
  18008. import { Particle } from "babylonjs/Particles/particle";
  18009. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18010. /**
  18011. * Particle emitter emitting particles from the inside of a cylinder.
  18012. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18013. */
  18014. export class CylinderParticleEmitter implements IParticleEmitterType {
  18015. /**
  18016. * The radius of the emission cylinder.
  18017. */
  18018. radius: number;
  18019. /**
  18020. * The height of the emission cylinder.
  18021. */
  18022. height: number;
  18023. /**
  18024. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18025. */
  18026. radiusRange: number;
  18027. /**
  18028. * How much to randomize the particle direction [0-1].
  18029. */
  18030. directionRandomizer: number;
  18031. /**
  18032. * Creates a new instance CylinderParticleEmitter
  18033. * @param radius the radius of the emission cylinder (1 by default)
  18034. * @param height the height of the emission cylinder (1 by default)
  18035. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18036. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18037. */
  18038. constructor(
  18039. /**
  18040. * The radius of the emission cylinder.
  18041. */
  18042. radius?: number,
  18043. /**
  18044. * The height of the emission cylinder.
  18045. */
  18046. height?: number,
  18047. /**
  18048. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18049. */
  18050. radiusRange?: number,
  18051. /**
  18052. * How much to randomize the particle direction [0-1].
  18053. */
  18054. directionRandomizer?: number);
  18055. /**
  18056. * Called by the particle System when the direction is computed for the created particle.
  18057. * @param worldMatrix is the world matrix of the particle system
  18058. * @param directionToUpdate is the direction vector to update with the result
  18059. * @param particle is the particle we are computed the direction for
  18060. */
  18061. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18062. /**
  18063. * Called by the particle System when the position is computed for the created particle.
  18064. * @param worldMatrix is the world matrix of the particle system
  18065. * @param positionToUpdate is the position vector to update with the result
  18066. * @param particle is the particle we are computed the position for
  18067. */
  18068. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18069. /**
  18070. * Clones the current emitter and returns a copy of it
  18071. * @returns the new emitter
  18072. */
  18073. clone(): CylinderParticleEmitter;
  18074. /**
  18075. * Called by the GPUParticleSystem to setup the update shader
  18076. * @param effect defines the update shader
  18077. */
  18078. applyToShader(effect: Effect): void;
  18079. /**
  18080. * Returns a string to use to update the GPU particles update shader
  18081. * @returns a string containng the defines string
  18082. */
  18083. getEffectDefines(): string;
  18084. /**
  18085. * Returns the string "CylinderParticleEmitter"
  18086. * @returns a string containing the class name
  18087. */
  18088. getClassName(): string;
  18089. /**
  18090. * Serializes the particle system to a JSON object.
  18091. * @returns the JSON object
  18092. */
  18093. serialize(): any;
  18094. /**
  18095. * Parse properties from a JSON object
  18096. * @param serializationObject defines the JSON object
  18097. */
  18098. parse(serializationObject: any): void;
  18099. }
  18100. /**
  18101. * Particle emitter emitting particles from the inside of a cylinder.
  18102. * It emits the particles randomly between two vectors.
  18103. */
  18104. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18105. /**
  18106. * The min limit of the emission direction.
  18107. */
  18108. direction1: Vector3;
  18109. /**
  18110. * The max limit of the emission direction.
  18111. */
  18112. direction2: Vector3;
  18113. /**
  18114. * Creates a new instance CylinderDirectedParticleEmitter
  18115. * @param radius the radius of the emission cylinder (1 by default)
  18116. * @param height the height of the emission cylinder (1 by default)
  18117. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18118. * @param direction1 the min limit of the emission direction (up vector by default)
  18119. * @param direction2 the max limit of the emission direction (up vector by default)
  18120. */
  18121. constructor(radius?: number, height?: number, radiusRange?: number,
  18122. /**
  18123. * The min limit of the emission direction.
  18124. */
  18125. direction1?: Vector3,
  18126. /**
  18127. * The max limit of the emission direction.
  18128. */
  18129. direction2?: Vector3);
  18130. /**
  18131. * Called by the particle System when the direction is computed for the created particle.
  18132. * @param worldMatrix is the world matrix of the particle system
  18133. * @param directionToUpdate is the direction vector to update with the result
  18134. * @param particle is the particle we are computed the direction for
  18135. */
  18136. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18137. /**
  18138. * Clones the current emitter and returns a copy of it
  18139. * @returns the new emitter
  18140. */
  18141. clone(): CylinderDirectedParticleEmitter;
  18142. /**
  18143. * Called by the GPUParticleSystem to setup the update shader
  18144. * @param effect defines the update shader
  18145. */
  18146. applyToShader(effect: Effect): void;
  18147. /**
  18148. * Returns a string to use to update the GPU particles update shader
  18149. * @returns a string containng the defines string
  18150. */
  18151. getEffectDefines(): string;
  18152. /**
  18153. * Returns the string "CylinderDirectedParticleEmitter"
  18154. * @returns a string containing the class name
  18155. */
  18156. getClassName(): string;
  18157. /**
  18158. * Serializes the particle system to a JSON object.
  18159. * @returns the JSON object
  18160. */
  18161. serialize(): any;
  18162. /**
  18163. * Parse properties from a JSON object
  18164. * @param serializationObject defines the JSON object
  18165. */
  18166. parse(serializationObject: any): void;
  18167. }
  18168. }
  18169. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18170. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18171. import { Effect } from "babylonjs/Materials/effect";
  18172. import { Particle } from "babylonjs/Particles/particle";
  18173. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18174. /**
  18175. * Particle emitter emitting particles from the inside of a hemisphere.
  18176. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18177. */
  18178. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18179. /**
  18180. * The radius of the emission hemisphere.
  18181. */
  18182. radius: number;
  18183. /**
  18184. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18185. */
  18186. radiusRange: number;
  18187. /**
  18188. * How much to randomize the particle direction [0-1].
  18189. */
  18190. directionRandomizer: number;
  18191. /**
  18192. * Creates a new instance HemisphericParticleEmitter
  18193. * @param radius the radius of the emission hemisphere (1 by default)
  18194. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18195. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18196. */
  18197. constructor(
  18198. /**
  18199. * The radius of the emission hemisphere.
  18200. */
  18201. radius?: number,
  18202. /**
  18203. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18204. */
  18205. radiusRange?: number,
  18206. /**
  18207. * How much to randomize the particle direction [0-1].
  18208. */
  18209. directionRandomizer?: number);
  18210. /**
  18211. * Called by the particle System when the direction is computed for the created particle.
  18212. * @param worldMatrix is the world matrix of the particle system
  18213. * @param directionToUpdate is the direction vector to update with the result
  18214. * @param particle is the particle we are computed the direction for
  18215. */
  18216. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18217. /**
  18218. * Called by the particle System when the position is computed for the created particle.
  18219. * @param worldMatrix is the world matrix of the particle system
  18220. * @param positionToUpdate is the position vector to update with the result
  18221. * @param particle is the particle we are computed the position for
  18222. */
  18223. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18224. /**
  18225. * Clones the current emitter and returns a copy of it
  18226. * @returns the new emitter
  18227. */
  18228. clone(): HemisphericParticleEmitter;
  18229. /**
  18230. * Called by the GPUParticleSystem to setup the update shader
  18231. * @param effect defines the update shader
  18232. */
  18233. applyToShader(effect: Effect): void;
  18234. /**
  18235. * Returns a string to use to update the GPU particles update shader
  18236. * @returns a string containng the defines string
  18237. */
  18238. getEffectDefines(): string;
  18239. /**
  18240. * Returns the string "HemisphericParticleEmitter"
  18241. * @returns a string containing the class name
  18242. */
  18243. getClassName(): string;
  18244. /**
  18245. * Serializes the particle system to a JSON object.
  18246. * @returns the JSON object
  18247. */
  18248. serialize(): any;
  18249. /**
  18250. * Parse properties from a JSON object
  18251. * @param serializationObject defines the JSON object
  18252. */
  18253. parse(serializationObject: any): void;
  18254. }
  18255. }
  18256. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18257. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18258. import { Effect } from "babylonjs/Materials/effect";
  18259. import { Particle } from "babylonjs/Particles/particle";
  18260. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18261. /**
  18262. * Particle emitter emitting particles from a point.
  18263. * It emits the particles randomly between 2 given directions.
  18264. */
  18265. export class PointParticleEmitter implements IParticleEmitterType {
  18266. /**
  18267. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18268. */
  18269. direction1: Vector3;
  18270. /**
  18271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18272. */
  18273. direction2: Vector3;
  18274. /**
  18275. * Creates a new instance PointParticleEmitter
  18276. */
  18277. constructor();
  18278. /**
  18279. * Called by the particle System when the direction is computed for the created particle.
  18280. * @param worldMatrix is the world matrix of the particle system
  18281. * @param directionToUpdate is the direction vector to update with the result
  18282. * @param particle is the particle we are computed the direction for
  18283. */
  18284. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18285. /**
  18286. * Called by the particle System when the position is computed for the created particle.
  18287. * @param worldMatrix is the world matrix of the particle system
  18288. * @param positionToUpdate is the position vector to update with the result
  18289. * @param particle is the particle we are computed the position for
  18290. */
  18291. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18292. /**
  18293. * Clones the current emitter and returns a copy of it
  18294. * @returns the new emitter
  18295. */
  18296. clone(): PointParticleEmitter;
  18297. /**
  18298. * Called by the GPUParticleSystem to setup the update shader
  18299. * @param effect defines the update shader
  18300. */
  18301. applyToShader(effect: Effect): void;
  18302. /**
  18303. * Returns a string to use to update the GPU particles update shader
  18304. * @returns a string containng the defines string
  18305. */
  18306. getEffectDefines(): string;
  18307. /**
  18308. * Returns the string "PointParticleEmitter"
  18309. * @returns a string containing the class name
  18310. */
  18311. getClassName(): string;
  18312. /**
  18313. * Serializes the particle system to a JSON object.
  18314. * @returns the JSON object
  18315. */
  18316. serialize(): any;
  18317. /**
  18318. * Parse properties from a JSON object
  18319. * @param serializationObject defines the JSON object
  18320. */
  18321. parse(serializationObject: any): void;
  18322. }
  18323. }
  18324. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18325. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18326. import { Effect } from "babylonjs/Materials/effect";
  18327. import { Particle } from "babylonjs/Particles/particle";
  18328. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18329. /**
  18330. * Particle emitter emitting particles from the inside of a sphere.
  18331. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18332. */
  18333. export class SphereParticleEmitter implements IParticleEmitterType {
  18334. /**
  18335. * The radius of the emission sphere.
  18336. */
  18337. radius: number;
  18338. /**
  18339. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18340. */
  18341. radiusRange: number;
  18342. /**
  18343. * How much to randomize the particle direction [0-1].
  18344. */
  18345. directionRandomizer: number;
  18346. /**
  18347. * Creates a new instance SphereParticleEmitter
  18348. * @param radius the radius of the emission sphere (1 by default)
  18349. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18350. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18351. */
  18352. constructor(
  18353. /**
  18354. * The radius of the emission sphere.
  18355. */
  18356. radius?: number,
  18357. /**
  18358. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18359. */
  18360. radiusRange?: number,
  18361. /**
  18362. * How much to randomize the particle direction [0-1].
  18363. */
  18364. directionRandomizer?: number);
  18365. /**
  18366. * Called by the particle System when the direction is computed for the created particle.
  18367. * @param worldMatrix is the world matrix of the particle system
  18368. * @param directionToUpdate is the direction vector to update with the result
  18369. * @param particle is the particle we are computed the direction for
  18370. */
  18371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18372. /**
  18373. * Called by the particle System when the position is computed for the created particle.
  18374. * @param worldMatrix is the world matrix of the particle system
  18375. * @param positionToUpdate is the position vector to update with the result
  18376. * @param particle is the particle we are computed the position for
  18377. */
  18378. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18379. /**
  18380. * Clones the current emitter and returns a copy of it
  18381. * @returns the new emitter
  18382. */
  18383. clone(): SphereParticleEmitter;
  18384. /**
  18385. * Called by the GPUParticleSystem to setup the update shader
  18386. * @param effect defines the update shader
  18387. */
  18388. applyToShader(effect: Effect): void;
  18389. /**
  18390. * Returns a string to use to update the GPU particles update shader
  18391. * @returns a string containng the defines string
  18392. */
  18393. getEffectDefines(): string;
  18394. /**
  18395. * Returns the string "SphereParticleEmitter"
  18396. * @returns a string containing the class name
  18397. */
  18398. getClassName(): string;
  18399. /**
  18400. * Serializes the particle system to a JSON object.
  18401. * @returns the JSON object
  18402. */
  18403. serialize(): any;
  18404. /**
  18405. * Parse properties from a JSON object
  18406. * @param serializationObject defines the JSON object
  18407. */
  18408. parse(serializationObject: any): void;
  18409. }
  18410. /**
  18411. * Particle emitter emitting particles from the inside of a sphere.
  18412. * It emits the particles randomly between two vectors.
  18413. */
  18414. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18415. /**
  18416. * The min limit of the emission direction.
  18417. */
  18418. direction1: Vector3;
  18419. /**
  18420. * The max limit of the emission direction.
  18421. */
  18422. direction2: Vector3;
  18423. /**
  18424. * Creates a new instance SphereDirectedParticleEmitter
  18425. * @param radius the radius of the emission sphere (1 by default)
  18426. * @param direction1 the min limit of the emission direction (up vector by default)
  18427. * @param direction2 the max limit of the emission direction (up vector by default)
  18428. */
  18429. constructor(radius?: number,
  18430. /**
  18431. * The min limit of the emission direction.
  18432. */
  18433. direction1?: Vector3,
  18434. /**
  18435. * The max limit of the emission direction.
  18436. */
  18437. direction2?: Vector3);
  18438. /**
  18439. * Called by the particle System when the direction is computed for the created particle.
  18440. * @param worldMatrix is the world matrix of the particle system
  18441. * @param directionToUpdate is the direction vector to update with the result
  18442. * @param particle is the particle we are computed the direction for
  18443. */
  18444. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18445. /**
  18446. * Clones the current emitter and returns a copy of it
  18447. * @returns the new emitter
  18448. */
  18449. clone(): SphereDirectedParticleEmitter;
  18450. /**
  18451. * Called by the GPUParticleSystem to setup the update shader
  18452. * @param effect defines the update shader
  18453. */
  18454. applyToShader(effect: Effect): void;
  18455. /**
  18456. * Returns a string to use to update the GPU particles update shader
  18457. * @returns a string containng the defines string
  18458. */
  18459. getEffectDefines(): string;
  18460. /**
  18461. * Returns the string "SphereDirectedParticleEmitter"
  18462. * @returns a string containing the class name
  18463. */
  18464. getClassName(): string;
  18465. /**
  18466. * Serializes the particle system to a JSON object.
  18467. * @returns the JSON object
  18468. */
  18469. serialize(): any;
  18470. /**
  18471. * Parse properties from a JSON object
  18472. * @param serializationObject defines the JSON object
  18473. */
  18474. parse(serializationObject: any): void;
  18475. }
  18476. }
  18477. declare module "babylonjs/Particles/EmitterTypes/index" {
  18478. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18479. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18480. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18481. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18482. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18483. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18484. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18485. }
  18486. declare module "babylonjs/Particles/IParticleSystem" {
  18487. import { Nullable } from "babylonjs/types";
  18488. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18489. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18492. import { Texture } from "babylonjs/Materials/Textures/texture";
  18493. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18494. import { Scene } from "babylonjs/scene";
  18495. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18496. import { Animation } from "babylonjs/Animations/animation";
  18497. /**
  18498. * Interface representing a particle system in Babylon.js.
  18499. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18500. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18501. */
  18502. export interface IParticleSystem {
  18503. /**
  18504. * List of animations used by the particle system.
  18505. */
  18506. animations: Animation[];
  18507. /**
  18508. * The id of the Particle system.
  18509. */
  18510. id: string;
  18511. /**
  18512. * The name of the Particle system.
  18513. */
  18514. name: string;
  18515. /**
  18516. * The emitter represents the Mesh or position we are attaching the particle system to.
  18517. */
  18518. emitter: Nullable<AbstractMesh | Vector3>;
  18519. /**
  18520. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18521. */
  18522. isBillboardBased: boolean;
  18523. /**
  18524. * The rendering group used by the Particle system to chose when to render.
  18525. */
  18526. renderingGroupId: number;
  18527. /**
  18528. * The layer mask we are rendering the particles through.
  18529. */
  18530. layerMask: number;
  18531. /**
  18532. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18533. */
  18534. updateSpeed: number;
  18535. /**
  18536. * The amount of time the particle system is running (depends of the overall update speed).
  18537. */
  18538. targetStopDuration: number;
  18539. /**
  18540. * The texture used to render each particle. (this can be a spritesheet)
  18541. */
  18542. particleTexture: Nullable<Texture>;
  18543. /**
  18544. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18545. */
  18546. blendMode: number;
  18547. /**
  18548. * Minimum life time of emitting particles.
  18549. */
  18550. minLifeTime: number;
  18551. /**
  18552. * Maximum life time of emitting particles.
  18553. */
  18554. maxLifeTime: number;
  18555. /**
  18556. * Minimum Size of emitting particles.
  18557. */
  18558. minSize: number;
  18559. /**
  18560. * Maximum Size of emitting particles.
  18561. */
  18562. maxSize: number;
  18563. /**
  18564. * Minimum scale of emitting particles on X axis.
  18565. */
  18566. minScaleX: number;
  18567. /**
  18568. * Maximum scale of emitting particles on X axis.
  18569. */
  18570. maxScaleX: number;
  18571. /**
  18572. * Minimum scale of emitting particles on Y axis.
  18573. */
  18574. minScaleY: number;
  18575. /**
  18576. * Maximum scale of emitting particles on Y axis.
  18577. */
  18578. maxScaleY: number;
  18579. /**
  18580. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18581. */
  18582. color1: Color4;
  18583. /**
  18584. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18585. */
  18586. color2: Color4;
  18587. /**
  18588. * Color the particle will have at the end of its lifetime.
  18589. */
  18590. colorDead: Color4;
  18591. /**
  18592. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18593. */
  18594. emitRate: number;
  18595. /**
  18596. * You can use gravity if you want to give an orientation to your particles.
  18597. */
  18598. gravity: Vector3;
  18599. /**
  18600. * Minimum power of emitting particles.
  18601. */
  18602. minEmitPower: number;
  18603. /**
  18604. * Maximum power of emitting particles.
  18605. */
  18606. maxEmitPower: number;
  18607. /**
  18608. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18609. */
  18610. minAngularSpeed: number;
  18611. /**
  18612. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18613. */
  18614. maxAngularSpeed: number;
  18615. /**
  18616. * Gets or sets the minimal initial rotation in radians.
  18617. */
  18618. minInitialRotation: number;
  18619. /**
  18620. * Gets or sets the maximal initial rotation in radians.
  18621. */
  18622. maxInitialRotation: number;
  18623. /**
  18624. * The particle emitter type defines the emitter used by the particle system.
  18625. * It can be for example box, sphere, or cone...
  18626. */
  18627. particleEmitterType: Nullable<IParticleEmitterType>;
  18628. /**
  18629. * Defines the delay in milliseconds before starting the system (0 by default)
  18630. */
  18631. startDelay: number;
  18632. /**
  18633. * 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
  18634. */
  18635. preWarmCycles: number;
  18636. /**
  18637. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18638. */
  18639. preWarmStepOffset: number;
  18640. /**
  18641. * 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)
  18642. */
  18643. spriteCellChangeSpeed: number;
  18644. /**
  18645. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18646. */
  18647. startSpriteCellID: number;
  18648. /**
  18649. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18650. */
  18651. endSpriteCellID: number;
  18652. /**
  18653. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18654. */
  18655. spriteCellWidth: number;
  18656. /**
  18657. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18658. */
  18659. spriteCellHeight: number;
  18660. /**
  18661. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18662. */
  18663. spriteRandomStartCell: boolean;
  18664. /**
  18665. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18666. */
  18667. isAnimationSheetEnabled: boolean;
  18668. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18669. translationPivot: Vector2;
  18670. /**
  18671. * Gets or sets a texture used to add random noise to particle positions
  18672. */
  18673. noiseTexture: Nullable<BaseTexture>;
  18674. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18675. noiseStrength: Vector3;
  18676. /**
  18677. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18678. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18679. */
  18680. billboardMode: number;
  18681. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18682. limitVelocityDamping: number;
  18683. /**
  18684. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18685. */
  18686. beginAnimationOnStart: boolean;
  18687. /**
  18688. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18689. */
  18690. beginAnimationFrom: number;
  18691. /**
  18692. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18693. */
  18694. beginAnimationTo: number;
  18695. /**
  18696. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18697. */
  18698. beginAnimationLoop: boolean;
  18699. /**
  18700. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18701. */
  18702. disposeOnStop: boolean;
  18703. /**
  18704. * Gets the maximum number of particles active at the same time.
  18705. * @returns The max number of active particles.
  18706. */
  18707. getCapacity(): number;
  18708. /**
  18709. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18710. * @returns True if it has been started, otherwise false.
  18711. */
  18712. isStarted(): boolean;
  18713. /**
  18714. * Animates the particle system for this frame.
  18715. */
  18716. animate(): void;
  18717. /**
  18718. * Renders the particle system in its current state.
  18719. * @returns the current number of particles
  18720. */
  18721. render(): number;
  18722. /**
  18723. * Dispose the particle system and frees its associated resources.
  18724. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18725. */
  18726. dispose(disposeTexture?: boolean): void;
  18727. /**
  18728. * Clones the particle system.
  18729. * @param name The name of the cloned object
  18730. * @param newEmitter The new emitter to use
  18731. * @returns the cloned particle system
  18732. */
  18733. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18734. /**
  18735. * Serializes the particle system to a JSON object.
  18736. * @returns the JSON object
  18737. */
  18738. serialize(): any;
  18739. /**
  18740. * Rebuild the particle system
  18741. */
  18742. rebuild(): void;
  18743. /**
  18744. * Starts the particle system and begins to emit
  18745. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18746. */
  18747. start(delay?: number): void;
  18748. /**
  18749. * Stops the particle system.
  18750. */
  18751. stop(): void;
  18752. /**
  18753. * Remove all active particles
  18754. */
  18755. reset(): void;
  18756. /**
  18757. * Is this system ready to be used/rendered
  18758. * @return true if the system is ready
  18759. */
  18760. isReady(): boolean;
  18761. /**
  18762. * Adds a new color gradient
  18763. * @param gradient defines the gradient to use (between 0 and 1)
  18764. * @param color1 defines the color to affect to the specified gradient
  18765. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18766. * @returns the current particle system
  18767. */
  18768. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18769. /**
  18770. * Remove a specific color gradient
  18771. * @param gradient defines the gradient to remove
  18772. * @returns the current particle system
  18773. */
  18774. removeColorGradient(gradient: number): IParticleSystem;
  18775. /**
  18776. * Adds a new size gradient
  18777. * @param gradient defines the gradient to use (between 0 and 1)
  18778. * @param factor defines the size factor to affect to the specified gradient
  18779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18780. * @returns the current particle system
  18781. */
  18782. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18783. /**
  18784. * Remove a specific size gradient
  18785. * @param gradient defines the gradient to remove
  18786. * @returns the current particle system
  18787. */
  18788. removeSizeGradient(gradient: number): IParticleSystem;
  18789. /**
  18790. * Gets the current list of color gradients.
  18791. * You must use addColorGradient and removeColorGradient to udpate this list
  18792. * @returns the list of color gradients
  18793. */
  18794. getColorGradients(): Nullable<Array<ColorGradient>>;
  18795. /**
  18796. * Gets the current list of size gradients.
  18797. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18798. * @returns the list of size gradients
  18799. */
  18800. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18801. /**
  18802. * Gets the current list of angular speed gradients.
  18803. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18804. * @returns the list of angular speed gradients
  18805. */
  18806. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18807. /**
  18808. * Adds a new angular speed gradient
  18809. * @param gradient defines the gradient to use (between 0 and 1)
  18810. * @param factor defines the angular speed to affect to the specified gradient
  18811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18812. * @returns the current particle system
  18813. */
  18814. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18815. /**
  18816. * Remove a specific angular speed gradient
  18817. * @param gradient defines the gradient to remove
  18818. * @returns the current particle system
  18819. */
  18820. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18821. /**
  18822. * Gets the current list of velocity gradients.
  18823. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18824. * @returns the list of velocity gradients
  18825. */
  18826. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18827. /**
  18828. * Adds a new velocity gradient
  18829. * @param gradient defines the gradient to use (between 0 and 1)
  18830. * @param factor defines the velocity to affect to the specified gradient
  18831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18832. * @returns the current particle system
  18833. */
  18834. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18835. /**
  18836. * Remove a specific velocity gradient
  18837. * @param gradient defines the gradient to remove
  18838. * @returns the current particle system
  18839. */
  18840. removeVelocityGradient(gradient: number): IParticleSystem;
  18841. /**
  18842. * Gets the current list of limit velocity gradients.
  18843. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18844. * @returns the list of limit velocity gradients
  18845. */
  18846. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18847. /**
  18848. * Adds a new limit velocity gradient
  18849. * @param gradient defines the gradient to use (between 0 and 1)
  18850. * @param factor defines the limit velocity to affect to the specified gradient
  18851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18852. * @returns the current particle system
  18853. */
  18854. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18855. /**
  18856. * Remove a specific limit velocity gradient
  18857. * @param gradient defines the gradient to remove
  18858. * @returns the current particle system
  18859. */
  18860. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18861. /**
  18862. * Adds a new drag gradient
  18863. * @param gradient defines the gradient to use (between 0 and 1)
  18864. * @param factor defines the drag to affect to the specified gradient
  18865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18866. * @returns the current particle system
  18867. */
  18868. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18869. /**
  18870. * Remove a specific drag gradient
  18871. * @param gradient defines the gradient to remove
  18872. * @returns the current particle system
  18873. */
  18874. removeDragGradient(gradient: number): IParticleSystem;
  18875. /**
  18876. * Gets the current list of drag gradients.
  18877. * You must use addDragGradient and removeDragGradient to udpate this list
  18878. * @returns the list of drag gradients
  18879. */
  18880. getDragGradients(): Nullable<Array<FactorGradient>>;
  18881. /**
  18882. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18883. * @param gradient defines the gradient to use (between 0 and 1)
  18884. * @param factor defines the emit rate to affect to the specified gradient
  18885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18886. * @returns the current particle system
  18887. */
  18888. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18889. /**
  18890. * Remove a specific emit rate gradient
  18891. * @param gradient defines the gradient to remove
  18892. * @returns the current particle system
  18893. */
  18894. removeEmitRateGradient(gradient: number): IParticleSystem;
  18895. /**
  18896. * Gets the current list of emit rate gradients.
  18897. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18898. * @returns the list of emit rate gradients
  18899. */
  18900. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18901. /**
  18902. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18903. * @param gradient defines the gradient to use (between 0 and 1)
  18904. * @param factor defines the start size to affect to the specified gradient
  18905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18906. * @returns the current particle system
  18907. */
  18908. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18909. /**
  18910. * Remove a specific start size gradient
  18911. * @param gradient defines the gradient to remove
  18912. * @returns the current particle system
  18913. */
  18914. removeStartSizeGradient(gradient: number): IParticleSystem;
  18915. /**
  18916. * Gets the current list of start size gradients.
  18917. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18918. * @returns the list of start size gradients
  18919. */
  18920. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18921. /**
  18922. * Adds a new life time gradient
  18923. * @param gradient defines the gradient to use (between 0 and 1)
  18924. * @param factor defines the life time factor to affect to the specified gradient
  18925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18926. * @returns the current particle system
  18927. */
  18928. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18929. /**
  18930. * Remove a specific life time gradient
  18931. * @param gradient defines the gradient to remove
  18932. * @returns the current particle system
  18933. */
  18934. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18935. /**
  18936. * Gets the current list of life time gradients.
  18937. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18938. * @returns the list of life time gradients
  18939. */
  18940. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18941. /**
  18942. * Gets the current list of color gradients.
  18943. * You must use addColorGradient and removeColorGradient to udpate this list
  18944. * @returns the list of color gradients
  18945. */
  18946. getColorGradients(): Nullable<Array<ColorGradient>>;
  18947. /**
  18948. * Adds a new ramp gradient used to remap particle colors
  18949. * @param gradient defines the gradient to use (between 0 and 1)
  18950. * @param color defines the color to affect to the specified gradient
  18951. * @returns the current particle system
  18952. */
  18953. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18954. /**
  18955. * Gets the current list of ramp gradients.
  18956. * You must use addRampGradient and removeRampGradient to udpate this list
  18957. * @returns the list of ramp gradients
  18958. */
  18959. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18960. /** Gets or sets a boolean indicating that ramp gradients must be used
  18961. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18962. */
  18963. useRampGradients: boolean;
  18964. /**
  18965. * Adds a new color remap gradient
  18966. * @param gradient defines the gradient to use (between 0 and 1)
  18967. * @param min defines the color remap minimal range
  18968. * @param max defines the color remap maximal range
  18969. * @returns the current particle system
  18970. */
  18971. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18972. /**
  18973. * Gets the current list of color remap gradients.
  18974. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18975. * @returns the list of color remap gradients
  18976. */
  18977. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18978. /**
  18979. * Adds a new alpha remap gradient
  18980. * @param gradient defines the gradient to use (between 0 and 1)
  18981. * @param min defines the alpha remap minimal range
  18982. * @param max defines the alpha remap maximal range
  18983. * @returns the current particle system
  18984. */
  18985. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18986. /**
  18987. * Gets the current list of alpha remap gradients.
  18988. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18989. * @returns the list of alpha remap gradients
  18990. */
  18991. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18992. /**
  18993. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18994. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18995. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18996. * @returns the emitter
  18997. */
  18998. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18999. /**
  19000. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19001. * @param radius The radius of the hemisphere to emit from
  19002. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19003. * @returns the emitter
  19004. */
  19005. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19006. /**
  19007. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19008. * @param radius The radius of the sphere to emit from
  19009. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19010. * @returns the emitter
  19011. */
  19012. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19013. /**
  19014. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19015. * @param radius The radius of the sphere to emit from
  19016. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19017. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19018. * @returns the emitter
  19019. */
  19020. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19021. /**
  19022. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19023. * @param radius The radius of the emission cylinder
  19024. * @param height The height of the emission cylinder
  19025. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19026. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19027. * @returns the emitter
  19028. */
  19029. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19030. /**
  19031. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19032. * @param radius The radius of the cylinder to emit from
  19033. * @param height The height of the emission cylinder
  19034. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19037. * @returns the emitter
  19038. */
  19039. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19040. /**
  19041. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19042. * @param radius The radius of the cone to emit from
  19043. * @param angle The base angle of the cone
  19044. * @returns the emitter
  19045. */
  19046. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19047. /**
  19048. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19049. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19050. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19051. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19052. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19053. * @returns the emitter
  19054. */
  19055. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19056. /**
  19057. * Get hosting scene
  19058. * @returns the scene
  19059. */
  19060. getScene(): Scene;
  19061. }
  19062. }
  19063. declare module "babylonjs/Meshes/instancedMesh" {
  19064. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19065. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19066. import { Camera } from "babylonjs/Cameras/camera";
  19067. import { Node } from "babylonjs/node";
  19068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19069. import { Mesh } from "babylonjs/Meshes/mesh";
  19070. import { Material } from "babylonjs/Materials/material";
  19071. import { Skeleton } from "babylonjs/Bones/skeleton";
  19072. import { Light } from "babylonjs/Lights/light";
  19073. /**
  19074. * Creates an instance based on a source mesh.
  19075. */
  19076. export class InstancedMesh extends AbstractMesh {
  19077. private _sourceMesh;
  19078. private _currentLOD;
  19079. /** @hidden */
  19080. _indexInSourceMeshInstanceArray: number;
  19081. constructor(name: string, source: Mesh);
  19082. /**
  19083. * Returns the string "InstancedMesh".
  19084. */
  19085. getClassName(): string;
  19086. /** Gets the list of lights affecting that mesh */
  19087. readonly lightSources: Light[];
  19088. _resyncLightSources(): void;
  19089. _resyncLighSource(light: Light): void;
  19090. _removeLightSource(light: Light, dispose: boolean): void;
  19091. /**
  19092. * If the source mesh receives shadows
  19093. */
  19094. readonly receiveShadows: boolean;
  19095. /**
  19096. * The material of the source mesh
  19097. */
  19098. readonly material: Nullable<Material>;
  19099. /**
  19100. * Visibility of the source mesh
  19101. */
  19102. readonly visibility: number;
  19103. /**
  19104. * Skeleton of the source mesh
  19105. */
  19106. readonly skeleton: Nullable<Skeleton>;
  19107. /**
  19108. * Rendering ground id of the source mesh
  19109. */
  19110. renderingGroupId: number;
  19111. /**
  19112. * Returns the total number of vertices (integer).
  19113. */
  19114. getTotalVertices(): number;
  19115. /**
  19116. * Returns a positive integer : the total number of indices in this mesh geometry.
  19117. * @returns the numner of indices or zero if the mesh has no geometry.
  19118. */
  19119. getTotalIndices(): number;
  19120. /**
  19121. * The source mesh of the instance
  19122. */
  19123. readonly sourceMesh: Mesh;
  19124. /**
  19125. * Is this node ready to be used/rendered
  19126. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19127. * @return {boolean} is it ready
  19128. */
  19129. isReady(completeCheck?: boolean): boolean;
  19130. /**
  19131. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19132. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19133. * @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.
  19134. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19135. */
  19136. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19137. /**
  19138. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19139. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19140. * The `data` are either a numeric array either a Float32Array.
  19141. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19142. * 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).
  19143. * Note that a new underlying VertexBuffer object is created each call.
  19144. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19145. *
  19146. * Possible `kind` values :
  19147. * - VertexBuffer.PositionKind
  19148. * - VertexBuffer.UVKind
  19149. * - VertexBuffer.UV2Kind
  19150. * - VertexBuffer.UV3Kind
  19151. * - VertexBuffer.UV4Kind
  19152. * - VertexBuffer.UV5Kind
  19153. * - VertexBuffer.UV6Kind
  19154. * - VertexBuffer.ColorKind
  19155. * - VertexBuffer.MatricesIndicesKind
  19156. * - VertexBuffer.MatricesIndicesExtraKind
  19157. * - VertexBuffer.MatricesWeightsKind
  19158. * - VertexBuffer.MatricesWeightsExtraKind
  19159. *
  19160. * Returns the Mesh.
  19161. */
  19162. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19163. /**
  19164. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19165. * If the mesh has no geometry, it is simply returned as it is.
  19166. * The `data` are either a numeric array either a Float32Array.
  19167. * No new underlying VertexBuffer object is created.
  19168. * 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.
  19169. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19170. *
  19171. * Possible `kind` values :
  19172. * - VertexBuffer.PositionKind
  19173. * - VertexBuffer.UVKind
  19174. * - VertexBuffer.UV2Kind
  19175. * - VertexBuffer.UV3Kind
  19176. * - VertexBuffer.UV4Kind
  19177. * - VertexBuffer.UV5Kind
  19178. * - VertexBuffer.UV6Kind
  19179. * - VertexBuffer.ColorKind
  19180. * - VertexBuffer.MatricesIndicesKind
  19181. * - VertexBuffer.MatricesIndicesExtraKind
  19182. * - VertexBuffer.MatricesWeightsKind
  19183. * - VertexBuffer.MatricesWeightsExtraKind
  19184. *
  19185. * Returns the Mesh.
  19186. */
  19187. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19188. /**
  19189. * Sets the mesh indices.
  19190. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19191. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19192. * This method creates a new index buffer each call.
  19193. * Returns the Mesh.
  19194. */
  19195. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19196. /**
  19197. * Boolean : True if the mesh owns the requested kind of data.
  19198. */
  19199. isVerticesDataPresent(kind: string): boolean;
  19200. /**
  19201. * Returns an array of indices (IndicesArray).
  19202. */
  19203. getIndices(): Nullable<IndicesArray>;
  19204. readonly _positions: Nullable<Vector3[]>;
  19205. /**
  19206. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19207. * This means the mesh underlying bounding box and sphere are recomputed.
  19208. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19209. * @returns the current mesh
  19210. */
  19211. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19212. /** @hidden */
  19213. _preActivate(): InstancedMesh;
  19214. /** @hidden */
  19215. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19216. /** @hidden */
  19217. _postActivate(): void;
  19218. getWorldMatrix(): Matrix;
  19219. readonly isAnInstance: boolean;
  19220. /**
  19221. * Returns the current associated LOD AbstractMesh.
  19222. */
  19223. getLOD(camera: Camera): AbstractMesh;
  19224. /** @hidden */
  19225. _syncSubMeshes(): InstancedMesh;
  19226. /** @hidden */
  19227. _generatePointsArray(): boolean;
  19228. /**
  19229. * Creates a new InstancedMesh from the current mesh.
  19230. * - name (string) : the cloned mesh name
  19231. * - newParent (optional Node) : the optional Node to parent the clone to.
  19232. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19233. *
  19234. * Returns the clone.
  19235. */
  19236. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19237. /**
  19238. * Disposes the InstancedMesh.
  19239. * Returns nothing.
  19240. */
  19241. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19242. }
  19243. }
  19244. declare module "babylonjs/Materials/shaderMaterial" {
  19245. import { Scene } from "babylonjs/scene";
  19246. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19248. import { Mesh } from "babylonjs/Meshes/mesh";
  19249. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19251. import { Texture } from "babylonjs/Materials/Textures/texture";
  19252. import { Material } from "babylonjs/Materials/material";
  19253. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19254. /**
  19255. * Defines the options associated with the creation of a shader material.
  19256. */
  19257. export interface IShaderMaterialOptions {
  19258. /**
  19259. * Does the material work in alpha blend mode
  19260. */
  19261. needAlphaBlending: boolean;
  19262. /**
  19263. * Does the material work in alpha test mode
  19264. */
  19265. needAlphaTesting: boolean;
  19266. /**
  19267. * The list of attribute names used in the shader
  19268. */
  19269. attributes: string[];
  19270. /**
  19271. * The list of unifrom names used in the shader
  19272. */
  19273. uniforms: string[];
  19274. /**
  19275. * The list of UBO names used in the shader
  19276. */
  19277. uniformBuffers: string[];
  19278. /**
  19279. * The list of sampler names used in the shader
  19280. */
  19281. samplers: string[];
  19282. /**
  19283. * The list of defines used in the shader
  19284. */
  19285. defines: string[];
  19286. }
  19287. /**
  19288. * 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.
  19289. *
  19290. * This returned material effects how the mesh will look based on the code in the shaders.
  19291. *
  19292. * @see http://doc.babylonjs.com/how_to/shader_material
  19293. */
  19294. export class ShaderMaterial extends Material {
  19295. private _shaderPath;
  19296. private _options;
  19297. private _textures;
  19298. private _textureArrays;
  19299. private _floats;
  19300. private _ints;
  19301. private _floatsArrays;
  19302. private _colors3;
  19303. private _colors3Arrays;
  19304. private _colors4;
  19305. private _colors4Arrays;
  19306. private _vectors2;
  19307. private _vectors3;
  19308. private _vectors4;
  19309. private _matrices;
  19310. private _matrices3x3;
  19311. private _matrices2x2;
  19312. private _vectors2Arrays;
  19313. private _vectors3Arrays;
  19314. private _vectors4Arrays;
  19315. private _cachedWorldViewMatrix;
  19316. private _cachedWorldViewProjectionMatrix;
  19317. private _renderId;
  19318. /**
  19319. * Instantiate a new shader material.
  19320. * 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.
  19321. * This returned material effects how the mesh will look based on the code in the shaders.
  19322. * @see http://doc.babylonjs.com/how_to/shader_material
  19323. * @param name Define the name of the material in the scene
  19324. * @param scene Define the scene the material belongs to
  19325. * @param shaderPath Defines the route to the shader code in one of three ways:
  19326. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19327. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19328. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19329. * @param options Define the options used to create the shader
  19330. */
  19331. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19332. /**
  19333. * Gets the options used to compile the shader.
  19334. * They can be modified to trigger a new compilation
  19335. */
  19336. readonly options: IShaderMaterialOptions;
  19337. /**
  19338. * Gets the current class name of the material e.g. "ShaderMaterial"
  19339. * Mainly use in serialization.
  19340. * @returns the class name
  19341. */
  19342. getClassName(): string;
  19343. /**
  19344. * Specifies if the material will require alpha blending
  19345. * @returns a boolean specifying if alpha blending is needed
  19346. */
  19347. needAlphaBlending(): boolean;
  19348. /**
  19349. * Specifies if this material should be rendered in alpha test mode
  19350. * @returns a boolean specifying if an alpha test is needed.
  19351. */
  19352. needAlphaTesting(): boolean;
  19353. private _checkUniform;
  19354. /**
  19355. * Set a texture in the shader.
  19356. * @param name Define the name of the uniform samplers as defined in the shader
  19357. * @param texture Define the texture to bind to this sampler
  19358. * @return the material itself allowing "fluent" like uniform updates
  19359. */
  19360. setTexture(name: string, texture: Texture): ShaderMaterial;
  19361. /**
  19362. * Set a texture array in the shader.
  19363. * @param name Define the name of the uniform sampler array as defined in the shader
  19364. * @param textures Define the list of textures to bind to this sampler
  19365. * @return the material itself allowing "fluent" like uniform updates
  19366. */
  19367. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19368. /**
  19369. * Set a float in the shader.
  19370. * @param name Define the name of the uniform as defined in the shader
  19371. * @param value Define the value to give to the uniform
  19372. * @return the material itself allowing "fluent" like uniform updates
  19373. */
  19374. setFloat(name: string, value: number): ShaderMaterial;
  19375. /**
  19376. * Set a int in the shader.
  19377. * @param name Define the name of the uniform as defined in the shader
  19378. * @param value Define the value to give to the uniform
  19379. * @return the material itself allowing "fluent" like uniform updates
  19380. */
  19381. setInt(name: string, value: number): ShaderMaterial;
  19382. /**
  19383. * Set an array of floats in the shader.
  19384. * @param name Define the name of the uniform as defined in the shader
  19385. * @param value Define the value to give to the uniform
  19386. * @return the material itself allowing "fluent" like uniform updates
  19387. */
  19388. setFloats(name: string, value: number[]): ShaderMaterial;
  19389. /**
  19390. * Set a vec3 in the shader from a Color3.
  19391. * @param name Define the name of the uniform as defined in the shader
  19392. * @param value Define the value to give to the uniform
  19393. * @return the material itself allowing "fluent" like uniform updates
  19394. */
  19395. setColor3(name: string, value: Color3): ShaderMaterial;
  19396. /**
  19397. * Set a vec3 array in the shader from a Color3 array.
  19398. * @param name Define the name of the uniform as defined in the shader
  19399. * @param value Define the value to give to the uniform
  19400. * @return the material itself allowing "fluent" like uniform updates
  19401. */
  19402. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19403. /**
  19404. * Set a vec4 in the shader from a Color4.
  19405. * @param name Define the name of the uniform as defined in the shader
  19406. * @param value Define the value to give to the uniform
  19407. * @return the material itself allowing "fluent" like uniform updates
  19408. */
  19409. setColor4(name: string, value: Color4): ShaderMaterial;
  19410. /**
  19411. * Set a vec4 array in the shader from a Color4 array.
  19412. * @param name Define the name of the uniform as defined in the shader
  19413. * @param value Define the value to give to the uniform
  19414. * @return the material itself allowing "fluent" like uniform updates
  19415. */
  19416. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19417. /**
  19418. * Set a vec2 in the shader from a Vector2.
  19419. * @param name Define the name of the uniform as defined in the shader
  19420. * @param value Define the value to give to the uniform
  19421. * @return the material itself allowing "fluent" like uniform updates
  19422. */
  19423. setVector2(name: string, value: Vector2): ShaderMaterial;
  19424. /**
  19425. * Set a vec3 in the shader from a Vector3.
  19426. * @param name Define the name of the uniform as defined in the shader
  19427. * @param value Define the value to give to the uniform
  19428. * @return the material itself allowing "fluent" like uniform updates
  19429. */
  19430. setVector3(name: string, value: Vector3): ShaderMaterial;
  19431. /**
  19432. * Set a vec4 in the shader from a Vector4.
  19433. * @param name Define the name of the uniform as defined in the shader
  19434. * @param value Define the value to give to the uniform
  19435. * @return the material itself allowing "fluent" like uniform updates
  19436. */
  19437. setVector4(name: string, value: Vector4): ShaderMaterial;
  19438. /**
  19439. * Set a mat4 in the shader from a Matrix.
  19440. * @param name Define the name of the uniform as defined in the shader
  19441. * @param value Define the value to give to the uniform
  19442. * @return the material itself allowing "fluent" like uniform updates
  19443. */
  19444. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19445. /**
  19446. * Set a mat3 in the shader from a Float32Array.
  19447. * @param name Define the name of the uniform as defined in the shader
  19448. * @param value Define the value to give to the uniform
  19449. * @return the material itself allowing "fluent" like uniform updates
  19450. */
  19451. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19452. /**
  19453. * Set a mat2 in the shader from a Float32Array.
  19454. * @param name Define the name of the uniform as defined in the shader
  19455. * @param value Define the value to give to the uniform
  19456. * @return the material itself allowing "fluent" like uniform updates
  19457. */
  19458. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19459. /**
  19460. * Set a vec2 array in the shader from a number array.
  19461. * @param name Define the name of the uniform as defined in the shader
  19462. * @param value Define the value to give to the uniform
  19463. * @return the material itself allowing "fluent" like uniform updates
  19464. */
  19465. setArray2(name: string, value: number[]): ShaderMaterial;
  19466. /**
  19467. * Set a vec3 array in the shader from a number array.
  19468. * @param name Define the name of the uniform as defined in the shader
  19469. * @param value Define the value to give to the uniform
  19470. * @return the material itself allowing "fluent" like uniform updates
  19471. */
  19472. setArray3(name: string, value: number[]): ShaderMaterial;
  19473. /**
  19474. * Set a vec4 array in the shader from a number array.
  19475. * @param name Define the name of the uniform as defined in the shader
  19476. * @param value Define the value to give to the uniform
  19477. * @return the material itself allowing "fluent" like uniform updates
  19478. */
  19479. setArray4(name: string, value: number[]): ShaderMaterial;
  19480. private _checkCache;
  19481. /**
  19482. * Specifies that the submesh is ready to be used
  19483. * @param mesh defines the mesh to check
  19484. * @param subMesh defines which submesh to check
  19485. * @param useInstances specifies that instances should be used
  19486. * @returns a boolean indicating that the submesh is ready or not
  19487. */
  19488. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19489. /**
  19490. * Checks if the material is ready to render the requested mesh
  19491. * @param mesh Define the mesh to render
  19492. * @param useInstances Define whether or not the material is used with instances
  19493. * @returns true if ready, otherwise false
  19494. */
  19495. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19496. /**
  19497. * Binds the world matrix to the material
  19498. * @param world defines the world transformation matrix
  19499. */
  19500. bindOnlyWorldMatrix(world: Matrix): void;
  19501. /**
  19502. * Binds the material to the mesh
  19503. * @param world defines the world transformation matrix
  19504. * @param mesh defines the mesh to bind the material to
  19505. */
  19506. bind(world: Matrix, mesh?: Mesh): void;
  19507. /**
  19508. * Gets the active textures from the material
  19509. * @returns an array of textures
  19510. */
  19511. getActiveTextures(): BaseTexture[];
  19512. /**
  19513. * Specifies if the material uses a texture
  19514. * @param texture defines the texture to check against the material
  19515. * @returns a boolean specifying if the material uses the texture
  19516. */
  19517. hasTexture(texture: BaseTexture): boolean;
  19518. /**
  19519. * Makes a duplicate of the material, and gives it a new name
  19520. * @param name defines the new name for the duplicated material
  19521. * @returns the cloned material
  19522. */
  19523. clone(name: string): ShaderMaterial;
  19524. /**
  19525. * Disposes the material
  19526. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19527. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19528. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19529. */
  19530. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19531. /**
  19532. * Serializes this material in a JSON representation
  19533. * @returns the serialized material object
  19534. */
  19535. serialize(): any;
  19536. /**
  19537. * Creates a shader material from parsed shader material data
  19538. * @param source defines the JSON represnetation of the material
  19539. * @param scene defines the hosting scene
  19540. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19541. * @returns a new material
  19542. */
  19543. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19544. }
  19545. }
  19546. declare module "babylonjs/Shaders/color.fragment" {
  19547. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19548. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19549. /** @hidden */
  19550. export var colorPixelShader: {
  19551. name: string;
  19552. shader: string;
  19553. };
  19554. }
  19555. declare module "babylonjs/Shaders/color.vertex" {
  19556. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19557. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19558. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19559. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19560. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19561. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19562. /** @hidden */
  19563. export var colorVertexShader: {
  19564. name: string;
  19565. shader: string;
  19566. };
  19567. }
  19568. declare module "babylonjs/Meshes/linesMesh" {
  19569. import { Nullable } from "babylonjs/types";
  19570. import { Scene } from "babylonjs/scene";
  19571. import { Color3 } from "babylonjs/Maths/math.color";
  19572. import { Node } from "babylonjs/node";
  19573. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19574. import { Mesh } from "babylonjs/Meshes/mesh";
  19575. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19576. import { Effect } from "babylonjs/Materials/effect";
  19577. import { Material } from "babylonjs/Materials/material";
  19578. import "babylonjs/Shaders/color.fragment";
  19579. import "babylonjs/Shaders/color.vertex";
  19580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19581. /**
  19582. * Line mesh
  19583. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19584. */
  19585. export class LinesMesh extends Mesh {
  19586. /**
  19587. * If vertex color should be applied to the mesh
  19588. */
  19589. readonly useVertexColor?: boolean | undefined;
  19590. /**
  19591. * If vertex alpha should be applied to the mesh
  19592. */
  19593. readonly useVertexAlpha?: boolean | undefined;
  19594. /**
  19595. * Color of the line (Default: White)
  19596. */
  19597. color: Color3;
  19598. /**
  19599. * Alpha of the line (Default: 1)
  19600. */
  19601. alpha: number;
  19602. /**
  19603. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19604. * This margin is expressed in world space coordinates, so its value may vary.
  19605. * Default value is 0.1
  19606. */
  19607. intersectionThreshold: number;
  19608. private _colorShader;
  19609. private color4;
  19610. /**
  19611. * Creates a new LinesMesh
  19612. * @param name defines the name
  19613. * @param scene defines the hosting scene
  19614. * @param parent defines the parent mesh if any
  19615. * @param source defines the optional source LinesMesh used to clone data from
  19616. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19617. * When false, achieved by calling a clone(), also passing False.
  19618. * This will make creation of children, recursive.
  19619. * @param useVertexColor defines if this LinesMesh supports vertex color
  19620. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19621. */
  19622. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19623. /**
  19624. * If vertex color should be applied to the mesh
  19625. */
  19626. useVertexColor?: boolean | undefined,
  19627. /**
  19628. * If vertex alpha should be applied to the mesh
  19629. */
  19630. useVertexAlpha?: boolean | undefined);
  19631. private _addClipPlaneDefine;
  19632. private _removeClipPlaneDefine;
  19633. isReady(): boolean;
  19634. /**
  19635. * Returns the string "LineMesh"
  19636. */
  19637. getClassName(): string;
  19638. /**
  19639. * @hidden
  19640. */
  19641. /**
  19642. * @hidden
  19643. */
  19644. material: Material;
  19645. /**
  19646. * @hidden
  19647. */
  19648. readonly checkCollisions: boolean;
  19649. /** @hidden */
  19650. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19651. /** @hidden */
  19652. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19653. /**
  19654. * Disposes of the line mesh
  19655. * @param doNotRecurse If children should be disposed
  19656. */
  19657. dispose(doNotRecurse?: boolean): void;
  19658. /**
  19659. * Returns a new LineMesh object cloned from the current one.
  19660. */
  19661. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19662. /**
  19663. * Creates a new InstancedLinesMesh object from the mesh model.
  19664. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19665. * @param name defines the name of the new instance
  19666. * @returns a new InstancedLinesMesh
  19667. */
  19668. createInstance(name: string): InstancedLinesMesh;
  19669. }
  19670. /**
  19671. * Creates an instance based on a source LinesMesh
  19672. */
  19673. export class InstancedLinesMesh extends InstancedMesh {
  19674. /**
  19675. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19676. * This margin is expressed in world space coordinates, so its value may vary.
  19677. * Initilized with the intersectionThreshold value of the source LinesMesh
  19678. */
  19679. intersectionThreshold: number;
  19680. constructor(name: string, source: LinesMesh);
  19681. /**
  19682. * Returns the string "InstancedLinesMesh".
  19683. */
  19684. getClassName(): string;
  19685. }
  19686. }
  19687. declare module "babylonjs/Shaders/line.fragment" {
  19688. /** @hidden */
  19689. export var linePixelShader: {
  19690. name: string;
  19691. shader: string;
  19692. };
  19693. }
  19694. declare module "babylonjs/Shaders/line.vertex" {
  19695. /** @hidden */
  19696. export var lineVertexShader: {
  19697. name: string;
  19698. shader: string;
  19699. };
  19700. }
  19701. declare module "babylonjs/Rendering/edgesRenderer" {
  19702. import { Nullable } from "babylonjs/types";
  19703. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19705. import { Vector3 } from "babylonjs/Maths/math.vector";
  19706. import { IDisposable } from "babylonjs/scene";
  19707. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19708. import "babylonjs/Shaders/line.fragment";
  19709. import "babylonjs/Shaders/line.vertex";
  19710. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19711. module "babylonjs/Meshes/abstractMesh" {
  19712. interface AbstractMesh {
  19713. /**
  19714. * Gets the edgesRenderer associated with the mesh
  19715. */
  19716. edgesRenderer: Nullable<EdgesRenderer>;
  19717. }
  19718. }
  19719. module "babylonjs/Meshes/linesMesh" {
  19720. interface LinesMesh {
  19721. /**
  19722. * Enables the edge rendering mode on the mesh.
  19723. * This mode makes the mesh edges visible
  19724. * @param epsilon defines the maximal distance between two angles to detect a face
  19725. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19726. * @returns the currentAbstractMesh
  19727. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19728. */
  19729. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19730. }
  19731. }
  19732. module "babylonjs/Meshes/linesMesh" {
  19733. interface InstancedLinesMesh {
  19734. /**
  19735. * Enables the edge rendering mode on the mesh.
  19736. * This mode makes the mesh edges visible
  19737. * @param epsilon defines the maximal distance between two angles to detect a face
  19738. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19739. * @returns the current InstancedLinesMesh
  19740. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19741. */
  19742. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19743. }
  19744. }
  19745. /**
  19746. * Defines the minimum contract an Edges renderer should follow.
  19747. */
  19748. export interface IEdgesRenderer extends IDisposable {
  19749. /**
  19750. * Gets or sets a boolean indicating if the edgesRenderer is active
  19751. */
  19752. isEnabled: boolean;
  19753. /**
  19754. * Renders the edges of the attached mesh,
  19755. */
  19756. render(): void;
  19757. /**
  19758. * Checks wether or not the edges renderer is ready to render.
  19759. * @return true if ready, otherwise false.
  19760. */
  19761. isReady(): boolean;
  19762. }
  19763. /**
  19764. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19765. */
  19766. export class EdgesRenderer implements IEdgesRenderer {
  19767. /**
  19768. * Define the size of the edges with an orthographic camera
  19769. */
  19770. edgesWidthScalerForOrthographic: number;
  19771. /**
  19772. * Define the size of the edges with a perspective camera
  19773. */
  19774. edgesWidthScalerForPerspective: number;
  19775. protected _source: AbstractMesh;
  19776. protected _linesPositions: number[];
  19777. protected _linesNormals: number[];
  19778. protected _linesIndices: number[];
  19779. protected _epsilon: number;
  19780. protected _indicesCount: number;
  19781. protected _lineShader: ShaderMaterial;
  19782. protected _ib: DataBuffer;
  19783. protected _buffers: {
  19784. [key: string]: Nullable<VertexBuffer>;
  19785. };
  19786. protected _checkVerticesInsteadOfIndices: boolean;
  19787. private _meshRebuildObserver;
  19788. private _meshDisposeObserver;
  19789. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19790. isEnabled: boolean;
  19791. /**
  19792. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19793. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19794. * @param source Mesh used to create edges
  19795. * @param epsilon sum of angles in adjacency to check for edge
  19796. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19797. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19798. */
  19799. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19800. protected _prepareRessources(): void;
  19801. /** @hidden */
  19802. _rebuild(): void;
  19803. /**
  19804. * Releases the required resources for the edges renderer
  19805. */
  19806. dispose(): void;
  19807. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19808. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19809. /**
  19810. * Checks if the pair of p0 and p1 is en edge
  19811. * @param faceIndex
  19812. * @param edge
  19813. * @param faceNormals
  19814. * @param p0
  19815. * @param p1
  19816. * @private
  19817. */
  19818. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19819. /**
  19820. * push line into the position, normal and index buffer
  19821. * @protected
  19822. */
  19823. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19824. /**
  19825. * Generates lines edges from adjacencjes
  19826. * @private
  19827. */
  19828. _generateEdgesLines(): void;
  19829. /**
  19830. * Checks wether or not the edges renderer is ready to render.
  19831. * @return true if ready, otherwise false.
  19832. */
  19833. isReady(): boolean;
  19834. /**
  19835. * Renders the edges of the attached mesh,
  19836. */
  19837. render(): void;
  19838. }
  19839. /**
  19840. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19841. */
  19842. export class LineEdgesRenderer extends EdgesRenderer {
  19843. /**
  19844. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19845. * @param source LineMesh used to generate edges
  19846. * @param epsilon not important (specified angle for edge detection)
  19847. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19848. */
  19849. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19850. /**
  19851. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19852. */
  19853. _generateEdgesLines(): void;
  19854. }
  19855. }
  19856. declare module "babylonjs/Rendering/renderingGroup" {
  19857. import { SmartArray } from "babylonjs/Misc/smartArray";
  19858. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19860. import { Nullable } from "babylonjs/types";
  19861. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19862. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19863. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19864. import { Material } from "babylonjs/Materials/material";
  19865. import { Scene } from "babylonjs/scene";
  19866. /**
  19867. * This represents the object necessary to create a rendering group.
  19868. * This is exclusively used and created by the rendering manager.
  19869. * To modify the behavior, you use the available helpers in your scene or meshes.
  19870. * @hidden
  19871. */
  19872. export class RenderingGroup {
  19873. index: number;
  19874. private static _zeroVector;
  19875. private _scene;
  19876. private _opaqueSubMeshes;
  19877. private _transparentSubMeshes;
  19878. private _alphaTestSubMeshes;
  19879. private _depthOnlySubMeshes;
  19880. private _particleSystems;
  19881. private _spriteManagers;
  19882. private _opaqueSortCompareFn;
  19883. private _alphaTestSortCompareFn;
  19884. private _transparentSortCompareFn;
  19885. private _renderOpaque;
  19886. private _renderAlphaTest;
  19887. private _renderTransparent;
  19888. /** @hidden */
  19889. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19890. onBeforeTransparentRendering: () => void;
  19891. /**
  19892. * Set the opaque sort comparison function.
  19893. * If null the sub meshes will be render in the order they were created
  19894. */
  19895. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19896. /**
  19897. * Set the alpha test sort comparison function.
  19898. * If null the sub meshes will be render in the order they were created
  19899. */
  19900. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19901. /**
  19902. * Set the transparent sort comparison function.
  19903. * If null the sub meshes will be render in the order they were created
  19904. */
  19905. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19906. /**
  19907. * Creates a new rendering group.
  19908. * @param index The rendering group index
  19909. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19910. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19911. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19912. */
  19913. 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>);
  19914. /**
  19915. * Render all the sub meshes contained in the group.
  19916. * @param customRenderFunction Used to override the default render behaviour of the group.
  19917. * @returns true if rendered some submeshes.
  19918. */
  19919. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19920. /**
  19921. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19922. * @param subMeshes The submeshes to render
  19923. */
  19924. private renderOpaqueSorted;
  19925. /**
  19926. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19927. * @param subMeshes The submeshes to render
  19928. */
  19929. private renderAlphaTestSorted;
  19930. /**
  19931. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19932. * @param subMeshes The submeshes to render
  19933. */
  19934. private renderTransparentSorted;
  19935. /**
  19936. * Renders the submeshes in a specified order.
  19937. * @param subMeshes The submeshes to sort before render
  19938. * @param sortCompareFn The comparison function use to sort
  19939. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19940. * @param transparent Specifies to activate blending if true
  19941. */
  19942. private static renderSorted;
  19943. /**
  19944. * Renders the submeshes in the order they were dispatched (no sort applied).
  19945. * @param subMeshes The submeshes to render
  19946. */
  19947. private static renderUnsorted;
  19948. /**
  19949. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19950. * are rendered back to front if in the same alpha index.
  19951. *
  19952. * @param a The first submesh
  19953. * @param b The second submesh
  19954. * @returns The result of the comparison
  19955. */
  19956. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19957. /**
  19958. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19959. * are rendered back to front.
  19960. *
  19961. * @param a The first submesh
  19962. * @param b The second submesh
  19963. * @returns The result of the comparison
  19964. */
  19965. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19966. /**
  19967. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19968. * are rendered front to back (prevent overdraw).
  19969. *
  19970. * @param a The first submesh
  19971. * @param b The second submesh
  19972. * @returns The result of the comparison
  19973. */
  19974. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19975. /**
  19976. * Resets the different lists of submeshes to prepare a new frame.
  19977. */
  19978. prepare(): void;
  19979. dispose(): void;
  19980. /**
  19981. * Inserts the submesh in its correct queue depending on its material.
  19982. * @param subMesh The submesh to dispatch
  19983. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19984. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19985. */
  19986. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19987. dispatchSprites(spriteManager: ISpriteManager): void;
  19988. dispatchParticles(particleSystem: IParticleSystem): void;
  19989. private _renderParticles;
  19990. private _renderSprites;
  19991. }
  19992. }
  19993. declare module "babylonjs/Rendering/renderingManager" {
  19994. import { Nullable } from "babylonjs/types";
  19995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19997. import { SmartArray } from "babylonjs/Misc/smartArray";
  19998. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19999. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20000. import { Material } from "babylonjs/Materials/material";
  20001. import { Scene } from "babylonjs/scene";
  20002. import { Camera } from "babylonjs/Cameras/camera";
  20003. /**
  20004. * Interface describing the different options available in the rendering manager
  20005. * regarding Auto Clear between groups.
  20006. */
  20007. export interface IRenderingManagerAutoClearSetup {
  20008. /**
  20009. * Defines whether or not autoclear is enable.
  20010. */
  20011. autoClear: boolean;
  20012. /**
  20013. * Defines whether or not to autoclear the depth buffer.
  20014. */
  20015. depth: boolean;
  20016. /**
  20017. * Defines whether or not to autoclear the stencil buffer.
  20018. */
  20019. stencil: boolean;
  20020. }
  20021. /**
  20022. * This class is used by the onRenderingGroupObservable
  20023. */
  20024. export class RenderingGroupInfo {
  20025. /**
  20026. * The Scene that being rendered
  20027. */
  20028. scene: Scene;
  20029. /**
  20030. * The camera currently used for the rendering pass
  20031. */
  20032. camera: Nullable<Camera>;
  20033. /**
  20034. * The ID of the renderingGroup being processed
  20035. */
  20036. renderingGroupId: number;
  20037. }
  20038. /**
  20039. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20040. * It is enable to manage the different groups as well as the different necessary sort functions.
  20041. * This should not be used directly aside of the few static configurations
  20042. */
  20043. export class RenderingManager {
  20044. /**
  20045. * The max id used for rendering groups (not included)
  20046. */
  20047. static MAX_RENDERINGGROUPS: number;
  20048. /**
  20049. * The min id used for rendering groups (included)
  20050. */
  20051. static MIN_RENDERINGGROUPS: number;
  20052. /**
  20053. * Used to globally prevent autoclearing scenes.
  20054. */
  20055. static AUTOCLEAR: boolean;
  20056. /**
  20057. * @hidden
  20058. */
  20059. _useSceneAutoClearSetup: boolean;
  20060. private _scene;
  20061. private _renderingGroups;
  20062. private _depthStencilBufferAlreadyCleaned;
  20063. private _autoClearDepthStencil;
  20064. private _customOpaqueSortCompareFn;
  20065. private _customAlphaTestSortCompareFn;
  20066. private _customTransparentSortCompareFn;
  20067. private _renderingGroupInfo;
  20068. /**
  20069. * Instantiates a new rendering group for a particular scene
  20070. * @param scene Defines the scene the groups belongs to
  20071. */
  20072. constructor(scene: Scene);
  20073. private _clearDepthStencilBuffer;
  20074. /**
  20075. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20076. * @hidden
  20077. */
  20078. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20079. /**
  20080. * Resets the different information of the group to prepare a new frame
  20081. * @hidden
  20082. */
  20083. reset(): void;
  20084. /**
  20085. * Dispose and release the group and its associated resources.
  20086. * @hidden
  20087. */
  20088. dispose(): void;
  20089. /**
  20090. * Clear the info related to rendering groups preventing retention points during dispose.
  20091. */
  20092. freeRenderingGroups(): void;
  20093. private _prepareRenderingGroup;
  20094. /**
  20095. * Add a sprite manager to the rendering manager in order to render it this frame.
  20096. * @param spriteManager Define the sprite manager to render
  20097. */
  20098. dispatchSprites(spriteManager: ISpriteManager): void;
  20099. /**
  20100. * Add a particle system to the rendering manager in order to render it this frame.
  20101. * @param particleSystem Define the particle system to render
  20102. */
  20103. dispatchParticles(particleSystem: IParticleSystem): void;
  20104. /**
  20105. * Add a submesh to the manager in order to render it this frame
  20106. * @param subMesh The submesh to dispatch
  20107. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20108. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20109. */
  20110. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20111. /**
  20112. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20113. * This allowed control for front to back rendering or reversly depending of the special needs.
  20114. *
  20115. * @param renderingGroupId The rendering group id corresponding to its index
  20116. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20117. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20118. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20119. */
  20120. 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;
  20121. /**
  20122. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20123. *
  20124. * @param renderingGroupId The rendering group id corresponding to its index
  20125. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20126. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20127. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20128. */
  20129. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20130. /**
  20131. * Gets the current auto clear configuration for one rendering group of the rendering
  20132. * manager.
  20133. * @param index the rendering group index to get the information for
  20134. * @returns The auto clear setup for the requested rendering group
  20135. */
  20136. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20137. }
  20138. }
  20139. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20140. import { Observable } from "babylonjs/Misc/observable";
  20141. import { SmartArray } from "babylonjs/Misc/smartArray";
  20142. import { Nullable } from "babylonjs/types";
  20143. import { Camera } from "babylonjs/Cameras/camera";
  20144. import { Scene } from "babylonjs/scene";
  20145. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20146. import { Color4 } from "babylonjs/Maths/math.color";
  20147. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20149. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20150. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20151. import { Texture } from "babylonjs/Materials/Textures/texture";
  20152. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20153. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20154. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20155. import { Engine } from "babylonjs/Engines/engine";
  20156. /**
  20157. * This Helps creating a texture that will be created from a camera in your scene.
  20158. * It is basically a dynamic texture that could be used to create special effects for instance.
  20159. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20160. */
  20161. export class RenderTargetTexture extends Texture {
  20162. isCube: boolean;
  20163. /**
  20164. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20165. */
  20166. static readonly REFRESHRATE_RENDER_ONCE: number;
  20167. /**
  20168. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20169. */
  20170. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20171. /**
  20172. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20173. * the central point of your effect and can save a lot of performances.
  20174. */
  20175. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20176. /**
  20177. * Use this predicate to dynamically define the list of mesh you want to render.
  20178. * If set, the renderList property will be overwritten.
  20179. */
  20180. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20181. private _renderList;
  20182. /**
  20183. * Use this list to define the list of mesh you want to render.
  20184. */
  20185. renderList: Nullable<Array<AbstractMesh>>;
  20186. private _hookArray;
  20187. /**
  20188. * Define if particles should be rendered in your texture.
  20189. */
  20190. renderParticles: boolean;
  20191. /**
  20192. * Define if sprites should be rendered in your texture.
  20193. */
  20194. renderSprites: boolean;
  20195. /**
  20196. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20197. */
  20198. coordinatesMode: number;
  20199. /**
  20200. * Define the camera used to render the texture.
  20201. */
  20202. activeCamera: Nullable<Camera>;
  20203. /**
  20204. * Override the render function of the texture with your own one.
  20205. */
  20206. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20207. /**
  20208. * Define if camera post processes should be use while rendering the texture.
  20209. */
  20210. useCameraPostProcesses: boolean;
  20211. /**
  20212. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20213. */
  20214. ignoreCameraViewport: boolean;
  20215. private _postProcessManager;
  20216. private _postProcesses;
  20217. private _resizeObserver;
  20218. /**
  20219. * An event triggered when the texture is unbind.
  20220. */
  20221. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20222. /**
  20223. * An event triggered when the texture is unbind.
  20224. */
  20225. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20226. private _onAfterUnbindObserver;
  20227. /**
  20228. * Set a after unbind callback in the texture.
  20229. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20230. */
  20231. onAfterUnbind: () => void;
  20232. /**
  20233. * An event triggered before rendering the texture
  20234. */
  20235. onBeforeRenderObservable: Observable<number>;
  20236. private _onBeforeRenderObserver;
  20237. /**
  20238. * Set a before render callback in the texture.
  20239. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20240. */
  20241. onBeforeRender: (faceIndex: number) => void;
  20242. /**
  20243. * An event triggered after rendering the texture
  20244. */
  20245. onAfterRenderObservable: Observable<number>;
  20246. private _onAfterRenderObserver;
  20247. /**
  20248. * Set a after render callback in the texture.
  20249. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20250. */
  20251. onAfterRender: (faceIndex: number) => void;
  20252. /**
  20253. * An event triggered after the texture clear
  20254. */
  20255. onClearObservable: Observable<Engine>;
  20256. private _onClearObserver;
  20257. /**
  20258. * Set a clear callback in the texture.
  20259. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20260. */
  20261. onClear: (Engine: Engine) => void;
  20262. /**
  20263. * An event triggered when the texture is resized.
  20264. */
  20265. onResizeObservable: Observable<RenderTargetTexture>;
  20266. /**
  20267. * Define the clear color of the Render Target if it should be different from the scene.
  20268. */
  20269. clearColor: Color4;
  20270. protected _size: number | {
  20271. width: number;
  20272. height: number;
  20273. };
  20274. protected _initialSizeParameter: number | {
  20275. width: number;
  20276. height: number;
  20277. } | {
  20278. ratio: number;
  20279. };
  20280. protected _sizeRatio: Nullable<number>;
  20281. /** @hidden */
  20282. _generateMipMaps: boolean;
  20283. protected _renderingManager: RenderingManager;
  20284. /** @hidden */
  20285. _waitingRenderList: string[];
  20286. protected _doNotChangeAspectRatio: boolean;
  20287. protected _currentRefreshId: number;
  20288. protected _refreshRate: number;
  20289. protected _textureMatrix: Matrix;
  20290. protected _samples: number;
  20291. protected _renderTargetOptions: RenderTargetCreationOptions;
  20292. /**
  20293. * Gets render target creation options that were used.
  20294. */
  20295. readonly renderTargetOptions: RenderTargetCreationOptions;
  20296. protected _engine: Engine;
  20297. protected _onRatioRescale(): void;
  20298. /**
  20299. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20300. * It must define where the camera used to render the texture is set
  20301. */
  20302. boundingBoxPosition: Vector3;
  20303. private _boundingBoxSize;
  20304. /**
  20305. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20306. * When defined, the cubemap will switch to local mode
  20307. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20308. * @example https://www.babylonjs-playground.com/#RNASML
  20309. */
  20310. boundingBoxSize: Vector3;
  20311. /**
  20312. * In case the RTT has been created with a depth texture, get the associated
  20313. * depth texture.
  20314. * Otherwise, return null.
  20315. */
  20316. depthStencilTexture: Nullable<InternalTexture>;
  20317. /**
  20318. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20319. * or used a shadow, depth texture...
  20320. * @param name The friendly name of the texture
  20321. * @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)
  20322. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20323. * @param generateMipMaps True if mip maps need to be generated after render.
  20324. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20325. * @param type The type of the buffer in the RTT (int, half float, float...)
  20326. * @param isCube True if a cube texture needs to be created
  20327. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20328. * @param generateDepthBuffer True to generate a depth buffer
  20329. * @param generateStencilBuffer True to generate a stencil buffer
  20330. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20331. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20332. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20333. */
  20334. constructor(name: string, size: number | {
  20335. width: number;
  20336. height: number;
  20337. } | {
  20338. ratio: number;
  20339. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20340. /**
  20341. * Creates a depth stencil texture.
  20342. * This is only available in WebGL 2 or with the depth texture extension available.
  20343. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20344. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20345. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20346. */
  20347. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20348. private _processSizeParameter;
  20349. /**
  20350. * Define the number of samples to use in case of MSAA.
  20351. * It defaults to one meaning no MSAA has been enabled.
  20352. */
  20353. samples: number;
  20354. /**
  20355. * Resets the refresh counter of the texture and start bak from scratch.
  20356. * Could be useful to regenerate the texture if it is setup to render only once.
  20357. */
  20358. resetRefreshCounter(): void;
  20359. /**
  20360. * Define the refresh rate of the texture or the rendering frequency.
  20361. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20362. */
  20363. refreshRate: number;
  20364. /**
  20365. * Adds a post process to the render target rendering passes.
  20366. * @param postProcess define the post process to add
  20367. */
  20368. addPostProcess(postProcess: PostProcess): void;
  20369. /**
  20370. * Clear all the post processes attached to the render target
  20371. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20372. */
  20373. clearPostProcesses(dispose?: boolean): void;
  20374. /**
  20375. * Remove one of the post process from the list of attached post processes to the texture
  20376. * @param postProcess define the post process to remove from the list
  20377. */
  20378. removePostProcess(postProcess: PostProcess): void;
  20379. /** @hidden */
  20380. _shouldRender(): boolean;
  20381. /**
  20382. * Gets the actual render size of the texture.
  20383. * @returns the width of the render size
  20384. */
  20385. getRenderSize(): number;
  20386. /**
  20387. * Gets the actual render width of the texture.
  20388. * @returns the width of the render size
  20389. */
  20390. getRenderWidth(): number;
  20391. /**
  20392. * Gets the actual render height of the texture.
  20393. * @returns the height of the render size
  20394. */
  20395. getRenderHeight(): number;
  20396. /**
  20397. * Get if the texture can be rescaled or not.
  20398. */
  20399. readonly canRescale: boolean;
  20400. /**
  20401. * Resize the texture using a ratio.
  20402. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20403. */
  20404. scale(ratio: number): void;
  20405. /**
  20406. * Get the texture reflection matrix used to rotate/transform the reflection.
  20407. * @returns the reflection matrix
  20408. */
  20409. getReflectionTextureMatrix(): Matrix;
  20410. /**
  20411. * Resize the texture to a new desired size.
  20412. * Be carrefull as it will recreate all the data in the new texture.
  20413. * @param size Define the new size. It can be:
  20414. * - a number for squared texture,
  20415. * - an object containing { width: number, height: number }
  20416. * - or an object containing a ratio { ratio: number }
  20417. */
  20418. resize(size: number | {
  20419. width: number;
  20420. height: number;
  20421. } | {
  20422. ratio: number;
  20423. }): void;
  20424. /**
  20425. * Renders all the objects from the render list into the texture.
  20426. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20427. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20428. */
  20429. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20430. private _bestReflectionRenderTargetDimension;
  20431. /**
  20432. * @hidden
  20433. * @param faceIndex face index to bind to if this is a cubetexture
  20434. */
  20435. _bindFrameBuffer(faceIndex?: number): void;
  20436. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20437. private renderToTarget;
  20438. /**
  20439. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20440. * This allowed control for front to back rendering or reversly depending of the special needs.
  20441. *
  20442. * @param renderingGroupId The rendering group id corresponding to its index
  20443. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20444. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20445. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20446. */
  20447. 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;
  20448. /**
  20449. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20450. *
  20451. * @param renderingGroupId The rendering group id corresponding to its index
  20452. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20453. */
  20454. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20455. /**
  20456. * Clones the texture.
  20457. * @returns the cloned texture
  20458. */
  20459. clone(): RenderTargetTexture;
  20460. /**
  20461. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20462. * @returns The JSON representation of the texture
  20463. */
  20464. serialize(): any;
  20465. /**
  20466. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20467. */
  20468. disposeFramebufferObjects(): void;
  20469. /**
  20470. * Dispose the texture and release its associated resources.
  20471. */
  20472. dispose(): void;
  20473. /** @hidden */
  20474. _rebuild(): void;
  20475. /**
  20476. * Clear the info related to rendering groups preventing retention point in material dispose.
  20477. */
  20478. freeRenderingGroups(): void;
  20479. /**
  20480. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20481. * @returns the view count
  20482. */
  20483. getViewCount(): number;
  20484. }
  20485. }
  20486. declare module "babylonjs/Materials/material" {
  20487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20488. import { SmartArray } from "babylonjs/Misc/smartArray";
  20489. import { Observable } from "babylonjs/Misc/observable";
  20490. import { Nullable } from "babylonjs/types";
  20491. import { Scene } from "babylonjs/scene";
  20492. import { Matrix } from "babylonjs/Maths/math.vector";
  20493. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20495. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20496. import { Effect } from "babylonjs/Materials/effect";
  20497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20498. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20499. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20500. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20501. import { Mesh } from "babylonjs/Meshes/mesh";
  20502. import { Animation } from "babylonjs/Animations/animation";
  20503. /**
  20504. * Base class for the main features of a material in Babylon.js
  20505. */
  20506. export class Material implements IAnimatable {
  20507. /**
  20508. * Returns the triangle fill mode
  20509. */
  20510. static readonly TriangleFillMode: number;
  20511. /**
  20512. * Returns the wireframe mode
  20513. */
  20514. static readonly WireFrameFillMode: number;
  20515. /**
  20516. * Returns the point fill mode
  20517. */
  20518. static readonly PointFillMode: number;
  20519. /**
  20520. * Returns the point list draw mode
  20521. */
  20522. static readonly PointListDrawMode: number;
  20523. /**
  20524. * Returns the line list draw mode
  20525. */
  20526. static readonly LineListDrawMode: number;
  20527. /**
  20528. * Returns the line loop draw mode
  20529. */
  20530. static readonly LineLoopDrawMode: number;
  20531. /**
  20532. * Returns the line strip draw mode
  20533. */
  20534. static readonly LineStripDrawMode: number;
  20535. /**
  20536. * Returns the triangle strip draw mode
  20537. */
  20538. static readonly TriangleStripDrawMode: number;
  20539. /**
  20540. * Returns the triangle fan draw mode
  20541. */
  20542. static readonly TriangleFanDrawMode: number;
  20543. /**
  20544. * Stores the clock-wise side orientation
  20545. */
  20546. static readonly ClockWiseSideOrientation: number;
  20547. /**
  20548. * Stores the counter clock-wise side orientation
  20549. */
  20550. static readonly CounterClockWiseSideOrientation: number;
  20551. /**
  20552. * The dirty texture flag value
  20553. */
  20554. static readonly TextureDirtyFlag: number;
  20555. /**
  20556. * The dirty light flag value
  20557. */
  20558. static readonly LightDirtyFlag: number;
  20559. /**
  20560. * The dirty fresnel flag value
  20561. */
  20562. static readonly FresnelDirtyFlag: number;
  20563. /**
  20564. * The dirty attribute flag value
  20565. */
  20566. static readonly AttributesDirtyFlag: number;
  20567. /**
  20568. * The dirty misc flag value
  20569. */
  20570. static readonly MiscDirtyFlag: number;
  20571. /**
  20572. * The all dirty flag value
  20573. */
  20574. static readonly AllDirtyFlag: number;
  20575. /**
  20576. * The ID of the material
  20577. */
  20578. id: string;
  20579. /**
  20580. * Gets or sets the unique id of the material
  20581. */
  20582. uniqueId: number;
  20583. /**
  20584. * The name of the material
  20585. */
  20586. name: string;
  20587. /**
  20588. * Gets or sets user defined metadata
  20589. */
  20590. metadata: any;
  20591. /**
  20592. * For internal use only. Please do not use.
  20593. */
  20594. reservedDataStore: any;
  20595. /**
  20596. * Specifies if the ready state should be checked on each call
  20597. */
  20598. checkReadyOnEveryCall: boolean;
  20599. /**
  20600. * Specifies if the ready state should be checked once
  20601. */
  20602. checkReadyOnlyOnce: boolean;
  20603. /**
  20604. * The state of the material
  20605. */
  20606. state: string;
  20607. /**
  20608. * The alpha value of the material
  20609. */
  20610. protected _alpha: number;
  20611. /**
  20612. * List of inspectable custom properties (used by the Inspector)
  20613. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20614. */
  20615. inspectableCustomProperties: IInspectable[];
  20616. /**
  20617. * Sets the alpha value of the material
  20618. */
  20619. /**
  20620. * Gets the alpha value of the material
  20621. */
  20622. alpha: number;
  20623. /**
  20624. * Specifies if back face culling is enabled
  20625. */
  20626. protected _backFaceCulling: boolean;
  20627. /**
  20628. * Sets the back-face culling state
  20629. */
  20630. /**
  20631. * Gets the back-face culling state
  20632. */
  20633. backFaceCulling: boolean;
  20634. /**
  20635. * Stores the value for side orientation
  20636. */
  20637. sideOrientation: number;
  20638. /**
  20639. * Callback triggered when the material is compiled
  20640. */
  20641. onCompiled: Nullable<(effect: Effect) => void>;
  20642. /**
  20643. * Callback triggered when an error occurs
  20644. */
  20645. onError: Nullable<(effect: Effect, errors: string) => void>;
  20646. /**
  20647. * Callback triggered to get the render target textures
  20648. */
  20649. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20650. /**
  20651. * Gets a boolean indicating that current material needs to register RTT
  20652. */
  20653. readonly hasRenderTargetTextures: boolean;
  20654. /**
  20655. * Specifies if the material should be serialized
  20656. */
  20657. doNotSerialize: boolean;
  20658. /**
  20659. * @hidden
  20660. */
  20661. _storeEffectOnSubMeshes: boolean;
  20662. /**
  20663. * Stores the animations for the material
  20664. */
  20665. animations: Nullable<Array<Animation>>;
  20666. /**
  20667. * An event triggered when the material is disposed
  20668. */
  20669. onDisposeObservable: Observable<Material>;
  20670. /**
  20671. * An observer which watches for dispose events
  20672. */
  20673. private _onDisposeObserver;
  20674. private _onUnBindObservable;
  20675. /**
  20676. * Called during a dispose event
  20677. */
  20678. onDispose: () => void;
  20679. private _onBindObservable;
  20680. /**
  20681. * An event triggered when the material is bound
  20682. */
  20683. readonly onBindObservable: Observable<AbstractMesh>;
  20684. /**
  20685. * An observer which watches for bind events
  20686. */
  20687. private _onBindObserver;
  20688. /**
  20689. * Called during a bind event
  20690. */
  20691. onBind: (Mesh: AbstractMesh) => void;
  20692. /**
  20693. * An event triggered when the material is unbound
  20694. */
  20695. readonly onUnBindObservable: Observable<Material>;
  20696. /**
  20697. * Stores the value of the alpha mode
  20698. */
  20699. private _alphaMode;
  20700. /**
  20701. * Sets the value of the alpha mode.
  20702. *
  20703. * | Value | Type | Description |
  20704. * | --- | --- | --- |
  20705. * | 0 | ALPHA_DISABLE | |
  20706. * | 1 | ALPHA_ADD | |
  20707. * | 2 | ALPHA_COMBINE | |
  20708. * | 3 | ALPHA_SUBTRACT | |
  20709. * | 4 | ALPHA_MULTIPLY | |
  20710. * | 5 | ALPHA_MAXIMIZED | |
  20711. * | 6 | ALPHA_ONEONE | |
  20712. * | 7 | ALPHA_PREMULTIPLIED | |
  20713. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20714. * | 9 | ALPHA_INTERPOLATE | |
  20715. * | 10 | ALPHA_SCREENMODE | |
  20716. *
  20717. */
  20718. /**
  20719. * Gets the value of the alpha mode
  20720. */
  20721. alphaMode: number;
  20722. /**
  20723. * Stores the state of the need depth pre-pass value
  20724. */
  20725. private _needDepthPrePass;
  20726. /**
  20727. * Sets the need depth pre-pass value
  20728. */
  20729. /**
  20730. * Gets the depth pre-pass value
  20731. */
  20732. needDepthPrePass: boolean;
  20733. /**
  20734. * Specifies if depth writing should be disabled
  20735. */
  20736. disableDepthWrite: boolean;
  20737. /**
  20738. * Specifies if depth writing should be forced
  20739. */
  20740. forceDepthWrite: boolean;
  20741. /**
  20742. * Specifies if there should be a separate pass for culling
  20743. */
  20744. separateCullingPass: boolean;
  20745. /**
  20746. * Stores the state specifing if fog should be enabled
  20747. */
  20748. private _fogEnabled;
  20749. /**
  20750. * Sets the state for enabling fog
  20751. */
  20752. /**
  20753. * Gets the value of the fog enabled state
  20754. */
  20755. fogEnabled: boolean;
  20756. /**
  20757. * Stores the size of points
  20758. */
  20759. pointSize: number;
  20760. /**
  20761. * Stores the z offset value
  20762. */
  20763. zOffset: number;
  20764. /**
  20765. * Gets a value specifying if wireframe mode is enabled
  20766. */
  20767. /**
  20768. * Sets the state of wireframe mode
  20769. */
  20770. wireframe: boolean;
  20771. /**
  20772. * Gets the value specifying if point clouds are enabled
  20773. */
  20774. /**
  20775. * Sets the state of point cloud mode
  20776. */
  20777. pointsCloud: boolean;
  20778. /**
  20779. * Gets the material fill mode
  20780. */
  20781. /**
  20782. * Sets the material fill mode
  20783. */
  20784. fillMode: number;
  20785. /**
  20786. * @hidden
  20787. * Stores the effects for the material
  20788. */
  20789. _effect: Nullable<Effect>;
  20790. /**
  20791. * @hidden
  20792. * Specifies if the material was previously ready
  20793. */
  20794. _wasPreviouslyReady: boolean;
  20795. /**
  20796. * Specifies if uniform buffers should be used
  20797. */
  20798. private _useUBO;
  20799. /**
  20800. * Stores a reference to the scene
  20801. */
  20802. private _scene;
  20803. /**
  20804. * Stores the fill mode state
  20805. */
  20806. private _fillMode;
  20807. /**
  20808. * Specifies if the depth write state should be cached
  20809. */
  20810. private _cachedDepthWriteState;
  20811. /**
  20812. * Stores the uniform buffer
  20813. */
  20814. protected _uniformBuffer: UniformBuffer;
  20815. /** @hidden */
  20816. _indexInSceneMaterialArray: number;
  20817. /** @hidden */
  20818. meshMap: Nullable<{
  20819. [id: string]: AbstractMesh | undefined;
  20820. }>;
  20821. /**
  20822. * Creates a material instance
  20823. * @param name defines the name of the material
  20824. * @param scene defines the scene to reference
  20825. * @param doNotAdd specifies if the material should be added to the scene
  20826. */
  20827. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20828. /**
  20829. * Returns a string representation of the current material
  20830. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20831. * @returns a string with material information
  20832. */
  20833. toString(fullDetails?: boolean): string;
  20834. /**
  20835. * Gets the class name of the material
  20836. * @returns a string with the class name of the material
  20837. */
  20838. getClassName(): string;
  20839. /**
  20840. * Specifies if updates for the material been locked
  20841. */
  20842. readonly isFrozen: boolean;
  20843. /**
  20844. * Locks updates for the material
  20845. */
  20846. freeze(): void;
  20847. /**
  20848. * Unlocks updates for the material
  20849. */
  20850. unfreeze(): void;
  20851. /**
  20852. * Specifies if the material is ready to be used
  20853. * @param mesh defines the mesh to check
  20854. * @param useInstances specifies if instances should be used
  20855. * @returns a boolean indicating if the material is ready to be used
  20856. */
  20857. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20858. /**
  20859. * Specifies that the submesh is ready to be used
  20860. * @param mesh defines the mesh to check
  20861. * @param subMesh defines which submesh to check
  20862. * @param useInstances specifies that instances should be used
  20863. * @returns a boolean indicating that the submesh is ready or not
  20864. */
  20865. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20866. /**
  20867. * Returns the material effect
  20868. * @returns the effect associated with the material
  20869. */
  20870. getEffect(): Nullable<Effect>;
  20871. /**
  20872. * Returns the current scene
  20873. * @returns a Scene
  20874. */
  20875. getScene(): Scene;
  20876. /**
  20877. * Specifies if the material will require alpha blending
  20878. * @returns a boolean specifying if alpha blending is needed
  20879. */
  20880. needAlphaBlending(): boolean;
  20881. /**
  20882. * Specifies if the mesh will require alpha blending
  20883. * @param mesh defines the mesh to check
  20884. * @returns a boolean specifying if alpha blending is needed for the mesh
  20885. */
  20886. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20887. /**
  20888. * Specifies if this material should be rendered in alpha test mode
  20889. * @returns a boolean specifying if an alpha test is needed.
  20890. */
  20891. needAlphaTesting(): boolean;
  20892. /**
  20893. * Gets the texture used for the alpha test
  20894. * @returns the texture to use for alpha testing
  20895. */
  20896. getAlphaTestTexture(): Nullable<BaseTexture>;
  20897. /**
  20898. * Marks the material to indicate that it needs to be re-calculated
  20899. */
  20900. markDirty(): void;
  20901. /** @hidden */
  20902. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20903. /**
  20904. * Binds the material to the mesh
  20905. * @param world defines the world transformation matrix
  20906. * @param mesh defines the mesh to bind the material to
  20907. */
  20908. bind(world: Matrix, mesh?: Mesh): void;
  20909. /**
  20910. * Binds the submesh to the material
  20911. * @param world defines the world transformation matrix
  20912. * @param mesh defines the mesh containing the submesh
  20913. * @param subMesh defines the submesh to bind the material to
  20914. */
  20915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20916. /**
  20917. * Binds the world matrix to the material
  20918. * @param world defines the world transformation matrix
  20919. */
  20920. bindOnlyWorldMatrix(world: Matrix): void;
  20921. /**
  20922. * Binds the scene's uniform buffer to the effect.
  20923. * @param effect defines the effect to bind to the scene uniform buffer
  20924. * @param sceneUbo defines the uniform buffer storing scene data
  20925. */
  20926. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20927. /**
  20928. * Binds the view matrix to the effect
  20929. * @param effect defines the effect to bind the view matrix to
  20930. */
  20931. bindView(effect: Effect): void;
  20932. /**
  20933. * Binds the view projection matrix to the effect
  20934. * @param effect defines the effect to bind the view projection matrix to
  20935. */
  20936. bindViewProjection(effect: Effect): void;
  20937. /**
  20938. * Specifies if material alpha testing should be turned on for the mesh
  20939. * @param mesh defines the mesh to check
  20940. */
  20941. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20942. /**
  20943. * Processes to execute after binding the material to a mesh
  20944. * @param mesh defines the rendered mesh
  20945. */
  20946. protected _afterBind(mesh?: Mesh): void;
  20947. /**
  20948. * Unbinds the material from the mesh
  20949. */
  20950. unbind(): void;
  20951. /**
  20952. * Gets the active textures from the material
  20953. * @returns an array of textures
  20954. */
  20955. getActiveTextures(): BaseTexture[];
  20956. /**
  20957. * Specifies if the material uses a texture
  20958. * @param texture defines the texture to check against the material
  20959. * @returns a boolean specifying if the material uses the texture
  20960. */
  20961. hasTexture(texture: BaseTexture): boolean;
  20962. /**
  20963. * Makes a duplicate of the material, and gives it a new name
  20964. * @param name defines the new name for the duplicated material
  20965. * @returns the cloned material
  20966. */
  20967. clone(name: string): Nullable<Material>;
  20968. /**
  20969. * Gets the meshes bound to the material
  20970. * @returns an array of meshes bound to the material
  20971. */
  20972. getBindedMeshes(): AbstractMesh[];
  20973. /**
  20974. * Force shader compilation
  20975. * @param mesh defines the mesh associated with this material
  20976. * @param onCompiled defines a function to execute once the material is compiled
  20977. * @param options defines the options to configure the compilation
  20978. */
  20979. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20980. clipPlane: boolean;
  20981. }>): void;
  20982. /**
  20983. * Force shader compilation
  20984. * @param mesh defines the mesh that will use this material
  20985. * @param options defines additional options for compiling the shaders
  20986. * @returns a promise that resolves when the compilation completes
  20987. */
  20988. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20989. clipPlane: boolean;
  20990. }>): Promise<void>;
  20991. private static readonly _AllDirtyCallBack;
  20992. private static readonly _ImageProcessingDirtyCallBack;
  20993. private static readonly _TextureDirtyCallBack;
  20994. private static readonly _FresnelDirtyCallBack;
  20995. private static readonly _MiscDirtyCallBack;
  20996. private static readonly _LightsDirtyCallBack;
  20997. private static readonly _AttributeDirtyCallBack;
  20998. private static _FresnelAndMiscDirtyCallBack;
  20999. private static _TextureAndMiscDirtyCallBack;
  21000. private static readonly _DirtyCallbackArray;
  21001. private static readonly _RunDirtyCallBacks;
  21002. /**
  21003. * Marks a define in the material to indicate that it needs to be re-computed
  21004. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21005. */
  21006. markAsDirty(flag: number): void;
  21007. /**
  21008. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21009. * @param func defines a function which checks material defines against the submeshes
  21010. */
  21011. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21012. /**
  21013. * Indicates that we need to re-calculated for all submeshes
  21014. */
  21015. protected _markAllSubMeshesAsAllDirty(): void;
  21016. /**
  21017. * Indicates that image processing needs to be re-calculated for all submeshes
  21018. */
  21019. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21020. /**
  21021. * Indicates that textures need to be re-calculated for all submeshes
  21022. */
  21023. protected _markAllSubMeshesAsTexturesDirty(): void;
  21024. /**
  21025. * Indicates that fresnel needs to be re-calculated for all submeshes
  21026. */
  21027. protected _markAllSubMeshesAsFresnelDirty(): void;
  21028. /**
  21029. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21030. */
  21031. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21032. /**
  21033. * Indicates that lights need to be re-calculated for all submeshes
  21034. */
  21035. protected _markAllSubMeshesAsLightsDirty(): void;
  21036. /**
  21037. * Indicates that attributes need to be re-calculated for all submeshes
  21038. */
  21039. protected _markAllSubMeshesAsAttributesDirty(): void;
  21040. /**
  21041. * Indicates that misc needs to be re-calculated for all submeshes
  21042. */
  21043. protected _markAllSubMeshesAsMiscDirty(): void;
  21044. /**
  21045. * Indicates that textures and misc need to be re-calculated for all submeshes
  21046. */
  21047. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21048. /**
  21049. * Disposes the material
  21050. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21051. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21052. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21053. */
  21054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21055. /** @hidden */
  21056. private releaseVertexArrayObject;
  21057. /**
  21058. * Serializes this material
  21059. * @returns the serialized material object
  21060. */
  21061. serialize(): any;
  21062. /**
  21063. * Creates a material from parsed material data
  21064. * @param parsedMaterial defines parsed material data
  21065. * @param scene defines the hosting scene
  21066. * @param rootUrl defines the root URL to use to load textures
  21067. * @returns a new material
  21068. */
  21069. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21070. }
  21071. }
  21072. declare module "babylonjs/Materials/multiMaterial" {
  21073. import { Nullable } from "babylonjs/types";
  21074. import { Scene } from "babylonjs/scene";
  21075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21076. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21077. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21078. import { Material } from "babylonjs/Materials/material";
  21079. /**
  21080. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21081. * separate meshes. This can be use to improve performances.
  21082. * @see http://doc.babylonjs.com/how_to/multi_materials
  21083. */
  21084. export class MultiMaterial extends Material {
  21085. private _subMaterials;
  21086. /**
  21087. * Gets or Sets the list of Materials used within the multi material.
  21088. * They need to be ordered according to the submeshes order in the associated mesh
  21089. */
  21090. subMaterials: Nullable<Material>[];
  21091. /**
  21092. * Function used to align with Node.getChildren()
  21093. * @returns the list of Materials used within the multi material
  21094. */
  21095. getChildren(): Nullable<Material>[];
  21096. /**
  21097. * Instantiates a new Multi Material
  21098. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21099. * separate meshes. This can be use to improve performances.
  21100. * @see http://doc.babylonjs.com/how_to/multi_materials
  21101. * @param name Define the name in the scene
  21102. * @param scene Define the scene the material belongs to
  21103. */
  21104. constructor(name: string, scene: Scene);
  21105. private _hookArray;
  21106. /**
  21107. * Get one of the submaterial by its index in the submaterials array
  21108. * @param index The index to look the sub material at
  21109. * @returns The Material if the index has been defined
  21110. */
  21111. getSubMaterial(index: number): Nullable<Material>;
  21112. /**
  21113. * Get the list of active textures for the whole sub materials list.
  21114. * @returns All the textures that will be used during the rendering
  21115. */
  21116. getActiveTextures(): BaseTexture[];
  21117. /**
  21118. * Gets the current class name of the material e.g. "MultiMaterial"
  21119. * Mainly use in serialization.
  21120. * @returns the class name
  21121. */
  21122. getClassName(): string;
  21123. /**
  21124. * Checks if the material is ready to render the requested sub mesh
  21125. * @param mesh Define the mesh the submesh belongs to
  21126. * @param subMesh Define the sub mesh to look readyness for
  21127. * @param useInstances Define whether or not the material is used with instances
  21128. * @returns true if ready, otherwise false
  21129. */
  21130. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21131. /**
  21132. * Clones the current material and its related sub materials
  21133. * @param name Define the name of the newly cloned material
  21134. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21135. * @returns the cloned material
  21136. */
  21137. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21138. /**
  21139. * Serializes the materials into a JSON representation.
  21140. * @returns the JSON representation
  21141. */
  21142. serialize(): any;
  21143. /**
  21144. * Dispose the material and release its associated resources
  21145. * @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)
  21146. * @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)
  21147. * @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)
  21148. */
  21149. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21150. /**
  21151. * Creates a MultiMaterial from parsed MultiMaterial data.
  21152. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21153. * @param scene defines the hosting scene
  21154. * @returns a new MultiMaterial
  21155. */
  21156. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21157. }
  21158. }
  21159. declare module "babylonjs/Meshes/subMesh" {
  21160. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21161. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21162. import { Engine } from "babylonjs/Engines/engine";
  21163. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21164. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21165. import { Effect } from "babylonjs/Materials/effect";
  21166. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21167. import { Plane } from "babylonjs/Maths/math.plane";
  21168. import { Collider } from "babylonjs/Collisions/collider";
  21169. import { Material } from "babylonjs/Materials/material";
  21170. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21172. import { Mesh } from "babylonjs/Meshes/mesh";
  21173. import { Ray } from "babylonjs/Culling/ray";
  21174. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21175. /**
  21176. * Base class for submeshes
  21177. */
  21178. export class BaseSubMesh {
  21179. /** @hidden */
  21180. _materialDefines: Nullable<MaterialDefines>;
  21181. /** @hidden */
  21182. _materialEffect: Nullable<Effect>;
  21183. /**
  21184. * Gets associated effect
  21185. */
  21186. readonly effect: Nullable<Effect>;
  21187. /**
  21188. * Sets associated effect (effect used to render this submesh)
  21189. * @param effect defines the effect to associate with
  21190. * @param defines defines the set of defines used to compile this effect
  21191. */
  21192. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21193. }
  21194. /**
  21195. * Defines a subdivision inside a mesh
  21196. */
  21197. export class SubMesh extends BaseSubMesh implements ICullable {
  21198. /** the material index to use */
  21199. materialIndex: number;
  21200. /** vertex index start */
  21201. verticesStart: number;
  21202. /** vertices count */
  21203. verticesCount: number;
  21204. /** index start */
  21205. indexStart: number;
  21206. /** indices count */
  21207. indexCount: number;
  21208. /** @hidden */
  21209. _linesIndexCount: number;
  21210. private _mesh;
  21211. private _renderingMesh;
  21212. private _boundingInfo;
  21213. private _linesIndexBuffer;
  21214. /** @hidden */
  21215. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21216. /** @hidden */
  21217. _trianglePlanes: Plane[];
  21218. /** @hidden */
  21219. _lastColliderTransformMatrix: Nullable<Matrix>;
  21220. /** @hidden */
  21221. _renderId: number;
  21222. /** @hidden */
  21223. _alphaIndex: number;
  21224. /** @hidden */
  21225. _distanceToCamera: number;
  21226. /** @hidden */
  21227. _id: number;
  21228. private _currentMaterial;
  21229. /**
  21230. * Add a new submesh to a mesh
  21231. * @param materialIndex defines the material index to use
  21232. * @param verticesStart defines vertex index start
  21233. * @param verticesCount defines vertices count
  21234. * @param indexStart defines index start
  21235. * @param indexCount defines indices count
  21236. * @param mesh defines the parent mesh
  21237. * @param renderingMesh defines an optional rendering mesh
  21238. * @param createBoundingBox defines if bounding box should be created for this submesh
  21239. * @returns the new submesh
  21240. */
  21241. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21242. /**
  21243. * Creates a new submesh
  21244. * @param materialIndex defines the material index to use
  21245. * @param verticesStart defines vertex index start
  21246. * @param verticesCount defines vertices count
  21247. * @param indexStart defines index start
  21248. * @param indexCount defines indices count
  21249. * @param mesh defines the parent mesh
  21250. * @param renderingMesh defines an optional rendering mesh
  21251. * @param createBoundingBox defines if bounding box should be created for this submesh
  21252. */
  21253. constructor(
  21254. /** the material index to use */
  21255. materialIndex: number,
  21256. /** vertex index start */
  21257. verticesStart: number,
  21258. /** vertices count */
  21259. verticesCount: number,
  21260. /** index start */
  21261. indexStart: number,
  21262. /** indices count */
  21263. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21264. /**
  21265. * Returns true if this submesh covers the entire parent mesh
  21266. * @ignorenaming
  21267. */
  21268. readonly IsGlobal: boolean;
  21269. /**
  21270. * Returns the submesh BoudingInfo object
  21271. * @returns current bounding info (or mesh's one if the submesh is global)
  21272. */
  21273. getBoundingInfo(): BoundingInfo;
  21274. /**
  21275. * Sets the submesh BoundingInfo
  21276. * @param boundingInfo defines the new bounding info to use
  21277. * @returns the SubMesh
  21278. */
  21279. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21280. /**
  21281. * Returns the mesh of the current submesh
  21282. * @return the parent mesh
  21283. */
  21284. getMesh(): AbstractMesh;
  21285. /**
  21286. * Returns the rendering mesh of the submesh
  21287. * @returns the rendering mesh (could be different from parent mesh)
  21288. */
  21289. getRenderingMesh(): Mesh;
  21290. /**
  21291. * Returns the submesh material
  21292. * @returns null or the current material
  21293. */
  21294. getMaterial(): Nullable<Material>;
  21295. /**
  21296. * Sets a new updated BoundingInfo object to the submesh
  21297. * @param data defines an optional position array to use to determine the bounding info
  21298. * @returns the SubMesh
  21299. */
  21300. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21301. /** @hidden */
  21302. _checkCollision(collider: Collider): boolean;
  21303. /**
  21304. * Updates the submesh BoundingInfo
  21305. * @param world defines the world matrix to use to update the bounding info
  21306. * @returns the submesh
  21307. */
  21308. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21309. /**
  21310. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21311. * @param frustumPlanes defines the frustum planes
  21312. * @returns true if the submesh is intersecting with the frustum
  21313. */
  21314. isInFrustum(frustumPlanes: Plane[]): boolean;
  21315. /**
  21316. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21317. * @param frustumPlanes defines the frustum planes
  21318. * @returns true if the submesh is inside the frustum
  21319. */
  21320. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21321. /**
  21322. * Renders the submesh
  21323. * @param enableAlphaMode defines if alpha needs to be used
  21324. * @returns the submesh
  21325. */
  21326. render(enableAlphaMode: boolean): SubMesh;
  21327. /**
  21328. * @hidden
  21329. */
  21330. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21331. /**
  21332. * Checks if the submesh intersects with a ray
  21333. * @param ray defines the ray to test
  21334. * @returns true is the passed ray intersects the submesh bounding box
  21335. */
  21336. canIntersects(ray: Ray): boolean;
  21337. /**
  21338. * Intersects current submesh with a ray
  21339. * @param ray defines the ray to test
  21340. * @param positions defines mesh's positions array
  21341. * @param indices defines mesh's indices array
  21342. * @param fastCheck defines if only bounding info should be used
  21343. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21344. * @returns intersection info or null if no intersection
  21345. */
  21346. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21347. /** @hidden */
  21348. private _intersectLines;
  21349. /** @hidden */
  21350. private _intersectUnIndexedLines;
  21351. /** @hidden */
  21352. private _intersectTriangles;
  21353. /** @hidden */
  21354. private _intersectUnIndexedTriangles;
  21355. /** @hidden */
  21356. _rebuild(): void;
  21357. /**
  21358. * Creates a new submesh from the passed mesh
  21359. * @param newMesh defines the new hosting mesh
  21360. * @param newRenderingMesh defines an optional rendering mesh
  21361. * @returns the new submesh
  21362. */
  21363. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21364. /**
  21365. * Release associated resources
  21366. */
  21367. dispose(): void;
  21368. /**
  21369. * Gets the class name
  21370. * @returns the string "SubMesh".
  21371. */
  21372. getClassName(): string;
  21373. /**
  21374. * Creates a new submesh from indices data
  21375. * @param materialIndex the index of the main mesh material
  21376. * @param startIndex the index where to start the copy in the mesh indices array
  21377. * @param indexCount the number of indices to copy then from the startIndex
  21378. * @param mesh the main mesh to create the submesh from
  21379. * @param renderingMesh the optional rendering mesh
  21380. * @returns a new submesh
  21381. */
  21382. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21383. }
  21384. }
  21385. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21386. /**
  21387. * Class used to represent data loading progression
  21388. */
  21389. export class SceneLoaderFlags {
  21390. private static _ForceFullSceneLoadingForIncremental;
  21391. private static _ShowLoadingScreen;
  21392. private static _CleanBoneMatrixWeights;
  21393. private static _loggingLevel;
  21394. /**
  21395. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21396. */
  21397. static ForceFullSceneLoadingForIncremental: boolean;
  21398. /**
  21399. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21400. */
  21401. static ShowLoadingScreen: boolean;
  21402. /**
  21403. * Defines the current logging level (while loading the scene)
  21404. * @ignorenaming
  21405. */
  21406. static loggingLevel: number;
  21407. /**
  21408. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21409. */
  21410. static CleanBoneMatrixWeights: boolean;
  21411. }
  21412. }
  21413. declare module "babylonjs/Meshes/geometry" {
  21414. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21415. import { Scene } from "babylonjs/scene";
  21416. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21417. import { Engine } from "babylonjs/Engines/engine";
  21418. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21419. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21420. import { Effect } from "babylonjs/Materials/effect";
  21421. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21422. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21423. import { Mesh } from "babylonjs/Meshes/mesh";
  21424. /**
  21425. * Class used to store geometry data (vertex buffers + index buffer)
  21426. */
  21427. export class Geometry implements IGetSetVerticesData {
  21428. /**
  21429. * Gets or sets the ID of the geometry
  21430. */
  21431. id: string;
  21432. /**
  21433. * Gets or sets the unique ID of the geometry
  21434. */
  21435. uniqueId: number;
  21436. /**
  21437. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21438. */
  21439. delayLoadState: number;
  21440. /**
  21441. * Gets the file containing the data to load when running in delay load state
  21442. */
  21443. delayLoadingFile: Nullable<string>;
  21444. /**
  21445. * Callback called when the geometry is updated
  21446. */
  21447. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21448. private _scene;
  21449. private _engine;
  21450. private _meshes;
  21451. private _totalVertices;
  21452. /** @hidden */
  21453. _indices: IndicesArray;
  21454. /** @hidden */
  21455. _vertexBuffers: {
  21456. [key: string]: VertexBuffer;
  21457. };
  21458. private _isDisposed;
  21459. private _extend;
  21460. private _boundingBias;
  21461. /** @hidden */
  21462. _delayInfo: Array<string>;
  21463. private _indexBuffer;
  21464. private _indexBufferIsUpdatable;
  21465. /** @hidden */
  21466. _boundingInfo: Nullable<BoundingInfo>;
  21467. /** @hidden */
  21468. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21469. /** @hidden */
  21470. _softwareSkinningFrameId: number;
  21471. private _vertexArrayObjects;
  21472. private _updatable;
  21473. /** @hidden */
  21474. _positions: Nullable<Vector3[]>;
  21475. /**
  21476. * 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
  21477. */
  21478. /**
  21479. * 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
  21480. */
  21481. boundingBias: Vector2;
  21482. /**
  21483. * Static function used to attach a new empty geometry to a mesh
  21484. * @param mesh defines the mesh to attach the geometry to
  21485. * @returns the new Geometry
  21486. */
  21487. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21488. /**
  21489. * Creates a new geometry
  21490. * @param id defines the unique ID
  21491. * @param scene defines the hosting scene
  21492. * @param vertexData defines the VertexData used to get geometry data
  21493. * @param updatable defines if geometry must be updatable (false by default)
  21494. * @param mesh defines the mesh that will be associated with the geometry
  21495. */
  21496. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21497. /**
  21498. * Gets the current extend of the geometry
  21499. */
  21500. readonly extend: {
  21501. minimum: Vector3;
  21502. maximum: Vector3;
  21503. };
  21504. /**
  21505. * Gets the hosting scene
  21506. * @returns the hosting Scene
  21507. */
  21508. getScene(): Scene;
  21509. /**
  21510. * Gets the hosting engine
  21511. * @returns the hosting Engine
  21512. */
  21513. getEngine(): Engine;
  21514. /**
  21515. * Defines if the geometry is ready to use
  21516. * @returns true if the geometry is ready to be used
  21517. */
  21518. isReady(): boolean;
  21519. /**
  21520. * Gets a value indicating that the geometry should not be serialized
  21521. */
  21522. readonly doNotSerialize: boolean;
  21523. /** @hidden */
  21524. _rebuild(): void;
  21525. /**
  21526. * Affects all geometry data in one call
  21527. * @param vertexData defines the geometry data
  21528. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21529. */
  21530. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21531. /**
  21532. * Set specific vertex data
  21533. * @param kind defines the data kind (Position, normal, etc...)
  21534. * @param data defines the vertex data to use
  21535. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21536. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21537. */
  21538. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21539. /**
  21540. * Removes a specific vertex data
  21541. * @param kind defines the data kind (Position, normal, etc...)
  21542. */
  21543. removeVerticesData(kind: string): void;
  21544. /**
  21545. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21546. * @param buffer defines the vertex buffer to use
  21547. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21548. */
  21549. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21550. /**
  21551. * Update a specific vertex buffer
  21552. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21553. * It will do nothing if the buffer is not updatable
  21554. * @param kind defines the data kind (Position, normal, etc...)
  21555. * @param data defines the data to use
  21556. * @param offset defines the offset in the target buffer where to store the data
  21557. * @param useBytes set to true if the offset is in bytes
  21558. */
  21559. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21560. /**
  21561. * Update a specific vertex buffer
  21562. * This function will create a new buffer if the current one is not updatable
  21563. * @param kind defines the data kind (Position, normal, etc...)
  21564. * @param data defines the data to use
  21565. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21566. */
  21567. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21568. private _updateBoundingInfo;
  21569. /** @hidden */
  21570. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21571. /**
  21572. * Gets total number of vertices
  21573. * @returns the total number of vertices
  21574. */
  21575. getTotalVertices(): number;
  21576. /**
  21577. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21578. * @param kind defines the data kind (Position, normal, etc...)
  21579. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21580. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21581. * @returns a float array containing vertex data
  21582. */
  21583. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21584. /**
  21585. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21586. * @param kind defines the data kind (Position, normal, etc...)
  21587. * @returns true if the vertex buffer with the specified kind is updatable
  21588. */
  21589. isVertexBufferUpdatable(kind: string): boolean;
  21590. /**
  21591. * Gets a specific vertex buffer
  21592. * @param kind defines the data kind (Position, normal, etc...)
  21593. * @returns a VertexBuffer
  21594. */
  21595. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21596. /**
  21597. * Returns all vertex buffers
  21598. * @return an object holding all vertex buffers indexed by kind
  21599. */
  21600. getVertexBuffers(): Nullable<{
  21601. [key: string]: VertexBuffer;
  21602. }>;
  21603. /**
  21604. * Gets a boolean indicating if specific vertex buffer is present
  21605. * @param kind defines the data kind (Position, normal, etc...)
  21606. * @returns true if data is present
  21607. */
  21608. isVerticesDataPresent(kind: string): boolean;
  21609. /**
  21610. * Gets a list of all attached data kinds (Position, normal, etc...)
  21611. * @returns a list of string containing all kinds
  21612. */
  21613. getVerticesDataKinds(): string[];
  21614. /**
  21615. * Update index buffer
  21616. * @param indices defines the indices to store in the index buffer
  21617. * @param offset defines the offset in the target buffer where to store the data
  21618. * @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)
  21619. */
  21620. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21621. /**
  21622. * Creates a new index buffer
  21623. * @param indices defines the indices to store in the index buffer
  21624. * @param totalVertices defines the total number of vertices (could be null)
  21625. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21626. */
  21627. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21628. /**
  21629. * Return the total number of indices
  21630. * @returns the total number of indices
  21631. */
  21632. getTotalIndices(): number;
  21633. /**
  21634. * Gets the index buffer array
  21635. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21636. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21637. * @returns the index buffer array
  21638. */
  21639. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21640. /**
  21641. * Gets the index buffer
  21642. * @return the index buffer
  21643. */
  21644. getIndexBuffer(): Nullable<DataBuffer>;
  21645. /** @hidden */
  21646. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21647. /**
  21648. * Release the associated resources for a specific mesh
  21649. * @param mesh defines the source mesh
  21650. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21651. */
  21652. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21653. /**
  21654. * Apply current geometry to a given mesh
  21655. * @param mesh defines the mesh to apply geometry to
  21656. */
  21657. applyToMesh(mesh: Mesh): void;
  21658. private _updateExtend;
  21659. private _applyToMesh;
  21660. private notifyUpdate;
  21661. /**
  21662. * Load the geometry if it was flagged as delay loaded
  21663. * @param scene defines the hosting scene
  21664. * @param onLoaded defines a callback called when the geometry is loaded
  21665. */
  21666. load(scene: Scene, onLoaded?: () => void): void;
  21667. private _queueLoad;
  21668. /**
  21669. * Invert the geometry to move from a right handed system to a left handed one.
  21670. */
  21671. toLeftHanded(): void;
  21672. /** @hidden */
  21673. _resetPointsArrayCache(): void;
  21674. /** @hidden */
  21675. _generatePointsArray(): boolean;
  21676. /**
  21677. * Gets a value indicating if the geometry is disposed
  21678. * @returns true if the geometry was disposed
  21679. */
  21680. isDisposed(): boolean;
  21681. private _disposeVertexArrayObjects;
  21682. /**
  21683. * Free all associated resources
  21684. */
  21685. dispose(): void;
  21686. /**
  21687. * Clone the current geometry into a new geometry
  21688. * @param id defines the unique ID of the new geometry
  21689. * @returns a new geometry object
  21690. */
  21691. copy(id: string): Geometry;
  21692. /**
  21693. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21694. * @return a JSON representation of the current geometry data (without the vertices data)
  21695. */
  21696. serialize(): any;
  21697. private toNumberArray;
  21698. /**
  21699. * Serialize all vertices data into a JSON oject
  21700. * @returns a JSON representation of the current geometry data
  21701. */
  21702. serializeVerticeData(): any;
  21703. /**
  21704. * Extracts a clone of a mesh geometry
  21705. * @param mesh defines the source mesh
  21706. * @param id defines the unique ID of the new geometry object
  21707. * @returns the new geometry object
  21708. */
  21709. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21710. /**
  21711. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21712. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21713. * Be aware Math.random() could cause collisions, but:
  21714. * "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"
  21715. * @returns a string containing a new GUID
  21716. */
  21717. static RandomId(): string;
  21718. /** @hidden */
  21719. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21720. private static _CleanMatricesWeights;
  21721. /**
  21722. * Create a new geometry from persisted data (Using .babylon file format)
  21723. * @param parsedVertexData defines the persisted data
  21724. * @param scene defines the hosting scene
  21725. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21726. * @returns the new geometry object
  21727. */
  21728. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21729. }
  21730. }
  21731. declare module "babylonjs/Meshes/mesh.vertexData" {
  21732. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21733. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21734. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21735. import { Geometry } from "babylonjs/Meshes/geometry";
  21736. import { Mesh } from "babylonjs/Meshes/mesh";
  21737. /**
  21738. * Define an interface for all classes that will get and set the data on vertices
  21739. */
  21740. export interface IGetSetVerticesData {
  21741. /**
  21742. * Gets a boolean indicating if specific vertex data is present
  21743. * @param kind defines the vertex data kind to use
  21744. * @returns true is data kind is present
  21745. */
  21746. isVerticesDataPresent(kind: string): boolean;
  21747. /**
  21748. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21749. * @param kind defines the data kind (Position, normal, etc...)
  21750. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21751. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21752. * @returns a float array containing vertex data
  21753. */
  21754. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21755. /**
  21756. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21757. * @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.
  21758. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21759. * @returns the indices array or an empty array if the mesh has no geometry
  21760. */
  21761. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21762. /**
  21763. * Set specific vertex data
  21764. * @param kind defines the data kind (Position, normal, etc...)
  21765. * @param data defines the vertex data to use
  21766. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21767. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21768. */
  21769. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21770. /**
  21771. * Update a specific associated vertex buffer
  21772. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21773. * - VertexBuffer.PositionKind
  21774. * - VertexBuffer.UVKind
  21775. * - VertexBuffer.UV2Kind
  21776. * - VertexBuffer.UV3Kind
  21777. * - VertexBuffer.UV4Kind
  21778. * - VertexBuffer.UV5Kind
  21779. * - VertexBuffer.UV6Kind
  21780. * - VertexBuffer.ColorKind
  21781. * - VertexBuffer.MatricesIndicesKind
  21782. * - VertexBuffer.MatricesIndicesExtraKind
  21783. * - VertexBuffer.MatricesWeightsKind
  21784. * - VertexBuffer.MatricesWeightsExtraKind
  21785. * @param data defines the data source
  21786. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21787. * @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)
  21788. */
  21789. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21790. /**
  21791. * Creates a new index buffer
  21792. * @param indices defines the indices to store in the index buffer
  21793. * @param totalVertices defines the total number of vertices (could be null)
  21794. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21795. */
  21796. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21797. }
  21798. /**
  21799. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21800. */
  21801. export class VertexData {
  21802. /**
  21803. * Mesh side orientation : usually the external or front surface
  21804. */
  21805. static readonly FRONTSIDE: number;
  21806. /**
  21807. * Mesh side orientation : usually the internal or back surface
  21808. */
  21809. static readonly BACKSIDE: number;
  21810. /**
  21811. * Mesh side orientation : both internal and external or front and back surfaces
  21812. */
  21813. static readonly DOUBLESIDE: number;
  21814. /**
  21815. * Mesh side orientation : by default, `FRONTSIDE`
  21816. */
  21817. static readonly DEFAULTSIDE: number;
  21818. /**
  21819. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21820. */
  21821. positions: Nullable<FloatArray>;
  21822. /**
  21823. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21824. */
  21825. normals: Nullable<FloatArray>;
  21826. /**
  21827. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21828. */
  21829. tangents: Nullable<FloatArray>;
  21830. /**
  21831. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21832. */
  21833. uvs: Nullable<FloatArray>;
  21834. /**
  21835. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21836. */
  21837. uvs2: Nullable<FloatArray>;
  21838. /**
  21839. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21840. */
  21841. uvs3: Nullable<FloatArray>;
  21842. /**
  21843. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21844. */
  21845. uvs4: Nullable<FloatArray>;
  21846. /**
  21847. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21848. */
  21849. uvs5: Nullable<FloatArray>;
  21850. /**
  21851. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21852. */
  21853. uvs6: Nullable<FloatArray>;
  21854. /**
  21855. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21856. */
  21857. colors: Nullable<FloatArray>;
  21858. /**
  21859. * 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).
  21860. */
  21861. matricesIndices: Nullable<FloatArray>;
  21862. /**
  21863. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21864. */
  21865. matricesWeights: Nullable<FloatArray>;
  21866. /**
  21867. * An array extending the number of possible indices
  21868. */
  21869. matricesIndicesExtra: Nullable<FloatArray>;
  21870. /**
  21871. * An array extending the number of possible weights when the number of indices is extended
  21872. */
  21873. matricesWeightsExtra: Nullable<FloatArray>;
  21874. /**
  21875. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21876. */
  21877. indices: Nullable<IndicesArray>;
  21878. /**
  21879. * Uses the passed data array to set the set the values for the specified kind of data
  21880. * @param data a linear array of floating numbers
  21881. * @param kind the type of data that is being set, eg positions, colors etc
  21882. */
  21883. set(data: FloatArray, kind: string): void;
  21884. /**
  21885. * Associates the vertexData to the passed Mesh.
  21886. * Sets it as updatable or not (default `false`)
  21887. * @param mesh the mesh the vertexData is applied to
  21888. * @param updatable when used and having the value true allows new data to update the vertexData
  21889. * @returns the VertexData
  21890. */
  21891. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21892. /**
  21893. * Associates the vertexData to the passed Geometry.
  21894. * Sets it as updatable or not (default `false`)
  21895. * @param geometry the geometry the vertexData is applied to
  21896. * @param updatable when used and having the value true allows new data to update the vertexData
  21897. * @returns VertexData
  21898. */
  21899. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21900. /**
  21901. * Updates the associated mesh
  21902. * @param mesh the mesh to be updated
  21903. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21904. * @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
  21905. * @returns VertexData
  21906. */
  21907. updateMesh(mesh: Mesh): VertexData;
  21908. /**
  21909. * Updates the associated geometry
  21910. * @param geometry the geometry to be updated
  21911. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21912. * @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
  21913. * @returns VertexData.
  21914. */
  21915. updateGeometry(geometry: Geometry): VertexData;
  21916. private _applyTo;
  21917. private _update;
  21918. /**
  21919. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21920. * @param matrix the transforming matrix
  21921. * @returns the VertexData
  21922. */
  21923. transform(matrix: Matrix): VertexData;
  21924. /**
  21925. * Merges the passed VertexData into the current one
  21926. * @param other the VertexData to be merged into the current one
  21927. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21928. * @returns the modified VertexData
  21929. */
  21930. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21931. private _mergeElement;
  21932. private _validate;
  21933. /**
  21934. * Serializes the VertexData
  21935. * @returns a serialized object
  21936. */
  21937. serialize(): any;
  21938. /**
  21939. * Extracts the vertexData from a mesh
  21940. * @param mesh the mesh from which to extract the VertexData
  21941. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21942. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21943. * @returns the object VertexData associated to the passed mesh
  21944. */
  21945. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21946. /**
  21947. * Extracts the vertexData from the geometry
  21948. * @param geometry the geometry from which to extract the VertexData
  21949. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21950. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21951. * @returns the object VertexData associated to the passed mesh
  21952. */
  21953. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21954. private static _ExtractFrom;
  21955. /**
  21956. * Creates the VertexData for a Ribbon
  21957. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21958. * * pathArray array of paths, each of which an array of successive Vector3
  21959. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21960. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21961. * * 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
  21962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21963. * * 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)
  21964. * * 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)
  21965. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21966. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21967. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21968. * @returns the VertexData of the ribbon
  21969. */
  21970. static CreateRibbon(options: {
  21971. pathArray: Vector3[][];
  21972. closeArray?: boolean;
  21973. closePath?: boolean;
  21974. offset?: number;
  21975. sideOrientation?: number;
  21976. frontUVs?: Vector4;
  21977. backUVs?: Vector4;
  21978. invertUV?: boolean;
  21979. uvs?: Vector2[];
  21980. colors?: Color4[];
  21981. }): VertexData;
  21982. /**
  21983. * Creates the VertexData for a box
  21984. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21985. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21986. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21987. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21988. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21989. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21990. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21992. * * 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)
  21993. * * 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)
  21994. * @returns the VertexData of the box
  21995. */
  21996. static CreateBox(options: {
  21997. size?: number;
  21998. width?: number;
  21999. height?: number;
  22000. depth?: number;
  22001. faceUV?: Vector4[];
  22002. faceColors?: Color4[];
  22003. sideOrientation?: number;
  22004. frontUVs?: Vector4;
  22005. backUVs?: Vector4;
  22006. }): VertexData;
  22007. /**
  22008. * Creates the VertexData for a tiled box
  22009. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22010. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22011. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22012. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22014. * @returns the VertexData of the box
  22015. */
  22016. static CreateTiledBox(options: {
  22017. pattern?: number;
  22018. width?: number;
  22019. height?: number;
  22020. depth?: number;
  22021. tileSize?: number;
  22022. tileWidth?: number;
  22023. tileHeight?: number;
  22024. alignHorizontal?: number;
  22025. alignVertical?: number;
  22026. faceUV?: Vector4[];
  22027. faceColors?: Color4[];
  22028. sideOrientation?: number;
  22029. }): VertexData;
  22030. /**
  22031. * Creates the VertexData for a tiled plane
  22032. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22033. * * pattern a limited pattern arrangement depending on the number
  22034. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22035. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22036. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22038. * * 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)
  22039. * * 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)
  22040. * @returns the VertexData of the tiled plane
  22041. */
  22042. static CreateTiledPlane(options: {
  22043. pattern?: number;
  22044. tileSize?: number;
  22045. tileWidth?: number;
  22046. tileHeight?: number;
  22047. size?: number;
  22048. width?: number;
  22049. height?: number;
  22050. alignHorizontal?: number;
  22051. alignVertical?: number;
  22052. sideOrientation?: number;
  22053. frontUVs?: Vector4;
  22054. backUVs?: Vector4;
  22055. }): VertexData;
  22056. /**
  22057. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22058. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22059. * * segments sets the number of horizontal strips optional, default 32
  22060. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22061. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22062. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22063. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22064. * * 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
  22065. * * 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
  22066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22067. * * 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)
  22068. * * 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)
  22069. * @returns the VertexData of the ellipsoid
  22070. */
  22071. static CreateSphere(options: {
  22072. segments?: number;
  22073. diameter?: number;
  22074. diameterX?: number;
  22075. diameterY?: number;
  22076. diameterZ?: number;
  22077. arc?: number;
  22078. slice?: number;
  22079. sideOrientation?: number;
  22080. frontUVs?: Vector4;
  22081. backUVs?: Vector4;
  22082. }): VertexData;
  22083. /**
  22084. * Creates the VertexData for a cylinder, cone or prism
  22085. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22086. * * height sets the height (y direction) of the cylinder, optional, default 2
  22087. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22088. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22089. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22090. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22091. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22092. * * 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
  22093. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22094. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22095. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22096. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22098. * * 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)
  22099. * * 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)
  22100. * @returns the VertexData of the cylinder, cone or prism
  22101. */
  22102. static CreateCylinder(options: {
  22103. height?: number;
  22104. diameterTop?: number;
  22105. diameterBottom?: number;
  22106. diameter?: number;
  22107. tessellation?: number;
  22108. subdivisions?: number;
  22109. arc?: number;
  22110. faceColors?: Color4[];
  22111. faceUV?: Vector4[];
  22112. hasRings?: boolean;
  22113. enclose?: boolean;
  22114. sideOrientation?: number;
  22115. frontUVs?: Vector4;
  22116. backUVs?: Vector4;
  22117. }): VertexData;
  22118. /**
  22119. * Creates the VertexData for a torus
  22120. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22121. * * diameter the diameter of the torus, optional default 1
  22122. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22123. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22125. * * 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)
  22126. * * 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)
  22127. * @returns the VertexData of the torus
  22128. */
  22129. static CreateTorus(options: {
  22130. diameter?: number;
  22131. thickness?: number;
  22132. tessellation?: number;
  22133. sideOrientation?: number;
  22134. frontUVs?: Vector4;
  22135. backUVs?: Vector4;
  22136. }): VertexData;
  22137. /**
  22138. * Creates the VertexData of the LineSystem
  22139. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22140. * - lines an array of lines, each line being an array of successive Vector3
  22141. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22142. * @returns the VertexData of the LineSystem
  22143. */
  22144. static CreateLineSystem(options: {
  22145. lines: Vector3[][];
  22146. colors?: Nullable<Color4[][]>;
  22147. }): VertexData;
  22148. /**
  22149. * Create the VertexData for a DashedLines
  22150. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22151. * - points an array successive Vector3
  22152. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22153. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22154. * - dashNb the intended total number of dashes, optional, default 200
  22155. * @returns the VertexData for the DashedLines
  22156. */
  22157. static CreateDashedLines(options: {
  22158. points: Vector3[];
  22159. dashSize?: number;
  22160. gapSize?: number;
  22161. dashNb?: number;
  22162. }): VertexData;
  22163. /**
  22164. * Creates the VertexData for a Ground
  22165. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22166. * - width the width (x direction) of the ground, optional, default 1
  22167. * - height the height (z direction) of the ground, optional, default 1
  22168. * - subdivisions the number of subdivisions per side, optional, default 1
  22169. * @returns the VertexData of the Ground
  22170. */
  22171. static CreateGround(options: {
  22172. width?: number;
  22173. height?: number;
  22174. subdivisions?: number;
  22175. subdivisionsX?: number;
  22176. subdivisionsY?: number;
  22177. }): VertexData;
  22178. /**
  22179. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22180. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22181. * * xmin the ground minimum X coordinate, optional, default -1
  22182. * * zmin the ground minimum Z coordinate, optional, default -1
  22183. * * xmax the ground maximum X coordinate, optional, default 1
  22184. * * zmax the ground maximum Z coordinate, optional, default 1
  22185. * * 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}
  22186. * * 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}
  22187. * @returns the VertexData of the TiledGround
  22188. */
  22189. static CreateTiledGround(options: {
  22190. xmin: number;
  22191. zmin: number;
  22192. xmax: number;
  22193. zmax: number;
  22194. subdivisions?: {
  22195. w: number;
  22196. h: number;
  22197. };
  22198. precision?: {
  22199. w: number;
  22200. h: number;
  22201. };
  22202. }): VertexData;
  22203. /**
  22204. * Creates the VertexData of the Ground designed from a heightmap
  22205. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22206. * * width the width (x direction) of the ground
  22207. * * height the height (z direction) of the ground
  22208. * * subdivisions the number of subdivisions per side
  22209. * * minHeight the minimum altitude on the ground, optional, default 0
  22210. * * maxHeight the maximum altitude on the ground, optional default 1
  22211. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22212. * * buffer the array holding the image color data
  22213. * * bufferWidth the width of image
  22214. * * bufferHeight the height of image
  22215. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22216. * @returns the VertexData of the Ground designed from a heightmap
  22217. */
  22218. static CreateGroundFromHeightMap(options: {
  22219. width: number;
  22220. height: number;
  22221. subdivisions: number;
  22222. minHeight: number;
  22223. maxHeight: number;
  22224. colorFilter: Color3;
  22225. buffer: Uint8Array;
  22226. bufferWidth: number;
  22227. bufferHeight: number;
  22228. alphaFilter: number;
  22229. }): VertexData;
  22230. /**
  22231. * Creates the VertexData for a Plane
  22232. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22233. * * size sets the width and height of the plane to the value of size, optional default 1
  22234. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22235. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22237. * * 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)
  22238. * * 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)
  22239. * @returns the VertexData of the box
  22240. */
  22241. static CreatePlane(options: {
  22242. size?: number;
  22243. width?: number;
  22244. height?: number;
  22245. sideOrientation?: number;
  22246. frontUVs?: Vector4;
  22247. backUVs?: Vector4;
  22248. }): VertexData;
  22249. /**
  22250. * Creates the VertexData of the Disc or regular Polygon
  22251. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22252. * * radius the radius of the disc, optional default 0.5
  22253. * * tessellation the number of polygon sides, optional, default 64
  22254. * * 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
  22255. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22256. * * 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)
  22257. * * 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)
  22258. * @returns the VertexData of the box
  22259. */
  22260. static CreateDisc(options: {
  22261. radius?: number;
  22262. tessellation?: number;
  22263. arc?: number;
  22264. sideOrientation?: number;
  22265. frontUVs?: Vector4;
  22266. backUVs?: Vector4;
  22267. }): VertexData;
  22268. /**
  22269. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22270. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22271. * @param polygon a mesh built from polygonTriangulation.build()
  22272. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22273. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22274. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22275. * @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)
  22276. * @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)
  22277. * @returns the VertexData of the Polygon
  22278. */
  22279. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22280. /**
  22281. * Creates the VertexData of the IcoSphere
  22282. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22283. * * radius the radius of the IcoSphere, optional default 1
  22284. * * radiusX allows stretching in the x direction, optional, default radius
  22285. * * radiusY allows stretching in the y direction, optional, default radius
  22286. * * radiusZ allows stretching in the z direction, optional, default radius
  22287. * * flat when true creates a flat shaded mesh, optional, default true
  22288. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22289. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22290. * * 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)
  22291. * * 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)
  22292. * @returns the VertexData of the IcoSphere
  22293. */
  22294. static CreateIcoSphere(options: {
  22295. radius?: number;
  22296. radiusX?: number;
  22297. radiusY?: number;
  22298. radiusZ?: number;
  22299. flat?: boolean;
  22300. subdivisions?: number;
  22301. sideOrientation?: number;
  22302. frontUVs?: Vector4;
  22303. backUVs?: Vector4;
  22304. }): VertexData;
  22305. /**
  22306. * Creates the VertexData for a Polyhedron
  22307. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22308. * * type provided types are:
  22309. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22310. * * 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)
  22311. * * size the size of the IcoSphere, optional default 1
  22312. * * sizeX allows stretching in the x direction, optional, default size
  22313. * * sizeY allows stretching in the y direction, optional, default size
  22314. * * sizeZ allows stretching in the z direction, optional, default size
  22315. * * 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
  22316. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22317. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22318. * * flat when true creates a flat shaded mesh, optional, default true
  22319. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22321. * * 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)
  22322. * * 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)
  22323. * @returns the VertexData of the Polyhedron
  22324. */
  22325. static CreatePolyhedron(options: {
  22326. type?: number;
  22327. size?: number;
  22328. sizeX?: number;
  22329. sizeY?: number;
  22330. sizeZ?: number;
  22331. custom?: any;
  22332. faceUV?: Vector4[];
  22333. faceColors?: Color4[];
  22334. flat?: boolean;
  22335. sideOrientation?: number;
  22336. frontUVs?: Vector4;
  22337. backUVs?: Vector4;
  22338. }): VertexData;
  22339. /**
  22340. * Creates the VertexData for a TorusKnot
  22341. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22342. * * radius the radius of the torus knot, optional, default 2
  22343. * * tube the thickness of the tube, optional, default 0.5
  22344. * * radialSegments the number of sides on each tube segments, optional, default 32
  22345. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22346. * * p the number of windings around the z axis, optional, default 2
  22347. * * q the number of windings around the x axis, optional, default 3
  22348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22349. * * 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)
  22350. * * 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)
  22351. * @returns the VertexData of the Torus Knot
  22352. */
  22353. static CreateTorusKnot(options: {
  22354. radius?: number;
  22355. tube?: number;
  22356. radialSegments?: number;
  22357. tubularSegments?: number;
  22358. p?: number;
  22359. q?: number;
  22360. sideOrientation?: number;
  22361. frontUVs?: Vector4;
  22362. backUVs?: Vector4;
  22363. }): VertexData;
  22364. /**
  22365. * Compute normals for given positions and indices
  22366. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22367. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22368. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22369. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22370. * * facetNormals : optional array of facet normals (vector3)
  22371. * * facetPositions : optional array of facet positions (vector3)
  22372. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22373. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22374. * * bInfo : optional bounding info, required for facetPartitioning computation
  22375. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22376. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22377. * * useRightHandedSystem: optional boolean to for right handed system computation
  22378. * * depthSort : optional boolean to enable the facet depth sort computation
  22379. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22380. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22381. */
  22382. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22383. facetNormals?: any;
  22384. facetPositions?: any;
  22385. facetPartitioning?: any;
  22386. ratio?: number;
  22387. bInfo?: any;
  22388. bbSize?: Vector3;
  22389. subDiv?: any;
  22390. useRightHandedSystem?: boolean;
  22391. depthSort?: boolean;
  22392. distanceTo?: Vector3;
  22393. depthSortedFacets?: any;
  22394. }): void;
  22395. /** @hidden */
  22396. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22397. /**
  22398. * Applies VertexData created from the imported parameters to the geometry
  22399. * @param parsedVertexData the parsed data from an imported file
  22400. * @param geometry the geometry to apply the VertexData to
  22401. */
  22402. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22403. }
  22404. }
  22405. declare module "babylonjs/Morph/morphTarget" {
  22406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22407. import { Observable } from "babylonjs/Misc/observable";
  22408. import { Nullable, FloatArray } from "babylonjs/types";
  22409. import { Scene } from "babylonjs/scene";
  22410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22411. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22412. /**
  22413. * Defines a target to use with MorphTargetManager
  22414. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22415. */
  22416. export class MorphTarget implements IAnimatable {
  22417. /** defines the name of the target */
  22418. name: string;
  22419. /**
  22420. * Gets or sets the list of animations
  22421. */
  22422. animations: import("babylonjs/Animations/animation").Animation[];
  22423. private _scene;
  22424. private _positions;
  22425. private _normals;
  22426. private _tangents;
  22427. private _uvs;
  22428. private _influence;
  22429. /**
  22430. * Observable raised when the influence changes
  22431. */
  22432. onInfluenceChanged: Observable<boolean>;
  22433. /** @hidden */
  22434. _onDataLayoutChanged: Observable<void>;
  22435. /**
  22436. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22437. */
  22438. influence: number;
  22439. /**
  22440. * Gets or sets the id of the morph Target
  22441. */
  22442. id: string;
  22443. private _animationPropertiesOverride;
  22444. /**
  22445. * Gets or sets the animation properties override
  22446. */
  22447. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22448. /**
  22449. * Creates a new MorphTarget
  22450. * @param name defines the name of the target
  22451. * @param influence defines the influence to use
  22452. * @param scene defines the scene the morphtarget belongs to
  22453. */
  22454. constructor(
  22455. /** defines the name of the target */
  22456. name: string, influence?: number, scene?: Nullable<Scene>);
  22457. /**
  22458. * Gets a boolean defining if the target contains position data
  22459. */
  22460. readonly hasPositions: boolean;
  22461. /**
  22462. * Gets a boolean defining if the target contains normal data
  22463. */
  22464. readonly hasNormals: boolean;
  22465. /**
  22466. * Gets a boolean defining if the target contains tangent data
  22467. */
  22468. readonly hasTangents: boolean;
  22469. /**
  22470. * Gets a boolean defining if the target contains texture coordinates data
  22471. */
  22472. readonly hasUVs: boolean;
  22473. /**
  22474. * Affects position data to this target
  22475. * @param data defines the position data to use
  22476. */
  22477. setPositions(data: Nullable<FloatArray>): void;
  22478. /**
  22479. * Gets the position data stored in this target
  22480. * @returns a FloatArray containing the position data (or null if not present)
  22481. */
  22482. getPositions(): Nullable<FloatArray>;
  22483. /**
  22484. * Affects normal data to this target
  22485. * @param data defines the normal data to use
  22486. */
  22487. setNormals(data: Nullable<FloatArray>): void;
  22488. /**
  22489. * Gets the normal data stored in this target
  22490. * @returns a FloatArray containing the normal data (or null if not present)
  22491. */
  22492. getNormals(): Nullable<FloatArray>;
  22493. /**
  22494. * Affects tangent data to this target
  22495. * @param data defines the tangent data to use
  22496. */
  22497. setTangents(data: Nullable<FloatArray>): void;
  22498. /**
  22499. * Gets the tangent data stored in this target
  22500. * @returns a FloatArray containing the tangent data (or null if not present)
  22501. */
  22502. getTangents(): Nullable<FloatArray>;
  22503. /**
  22504. * Affects texture coordinates data to this target
  22505. * @param data defines the texture coordinates data to use
  22506. */
  22507. setUVs(data: Nullable<FloatArray>): void;
  22508. /**
  22509. * Gets the texture coordinates data stored in this target
  22510. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22511. */
  22512. getUVs(): Nullable<FloatArray>;
  22513. /**
  22514. * Serializes the current target into a Serialization object
  22515. * @returns the serialized object
  22516. */
  22517. serialize(): any;
  22518. /**
  22519. * Returns the string "MorphTarget"
  22520. * @returns "MorphTarget"
  22521. */
  22522. getClassName(): string;
  22523. /**
  22524. * Creates a new target from serialized data
  22525. * @param serializationObject defines the serialized data to use
  22526. * @returns a new MorphTarget
  22527. */
  22528. static Parse(serializationObject: any): MorphTarget;
  22529. /**
  22530. * Creates a MorphTarget from mesh data
  22531. * @param mesh defines the source mesh
  22532. * @param name defines the name to use for the new target
  22533. * @param influence defines the influence to attach to the target
  22534. * @returns a new MorphTarget
  22535. */
  22536. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22537. }
  22538. }
  22539. declare module "babylonjs/Morph/morphTargetManager" {
  22540. import { Nullable } from "babylonjs/types";
  22541. import { Scene } from "babylonjs/scene";
  22542. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22543. /**
  22544. * This class is used to deform meshes using morphing between different targets
  22545. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22546. */
  22547. export class MorphTargetManager {
  22548. private _targets;
  22549. private _targetInfluenceChangedObservers;
  22550. private _targetDataLayoutChangedObservers;
  22551. private _activeTargets;
  22552. private _scene;
  22553. private _influences;
  22554. private _supportsNormals;
  22555. private _supportsTangents;
  22556. private _supportsUVs;
  22557. private _vertexCount;
  22558. private _uniqueId;
  22559. private _tempInfluences;
  22560. /**
  22561. * Gets or sets a boolean indicating if normals must be morphed
  22562. */
  22563. enableNormalMorphing: boolean;
  22564. /**
  22565. * Gets or sets a boolean indicating if tangents must be morphed
  22566. */
  22567. enableTangentMorphing: boolean;
  22568. /**
  22569. * Gets or sets a boolean indicating if UV must be morphed
  22570. */
  22571. enableUVMorphing: boolean;
  22572. /**
  22573. * Creates a new MorphTargetManager
  22574. * @param scene defines the current scene
  22575. */
  22576. constructor(scene?: Nullable<Scene>);
  22577. /**
  22578. * Gets the unique ID of this manager
  22579. */
  22580. readonly uniqueId: number;
  22581. /**
  22582. * Gets the number of vertices handled by this manager
  22583. */
  22584. readonly vertexCount: number;
  22585. /**
  22586. * Gets a boolean indicating if this manager supports morphing of normals
  22587. */
  22588. readonly supportsNormals: boolean;
  22589. /**
  22590. * Gets a boolean indicating if this manager supports morphing of tangents
  22591. */
  22592. readonly supportsTangents: boolean;
  22593. /**
  22594. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22595. */
  22596. readonly supportsUVs: boolean;
  22597. /**
  22598. * Gets the number of targets stored in this manager
  22599. */
  22600. readonly numTargets: number;
  22601. /**
  22602. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22603. */
  22604. readonly numInfluencers: number;
  22605. /**
  22606. * Gets the list of influences (one per target)
  22607. */
  22608. readonly influences: Float32Array;
  22609. /**
  22610. * Gets the active target at specified index. An active target is a target with an influence > 0
  22611. * @param index defines the index to check
  22612. * @returns the requested target
  22613. */
  22614. getActiveTarget(index: number): MorphTarget;
  22615. /**
  22616. * Gets the target at specified index
  22617. * @param index defines the index to check
  22618. * @returns the requested target
  22619. */
  22620. getTarget(index: number): MorphTarget;
  22621. /**
  22622. * Add a new target to this manager
  22623. * @param target defines the target to add
  22624. */
  22625. addTarget(target: MorphTarget): void;
  22626. /**
  22627. * Removes a target from the manager
  22628. * @param target defines the target to remove
  22629. */
  22630. removeTarget(target: MorphTarget): void;
  22631. /**
  22632. * Serializes the current manager into a Serialization object
  22633. * @returns the serialized object
  22634. */
  22635. serialize(): any;
  22636. private _syncActiveTargets;
  22637. /**
  22638. * Syncrhonize the targets with all the meshes using this morph target manager
  22639. */
  22640. synchronize(): void;
  22641. /**
  22642. * Creates a new MorphTargetManager from serialized data
  22643. * @param serializationObject defines the serialized data
  22644. * @param scene defines the hosting scene
  22645. * @returns the new MorphTargetManager
  22646. */
  22647. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22648. }
  22649. }
  22650. declare module "babylonjs/Meshes/meshLODLevel" {
  22651. import { Mesh } from "babylonjs/Meshes/mesh";
  22652. import { Nullable } from "babylonjs/types";
  22653. /**
  22654. * Class used to represent a specific level of detail of a mesh
  22655. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22656. */
  22657. export class MeshLODLevel {
  22658. /** Defines the distance where this level should star being displayed */
  22659. distance: number;
  22660. /** Defines the mesh to use to render this level */
  22661. mesh: Nullable<Mesh>;
  22662. /**
  22663. * Creates a new LOD level
  22664. * @param distance defines the distance where this level should star being displayed
  22665. * @param mesh defines the mesh to use to render this level
  22666. */
  22667. constructor(
  22668. /** Defines the distance where this level should star being displayed */
  22669. distance: number,
  22670. /** Defines the mesh to use to render this level */
  22671. mesh: Nullable<Mesh>);
  22672. }
  22673. }
  22674. declare module "babylonjs/Meshes/groundMesh" {
  22675. import { Scene } from "babylonjs/scene";
  22676. import { Vector3 } from "babylonjs/Maths/math.vector";
  22677. import { Mesh } from "babylonjs/Meshes/mesh";
  22678. /**
  22679. * Mesh representing the gorund
  22680. */
  22681. export class GroundMesh extends Mesh {
  22682. /** If octree should be generated */
  22683. generateOctree: boolean;
  22684. private _heightQuads;
  22685. /** @hidden */
  22686. _subdivisionsX: number;
  22687. /** @hidden */
  22688. _subdivisionsY: number;
  22689. /** @hidden */
  22690. _width: number;
  22691. /** @hidden */
  22692. _height: number;
  22693. /** @hidden */
  22694. _minX: number;
  22695. /** @hidden */
  22696. _maxX: number;
  22697. /** @hidden */
  22698. _minZ: number;
  22699. /** @hidden */
  22700. _maxZ: number;
  22701. constructor(name: string, scene: Scene);
  22702. /**
  22703. * "GroundMesh"
  22704. * @returns "GroundMesh"
  22705. */
  22706. getClassName(): string;
  22707. /**
  22708. * The minimum of x and y subdivisions
  22709. */
  22710. readonly subdivisions: number;
  22711. /**
  22712. * X subdivisions
  22713. */
  22714. readonly subdivisionsX: number;
  22715. /**
  22716. * Y subdivisions
  22717. */
  22718. readonly subdivisionsY: number;
  22719. /**
  22720. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22721. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22722. * @param chunksCount the number of subdivisions for x and y
  22723. * @param octreeBlocksSize (Default: 32)
  22724. */
  22725. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22726. /**
  22727. * Returns a height (y) value in the Worl system :
  22728. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22729. * @param x x coordinate
  22730. * @param z z coordinate
  22731. * @returns the ground y position if (x, z) are outside the ground surface.
  22732. */
  22733. getHeightAtCoordinates(x: number, z: number): number;
  22734. /**
  22735. * Returns a normalized vector (Vector3) orthogonal to the ground
  22736. * at the ground coordinates (x, z) expressed in the World system.
  22737. * @param x x coordinate
  22738. * @param z z coordinate
  22739. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22740. */
  22741. getNormalAtCoordinates(x: number, z: number): Vector3;
  22742. /**
  22743. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22744. * at the ground coordinates (x, z) expressed in the World system.
  22745. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22746. * @param x x coordinate
  22747. * @param z z coordinate
  22748. * @param ref vector to store the result
  22749. * @returns the GroundMesh.
  22750. */
  22751. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22752. /**
  22753. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22754. * if the ground has been updated.
  22755. * This can be used in the render loop.
  22756. * @returns the GroundMesh.
  22757. */
  22758. updateCoordinateHeights(): GroundMesh;
  22759. private _getFacetAt;
  22760. private _initHeightQuads;
  22761. private _computeHeightQuads;
  22762. /**
  22763. * Serializes this ground mesh
  22764. * @param serializationObject object to write serialization to
  22765. */
  22766. serialize(serializationObject: any): void;
  22767. /**
  22768. * Parses a serialized ground mesh
  22769. * @param parsedMesh the serialized mesh
  22770. * @param scene the scene to create the ground mesh in
  22771. * @returns the created ground mesh
  22772. */
  22773. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22774. }
  22775. }
  22776. declare module "babylonjs/Physics/physicsJoint" {
  22777. import { Vector3 } from "babylonjs/Maths/math.vector";
  22778. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22779. /**
  22780. * Interface for Physics-Joint data
  22781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22782. */
  22783. export interface PhysicsJointData {
  22784. /**
  22785. * The main pivot of the joint
  22786. */
  22787. mainPivot?: Vector3;
  22788. /**
  22789. * The connected pivot of the joint
  22790. */
  22791. connectedPivot?: Vector3;
  22792. /**
  22793. * The main axis of the joint
  22794. */
  22795. mainAxis?: Vector3;
  22796. /**
  22797. * The connected axis of the joint
  22798. */
  22799. connectedAxis?: Vector3;
  22800. /**
  22801. * The collision of the joint
  22802. */
  22803. collision?: boolean;
  22804. /**
  22805. * Native Oimo/Cannon/Energy data
  22806. */
  22807. nativeParams?: any;
  22808. }
  22809. /**
  22810. * This is a holder class for the physics joint created by the physics plugin
  22811. * It holds a set of functions to control the underlying joint
  22812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22813. */
  22814. export class PhysicsJoint {
  22815. /**
  22816. * The type of the physics joint
  22817. */
  22818. type: number;
  22819. /**
  22820. * The data for the physics joint
  22821. */
  22822. jointData: PhysicsJointData;
  22823. private _physicsJoint;
  22824. protected _physicsPlugin: IPhysicsEnginePlugin;
  22825. /**
  22826. * Initializes the physics joint
  22827. * @param type The type of the physics joint
  22828. * @param jointData The data for the physics joint
  22829. */
  22830. constructor(
  22831. /**
  22832. * The type of the physics joint
  22833. */
  22834. type: number,
  22835. /**
  22836. * The data for the physics joint
  22837. */
  22838. jointData: PhysicsJointData);
  22839. /**
  22840. * Gets the physics joint
  22841. */
  22842. /**
  22843. * Sets the physics joint
  22844. */
  22845. physicsJoint: any;
  22846. /**
  22847. * Sets the physics plugin
  22848. */
  22849. physicsPlugin: IPhysicsEnginePlugin;
  22850. /**
  22851. * Execute a function that is physics-plugin specific.
  22852. * @param {Function} func the function that will be executed.
  22853. * It accepts two parameters: the physics world and the physics joint
  22854. */
  22855. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22856. /**
  22857. * Distance-Joint type
  22858. */
  22859. static DistanceJoint: number;
  22860. /**
  22861. * Hinge-Joint type
  22862. */
  22863. static HingeJoint: number;
  22864. /**
  22865. * Ball-and-Socket joint type
  22866. */
  22867. static BallAndSocketJoint: number;
  22868. /**
  22869. * Wheel-Joint type
  22870. */
  22871. static WheelJoint: number;
  22872. /**
  22873. * Slider-Joint type
  22874. */
  22875. static SliderJoint: number;
  22876. /**
  22877. * Prismatic-Joint type
  22878. */
  22879. static PrismaticJoint: number;
  22880. /**
  22881. * Universal-Joint type
  22882. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22883. */
  22884. static UniversalJoint: number;
  22885. /**
  22886. * Hinge-Joint 2 type
  22887. */
  22888. static Hinge2Joint: number;
  22889. /**
  22890. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22891. */
  22892. static PointToPointJoint: number;
  22893. /**
  22894. * Spring-Joint type
  22895. */
  22896. static SpringJoint: number;
  22897. /**
  22898. * Lock-Joint type
  22899. */
  22900. static LockJoint: number;
  22901. }
  22902. /**
  22903. * A class representing a physics distance joint
  22904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22905. */
  22906. export class DistanceJoint extends PhysicsJoint {
  22907. /**
  22908. *
  22909. * @param jointData The data for the Distance-Joint
  22910. */
  22911. constructor(jointData: DistanceJointData);
  22912. /**
  22913. * Update the predefined distance.
  22914. * @param maxDistance The maximum preferred distance
  22915. * @param minDistance The minimum preferred distance
  22916. */
  22917. updateDistance(maxDistance: number, minDistance?: number): void;
  22918. }
  22919. /**
  22920. * Represents a Motor-Enabled Joint
  22921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22922. */
  22923. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22924. /**
  22925. * Initializes the Motor-Enabled Joint
  22926. * @param type The type of the joint
  22927. * @param jointData The physica joint data for the joint
  22928. */
  22929. constructor(type: number, jointData: PhysicsJointData);
  22930. /**
  22931. * Set the motor values.
  22932. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22933. * @param force the force to apply
  22934. * @param maxForce max force for this motor.
  22935. */
  22936. setMotor(force?: number, maxForce?: number): void;
  22937. /**
  22938. * Set the motor's limits.
  22939. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22940. * @param upperLimit The upper limit of the motor
  22941. * @param lowerLimit The lower limit of the motor
  22942. */
  22943. setLimit(upperLimit: number, lowerLimit?: number): void;
  22944. }
  22945. /**
  22946. * This class represents a single physics Hinge-Joint
  22947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22948. */
  22949. export class HingeJoint extends MotorEnabledJoint {
  22950. /**
  22951. * Initializes the Hinge-Joint
  22952. * @param jointData The joint data for the Hinge-Joint
  22953. */
  22954. constructor(jointData: PhysicsJointData);
  22955. /**
  22956. * Set the motor values.
  22957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22958. * @param {number} force the force to apply
  22959. * @param {number} maxForce max force for this motor.
  22960. */
  22961. setMotor(force?: number, maxForce?: number): void;
  22962. /**
  22963. * Set the motor's limits.
  22964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22965. * @param upperLimit The upper limit of the motor
  22966. * @param lowerLimit The lower limit of the motor
  22967. */
  22968. setLimit(upperLimit: number, lowerLimit?: number): void;
  22969. }
  22970. /**
  22971. * This class represents a dual hinge physics joint (same as wheel joint)
  22972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22973. */
  22974. export class Hinge2Joint extends MotorEnabledJoint {
  22975. /**
  22976. * Initializes the Hinge2-Joint
  22977. * @param jointData The joint data for the Hinge2-Joint
  22978. */
  22979. constructor(jointData: PhysicsJointData);
  22980. /**
  22981. * Set the motor values.
  22982. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22983. * @param {number} targetSpeed the speed the motor is to reach
  22984. * @param {number} maxForce max force for this motor.
  22985. * @param {motorIndex} the motor's index, 0 or 1.
  22986. */
  22987. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22988. /**
  22989. * Set the motor limits.
  22990. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22991. * @param {number} upperLimit the upper limit
  22992. * @param {number} lowerLimit lower limit
  22993. * @param {motorIndex} the motor's index, 0 or 1.
  22994. */
  22995. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22996. }
  22997. /**
  22998. * Interface for a motor enabled joint
  22999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23000. */
  23001. export interface IMotorEnabledJoint {
  23002. /**
  23003. * Physics joint
  23004. */
  23005. physicsJoint: any;
  23006. /**
  23007. * Sets the motor of the motor-enabled joint
  23008. * @param force The force of the motor
  23009. * @param maxForce The maximum force of the motor
  23010. * @param motorIndex The index of the motor
  23011. */
  23012. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23013. /**
  23014. * Sets the limit of the motor
  23015. * @param upperLimit The upper limit of the motor
  23016. * @param lowerLimit The lower limit of the motor
  23017. * @param motorIndex The index of the motor
  23018. */
  23019. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23020. }
  23021. /**
  23022. * Joint data for a Distance-Joint
  23023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23024. */
  23025. export interface DistanceJointData extends PhysicsJointData {
  23026. /**
  23027. * Max distance the 2 joint objects can be apart
  23028. */
  23029. maxDistance: number;
  23030. }
  23031. /**
  23032. * Joint data from a spring joint
  23033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23034. */
  23035. export interface SpringJointData extends PhysicsJointData {
  23036. /**
  23037. * Length of the spring
  23038. */
  23039. length: number;
  23040. /**
  23041. * Stiffness of the spring
  23042. */
  23043. stiffness: number;
  23044. /**
  23045. * Damping of the spring
  23046. */
  23047. damping: number;
  23048. /** this callback will be called when applying the force to the impostors. */
  23049. forceApplicationCallback: () => void;
  23050. }
  23051. }
  23052. declare module "babylonjs/Physics/physicsRaycastResult" {
  23053. import { Vector3 } from "babylonjs/Maths/math.vector";
  23054. /**
  23055. * Holds the data for the raycast result
  23056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23057. */
  23058. export class PhysicsRaycastResult {
  23059. private _hasHit;
  23060. private _hitDistance;
  23061. private _hitNormalWorld;
  23062. private _hitPointWorld;
  23063. private _rayFromWorld;
  23064. private _rayToWorld;
  23065. /**
  23066. * Gets if there was a hit
  23067. */
  23068. readonly hasHit: boolean;
  23069. /**
  23070. * Gets the distance from the hit
  23071. */
  23072. readonly hitDistance: number;
  23073. /**
  23074. * Gets the hit normal/direction in the world
  23075. */
  23076. readonly hitNormalWorld: Vector3;
  23077. /**
  23078. * Gets the hit point in the world
  23079. */
  23080. readonly hitPointWorld: Vector3;
  23081. /**
  23082. * Gets the ray "start point" of the ray in the world
  23083. */
  23084. readonly rayFromWorld: Vector3;
  23085. /**
  23086. * Gets the ray "end point" of the ray in the world
  23087. */
  23088. readonly rayToWorld: Vector3;
  23089. /**
  23090. * Sets the hit data (normal & point in world space)
  23091. * @param hitNormalWorld defines the normal in world space
  23092. * @param hitPointWorld defines the point in world space
  23093. */
  23094. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23095. /**
  23096. * Sets the distance from the start point to the hit point
  23097. * @param distance
  23098. */
  23099. setHitDistance(distance: number): void;
  23100. /**
  23101. * Calculates the distance manually
  23102. */
  23103. calculateHitDistance(): void;
  23104. /**
  23105. * Resets all the values to default
  23106. * @param from The from point on world space
  23107. * @param to The to point on world space
  23108. */
  23109. reset(from?: Vector3, to?: Vector3): void;
  23110. }
  23111. /**
  23112. * Interface for the size containing width and height
  23113. */
  23114. interface IXYZ {
  23115. /**
  23116. * X
  23117. */
  23118. x: number;
  23119. /**
  23120. * Y
  23121. */
  23122. y: number;
  23123. /**
  23124. * Z
  23125. */
  23126. z: number;
  23127. }
  23128. }
  23129. declare module "babylonjs/Physics/IPhysicsEngine" {
  23130. import { Nullable } from "babylonjs/types";
  23131. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23133. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23134. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23135. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23136. /**
  23137. * Interface used to describe a physics joint
  23138. */
  23139. export interface PhysicsImpostorJoint {
  23140. /** Defines the main impostor to which the joint is linked */
  23141. mainImpostor: PhysicsImpostor;
  23142. /** Defines the impostor that is connected to the main impostor using this joint */
  23143. connectedImpostor: PhysicsImpostor;
  23144. /** Defines the joint itself */
  23145. joint: PhysicsJoint;
  23146. }
  23147. /** @hidden */
  23148. export interface IPhysicsEnginePlugin {
  23149. world: any;
  23150. name: string;
  23151. setGravity(gravity: Vector3): void;
  23152. setTimeStep(timeStep: number): void;
  23153. getTimeStep(): number;
  23154. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23155. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23156. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23157. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23158. removePhysicsBody(impostor: PhysicsImpostor): void;
  23159. generateJoint(joint: PhysicsImpostorJoint): void;
  23160. removeJoint(joint: PhysicsImpostorJoint): void;
  23161. isSupported(): boolean;
  23162. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23163. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23164. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23165. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23166. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23167. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23168. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23169. getBodyMass(impostor: PhysicsImpostor): number;
  23170. getBodyFriction(impostor: PhysicsImpostor): number;
  23171. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23172. getBodyRestitution(impostor: PhysicsImpostor): number;
  23173. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23174. getBodyPressure?(impostor: PhysicsImpostor): number;
  23175. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23176. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23177. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23178. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23179. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23180. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23181. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23182. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23183. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23184. sleepBody(impostor: PhysicsImpostor): void;
  23185. wakeUpBody(impostor: PhysicsImpostor): void;
  23186. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23187. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23188. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23189. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23190. getRadius(impostor: PhysicsImpostor): number;
  23191. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23192. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23193. dispose(): void;
  23194. }
  23195. /**
  23196. * Interface used to define a physics engine
  23197. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23198. */
  23199. export interface IPhysicsEngine {
  23200. /**
  23201. * Gets the gravity vector used by the simulation
  23202. */
  23203. gravity: Vector3;
  23204. /**
  23205. * Sets the gravity vector used by the simulation
  23206. * @param gravity defines the gravity vector to use
  23207. */
  23208. setGravity(gravity: Vector3): void;
  23209. /**
  23210. * Set the time step of the physics engine.
  23211. * Default is 1/60.
  23212. * To slow it down, enter 1/600 for example.
  23213. * To speed it up, 1/30
  23214. * @param newTimeStep the new timestep to apply to this world.
  23215. */
  23216. setTimeStep(newTimeStep: number): void;
  23217. /**
  23218. * Get the time step of the physics engine.
  23219. * @returns the current time step
  23220. */
  23221. getTimeStep(): number;
  23222. /**
  23223. * Release all resources
  23224. */
  23225. dispose(): void;
  23226. /**
  23227. * Gets the name of the current physics plugin
  23228. * @returns the name of the plugin
  23229. */
  23230. getPhysicsPluginName(): string;
  23231. /**
  23232. * Adding a new impostor for the impostor tracking.
  23233. * This will be done by the impostor itself.
  23234. * @param impostor the impostor to add
  23235. */
  23236. addImpostor(impostor: PhysicsImpostor): void;
  23237. /**
  23238. * Remove an impostor from the engine.
  23239. * This impostor and its mesh will not longer be updated by the physics engine.
  23240. * @param impostor the impostor to remove
  23241. */
  23242. removeImpostor(impostor: PhysicsImpostor): void;
  23243. /**
  23244. * Add a joint to the physics engine
  23245. * @param mainImpostor defines the main impostor to which the joint is added.
  23246. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23247. * @param joint defines the joint that will connect both impostors.
  23248. */
  23249. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23250. /**
  23251. * Removes a joint from the simulation
  23252. * @param mainImpostor defines the impostor used with the joint
  23253. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23254. * @param joint defines the joint to remove
  23255. */
  23256. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23257. /**
  23258. * Gets the current plugin used to run the simulation
  23259. * @returns current plugin
  23260. */
  23261. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23262. /**
  23263. * Gets the list of physic impostors
  23264. * @returns an array of PhysicsImpostor
  23265. */
  23266. getImpostors(): Array<PhysicsImpostor>;
  23267. /**
  23268. * Gets the impostor for a physics enabled object
  23269. * @param object defines the object impersonated by the impostor
  23270. * @returns the PhysicsImpostor or null if not found
  23271. */
  23272. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23273. /**
  23274. * Gets the impostor for a physics body object
  23275. * @param body defines physics body used by the impostor
  23276. * @returns the PhysicsImpostor or null if not found
  23277. */
  23278. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23279. /**
  23280. * Does a raycast in the physics world
  23281. * @param from when should the ray start?
  23282. * @param to when should the ray end?
  23283. * @returns PhysicsRaycastResult
  23284. */
  23285. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23286. /**
  23287. * Called by the scene. No need to call it.
  23288. * @param delta defines the timespam between frames
  23289. */
  23290. _step(delta: number): void;
  23291. }
  23292. }
  23293. declare module "babylonjs/Physics/physicsImpostor" {
  23294. import { Nullable, IndicesArray } from "babylonjs/types";
  23295. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23298. import { Scene } from "babylonjs/scene";
  23299. import { Bone } from "babylonjs/Bones/bone";
  23300. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23301. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23302. import { Space } from "babylonjs/Maths/math.axis";
  23303. /**
  23304. * The interface for the physics imposter parameters
  23305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23306. */
  23307. export interface PhysicsImpostorParameters {
  23308. /**
  23309. * The mass of the physics imposter
  23310. */
  23311. mass: number;
  23312. /**
  23313. * The friction of the physics imposter
  23314. */
  23315. friction?: number;
  23316. /**
  23317. * The coefficient of restitution of the physics imposter
  23318. */
  23319. restitution?: number;
  23320. /**
  23321. * The native options of the physics imposter
  23322. */
  23323. nativeOptions?: any;
  23324. /**
  23325. * Specifies if the parent should be ignored
  23326. */
  23327. ignoreParent?: boolean;
  23328. /**
  23329. * Specifies if bi-directional transformations should be disabled
  23330. */
  23331. disableBidirectionalTransformation?: boolean;
  23332. /**
  23333. * The pressure inside the physics imposter, soft object only
  23334. */
  23335. pressure?: number;
  23336. /**
  23337. * The stiffness the physics imposter, soft object only
  23338. */
  23339. stiffness?: number;
  23340. /**
  23341. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23342. */
  23343. velocityIterations?: number;
  23344. /**
  23345. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23346. */
  23347. positionIterations?: number;
  23348. /**
  23349. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23350. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23351. * Add to fix multiple points
  23352. */
  23353. fixedPoints?: number;
  23354. /**
  23355. * The collision margin around a soft object
  23356. */
  23357. margin?: number;
  23358. /**
  23359. * The collision margin around a soft object
  23360. */
  23361. damping?: number;
  23362. /**
  23363. * The path for a rope based on an extrusion
  23364. */
  23365. path?: any;
  23366. /**
  23367. * The shape of an extrusion used for a rope based on an extrusion
  23368. */
  23369. shape?: any;
  23370. }
  23371. /**
  23372. * Interface for a physics-enabled object
  23373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23374. */
  23375. export interface IPhysicsEnabledObject {
  23376. /**
  23377. * The position of the physics-enabled object
  23378. */
  23379. position: Vector3;
  23380. /**
  23381. * The rotation of the physics-enabled object
  23382. */
  23383. rotationQuaternion: Nullable<Quaternion>;
  23384. /**
  23385. * The scale of the physics-enabled object
  23386. */
  23387. scaling: Vector3;
  23388. /**
  23389. * The rotation of the physics-enabled object
  23390. */
  23391. rotation?: Vector3;
  23392. /**
  23393. * The parent of the physics-enabled object
  23394. */
  23395. parent?: any;
  23396. /**
  23397. * The bounding info of the physics-enabled object
  23398. * @returns The bounding info of the physics-enabled object
  23399. */
  23400. getBoundingInfo(): BoundingInfo;
  23401. /**
  23402. * Computes the world matrix
  23403. * @param force Specifies if the world matrix should be computed by force
  23404. * @returns A world matrix
  23405. */
  23406. computeWorldMatrix(force: boolean): Matrix;
  23407. /**
  23408. * Gets the world matrix
  23409. * @returns A world matrix
  23410. */
  23411. getWorldMatrix?(): Matrix;
  23412. /**
  23413. * Gets the child meshes
  23414. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23415. * @returns An array of abstract meshes
  23416. */
  23417. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23418. /**
  23419. * Gets the vertex data
  23420. * @param kind The type of vertex data
  23421. * @returns A nullable array of numbers, or a float32 array
  23422. */
  23423. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23424. /**
  23425. * Gets the indices from the mesh
  23426. * @returns A nullable array of index arrays
  23427. */
  23428. getIndices?(): Nullable<IndicesArray>;
  23429. /**
  23430. * Gets the scene from the mesh
  23431. * @returns the indices array or null
  23432. */
  23433. getScene?(): Scene;
  23434. /**
  23435. * Gets the absolute position from the mesh
  23436. * @returns the absolute position
  23437. */
  23438. getAbsolutePosition(): Vector3;
  23439. /**
  23440. * Gets the absolute pivot point from the mesh
  23441. * @returns the absolute pivot point
  23442. */
  23443. getAbsolutePivotPoint(): Vector3;
  23444. /**
  23445. * Rotates the mesh
  23446. * @param axis The axis of rotation
  23447. * @param amount The amount of rotation
  23448. * @param space The space of the rotation
  23449. * @returns The rotation transform node
  23450. */
  23451. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23452. /**
  23453. * Translates the mesh
  23454. * @param axis The axis of translation
  23455. * @param distance The distance of translation
  23456. * @param space The space of the translation
  23457. * @returns The transform node
  23458. */
  23459. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23460. /**
  23461. * Sets the absolute position of the mesh
  23462. * @param absolutePosition The absolute position of the mesh
  23463. * @returns The transform node
  23464. */
  23465. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23466. /**
  23467. * Gets the class name of the mesh
  23468. * @returns The class name
  23469. */
  23470. getClassName(): string;
  23471. }
  23472. /**
  23473. * Represents a physics imposter
  23474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23475. */
  23476. export class PhysicsImpostor {
  23477. /**
  23478. * The physics-enabled object used as the physics imposter
  23479. */
  23480. object: IPhysicsEnabledObject;
  23481. /**
  23482. * The type of the physics imposter
  23483. */
  23484. type: number;
  23485. private _options;
  23486. private _scene?;
  23487. /**
  23488. * The default object size of the imposter
  23489. */
  23490. static DEFAULT_OBJECT_SIZE: Vector3;
  23491. /**
  23492. * The identity quaternion of the imposter
  23493. */
  23494. static IDENTITY_QUATERNION: Quaternion;
  23495. /** @hidden */
  23496. _pluginData: any;
  23497. private _physicsEngine;
  23498. private _physicsBody;
  23499. private _bodyUpdateRequired;
  23500. private _onBeforePhysicsStepCallbacks;
  23501. private _onAfterPhysicsStepCallbacks;
  23502. /** @hidden */
  23503. _onPhysicsCollideCallbacks: Array<{
  23504. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23505. otherImpostors: Array<PhysicsImpostor>;
  23506. }>;
  23507. private _deltaPosition;
  23508. private _deltaRotation;
  23509. private _deltaRotationConjugated;
  23510. /** @hidden */
  23511. _isFromLine: boolean;
  23512. private _parent;
  23513. private _isDisposed;
  23514. private static _tmpVecs;
  23515. private static _tmpQuat;
  23516. /**
  23517. * Specifies if the physics imposter is disposed
  23518. */
  23519. readonly isDisposed: boolean;
  23520. /**
  23521. * Gets the mass of the physics imposter
  23522. */
  23523. mass: number;
  23524. /**
  23525. * Gets the coefficient of friction
  23526. */
  23527. /**
  23528. * Sets the coefficient of friction
  23529. */
  23530. friction: number;
  23531. /**
  23532. * Gets the coefficient of restitution
  23533. */
  23534. /**
  23535. * Sets the coefficient of restitution
  23536. */
  23537. restitution: number;
  23538. /**
  23539. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23540. */
  23541. /**
  23542. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23543. */
  23544. pressure: number;
  23545. /**
  23546. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23547. */
  23548. /**
  23549. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23550. */
  23551. stiffness: number;
  23552. /**
  23553. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23554. */
  23555. /**
  23556. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23557. */
  23558. velocityIterations: number;
  23559. /**
  23560. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23561. */
  23562. /**
  23563. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23564. */
  23565. positionIterations: number;
  23566. /**
  23567. * The unique id of the physics imposter
  23568. * set by the physics engine when adding this impostor to the array
  23569. */
  23570. uniqueId: number;
  23571. /**
  23572. * @hidden
  23573. */
  23574. soft: boolean;
  23575. /**
  23576. * @hidden
  23577. */
  23578. segments: number;
  23579. private _joints;
  23580. /**
  23581. * Initializes the physics imposter
  23582. * @param object The physics-enabled object used as the physics imposter
  23583. * @param type The type of the physics imposter
  23584. * @param _options The options for the physics imposter
  23585. * @param _scene The Babylon scene
  23586. */
  23587. constructor(
  23588. /**
  23589. * The physics-enabled object used as the physics imposter
  23590. */
  23591. object: IPhysicsEnabledObject,
  23592. /**
  23593. * The type of the physics imposter
  23594. */
  23595. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23596. /**
  23597. * This function will completly initialize this impostor.
  23598. * It will create a new body - but only if this mesh has no parent.
  23599. * If it has, this impostor will not be used other than to define the impostor
  23600. * of the child mesh.
  23601. * @hidden
  23602. */
  23603. _init(): void;
  23604. private _getPhysicsParent;
  23605. /**
  23606. * Should a new body be generated.
  23607. * @returns boolean specifying if body initialization is required
  23608. */
  23609. isBodyInitRequired(): boolean;
  23610. /**
  23611. * Sets the updated scaling
  23612. * @param updated Specifies if the scaling is updated
  23613. */
  23614. setScalingUpdated(): void;
  23615. /**
  23616. * Force a regeneration of this or the parent's impostor's body.
  23617. * Use under cautious - This will remove all joints already implemented.
  23618. */
  23619. forceUpdate(): void;
  23620. /**
  23621. * Gets the body that holds this impostor. Either its own, or its parent.
  23622. */
  23623. /**
  23624. * Set the physics body. Used mainly by the physics engine/plugin
  23625. */
  23626. physicsBody: any;
  23627. /**
  23628. * Get the parent of the physics imposter
  23629. * @returns Physics imposter or null
  23630. */
  23631. /**
  23632. * Sets the parent of the physics imposter
  23633. */
  23634. parent: Nullable<PhysicsImpostor>;
  23635. /**
  23636. * Resets the update flags
  23637. */
  23638. resetUpdateFlags(): void;
  23639. /**
  23640. * Gets the object extend size
  23641. * @returns the object extend size
  23642. */
  23643. getObjectExtendSize(): Vector3;
  23644. /**
  23645. * Gets the object center
  23646. * @returns The object center
  23647. */
  23648. getObjectCenter(): Vector3;
  23649. /**
  23650. * Get a specific parametes from the options parameter
  23651. * @param paramName The object parameter name
  23652. * @returns The object parameter
  23653. */
  23654. getParam(paramName: string): any;
  23655. /**
  23656. * Sets a specific parameter in the options given to the physics plugin
  23657. * @param paramName The parameter name
  23658. * @param value The value of the parameter
  23659. */
  23660. setParam(paramName: string, value: number): void;
  23661. /**
  23662. * Specifically change the body's mass option. Won't recreate the physics body object
  23663. * @param mass The mass of the physics imposter
  23664. */
  23665. setMass(mass: number): void;
  23666. /**
  23667. * Gets the linear velocity
  23668. * @returns linear velocity or null
  23669. */
  23670. getLinearVelocity(): Nullable<Vector3>;
  23671. /**
  23672. * Sets the linear velocity
  23673. * @param velocity linear velocity or null
  23674. */
  23675. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23676. /**
  23677. * Gets the angular velocity
  23678. * @returns angular velocity or null
  23679. */
  23680. getAngularVelocity(): Nullable<Vector3>;
  23681. /**
  23682. * Sets the angular velocity
  23683. * @param velocity The velocity or null
  23684. */
  23685. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23686. /**
  23687. * Execute a function with the physics plugin native code
  23688. * Provide a function the will have two variables - the world object and the physics body object
  23689. * @param func The function to execute with the physics plugin native code
  23690. */
  23691. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23692. /**
  23693. * Register a function that will be executed before the physics world is stepping forward
  23694. * @param func The function to execute before the physics world is stepped forward
  23695. */
  23696. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23697. /**
  23698. * Unregister a function that will be executed before the physics world is stepping forward
  23699. * @param func The function to execute before the physics world is stepped forward
  23700. */
  23701. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23702. /**
  23703. * Register a function that will be executed after the physics step
  23704. * @param func The function to execute after physics step
  23705. */
  23706. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23707. /**
  23708. * Unregisters a function that will be executed after the physics step
  23709. * @param func The function to execute after physics step
  23710. */
  23711. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23712. /**
  23713. * register a function that will be executed when this impostor collides against a different body
  23714. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23715. * @param func Callback that is executed on collision
  23716. */
  23717. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23718. /**
  23719. * Unregisters the physics imposter on contact
  23720. * @param collideAgainst The physics object to collide against
  23721. * @param func Callback to execute on collision
  23722. */
  23723. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23724. private _tmpQuat;
  23725. private _tmpQuat2;
  23726. /**
  23727. * Get the parent rotation
  23728. * @returns The parent rotation
  23729. */
  23730. getParentsRotation(): Quaternion;
  23731. /**
  23732. * this function is executed by the physics engine.
  23733. */
  23734. beforeStep: () => void;
  23735. /**
  23736. * this function is executed by the physics engine
  23737. */
  23738. afterStep: () => void;
  23739. /**
  23740. * Legacy collision detection event support
  23741. */
  23742. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23743. /**
  23744. * event and body object due to cannon's event-based architecture.
  23745. */
  23746. onCollide: (e: {
  23747. body: any;
  23748. }) => void;
  23749. /**
  23750. * Apply a force
  23751. * @param force The force to apply
  23752. * @param contactPoint The contact point for the force
  23753. * @returns The physics imposter
  23754. */
  23755. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23756. /**
  23757. * Apply an impulse
  23758. * @param force The impulse force
  23759. * @param contactPoint The contact point for the impulse force
  23760. * @returns The physics imposter
  23761. */
  23762. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23763. /**
  23764. * A help function to create a joint
  23765. * @param otherImpostor A physics imposter used to create a joint
  23766. * @param jointType The type of joint
  23767. * @param jointData The data for the joint
  23768. * @returns The physics imposter
  23769. */
  23770. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23771. /**
  23772. * Add a joint to this impostor with a different impostor
  23773. * @param otherImpostor A physics imposter used to add a joint
  23774. * @param joint The joint to add
  23775. * @returns The physics imposter
  23776. */
  23777. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23778. /**
  23779. * Add an anchor to a cloth impostor
  23780. * @param otherImpostor rigid impostor to anchor to
  23781. * @param width ratio across width from 0 to 1
  23782. * @param height ratio up height from 0 to 1
  23783. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23784. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23785. * @returns impostor the soft imposter
  23786. */
  23787. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23788. /**
  23789. * Add a hook to a rope impostor
  23790. * @param otherImpostor rigid impostor to anchor to
  23791. * @param length ratio across rope from 0 to 1
  23792. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23793. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23794. * @returns impostor the rope imposter
  23795. */
  23796. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23797. /**
  23798. * Will keep this body still, in a sleep mode.
  23799. * @returns the physics imposter
  23800. */
  23801. sleep(): PhysicsImpostor;
  23802. /**
  23803. * Wake the body up.
  23804. * @returns The physics imposter
  23805. */
  23806. wakeUp(): PhysicsImpostor;
  23807. /**
  23808. * Clones the physics imposter
  23809. * @param newObject The physics imposter clones to this physics-enabled object
  23810. * @returns A nullable physics imposter
  23811. */
  23812. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23813. /**
  23814. * Disposes the physics imposter
  23815. */
  23816. dispose(): void;
  23817. /**
  23818. * Sets the delta position
  23819. * @param position The delta position amount
  23820. */
  23821. setDeltaPosition(position: Vector3): void;
  23822. /**
  23823. * Sets the delta rotation
  23824. * @param rotation The delta rotation amount
  23825. */
  23826. setDeltaRotation(rotation: Quaternion): void;
  23827. /**
  23828. * Gets the box size of the physics imposter and stores the result in the input parameter
  23829. * @param result Stores the box size
  23830. * @returns The physics imposter
  23831. */
  23832. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23833. /**
  23834. * Gets the radius of the physics imposter
  23835. * @returns Radius of the physics imposter
  23836. */
  23837. getRadius(): number;
  23838. /**
  23839. * Sync a bone with this impostor
  23840. * @param bone The bone to sync to the impostor.
  23841. * @param boneMesh The mesh that the bone is influencing.
  23842. * @param jointPivot The pivot of the joint / bone in local space.
  23843. * @param distToJoint Optional distance from the impostor to the joint.
  23844. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23845. */
  23846. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23847. /**
  23848. * Sync impostor to a bone
  23849. * @param bone The bone that the impostor will be synced to.
  23850. * @param boneMesh The mesh that the bone is influencing.
  23851. * @param jointPivot The pivot of the joint / bone in local space.
  23852. * @param distToJoint Optional distance from the impostor to the joint.
  23853. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23854. * @param boneAxis Optional vector3 axis the bone is aligned with
  23855. */
  23856. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23857. /**
  23858. * No-Imposter type
  23859. */
  23860. static NoImpostor: number;
  23861. /**
  23862. * Sphere-Imposter type
  23863. */
  23864. static SphereImpostor: number;
  23865. /**
  23866. * Box-Imposter type
  23867. */
  23868. static BoxImpostor: number;
  23869. /**
  23870. * Plane-Imposter type
  23871. */
  23872. static PlaneImpostor: number;
  23873. /**
  23874. * Mesh-imposter type
  23875. */
  23876. static MeshImpostor: number;
  23877. /**
  23878. * Capsule-Impostor type (Ammo.js plugin only)
  23879. */
  23880. static CapsuleImpostor: number;
  23881. /**
  23882. * Cylinder-Imposter type
  23883. */
  23884. static CylinderImpostor: number;
  23885. /**
  23886. * Particle-Imposter type
  23887. */
  23888. static ParticleImpostor: number;
  23889. /**
  23890. * Heightmap-Imposter type
  23891. */
  23892. static HeightmapImpostor: number;
  23893. /**
  23894. * ConvexHull-Impostor type (Ammo.js plugin only)
  23895. */
  23896. static ConvexHullImpostor: number;
  23897. /**
  23898. * Rope-Imposter type
  23899. */
  23900. static RopeImpostor: number;
  23901. /**
  23902. * Cloth-Imposter type
  23903. */
  23904. static ClothImpostor: number;
  23905. /**
  23906. * Softbody-Imposter type
  23907. */
  23908. static SoftbodyImpostor: number;
  23909. }
  23910. }
  23911. declare module "babylonjs/Meshes/mesh" {
  23912. import { Observable } from "babylonjs/Misc/observable";
  23913. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23914. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23915. import { Camera } from "babylonjs/Cameras/camera";
  23916. import { Scene } from "babylonjs/scene";
  23917. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23918. import { Color4 } from "babylonjs/Maths/math.color";
  23919. import { Engine } from "babylonjs/Engines/engine";
  23920. import { Node } from "babylonjs/node";
  23921. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23922. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23923. import { Buffer } from "babylonjs/Meshes/buffer";
  23924. import { Geometry } from "babylonjs/Meshes/geometry";
  23925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23927. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23928. import { Effect } from "babylonjs/Materials/effect";
  23929. import { Material } from "babylonjs/Materials/material";
  23930. import { Skeleton } from "babylonjs/Bones/skeleton";
  23931. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23932. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23933. import { Path3D } from "babylonjs/Maths/math.path";
  23934. import { Plane } from "babylonjs/Maths/math.plane";
  23935. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23936. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23937. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23938. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23939. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23940. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23941. /**
  23942. * @hidden
  23943. **/
  23944. export class _CreationDataStorage {
  23945. closePath?: boolean;
  23946. closeArray?: boolean;
  23947. idx: number[];
  23948. dashSize: number;
  23949. gapSize: number;
  23950. path3D: Path3D;
  23951. pathArray: Vector3[][];
  23952. arc: number;
  23953. radius: number;
  23954. cap: number;
  23955. tessellation: number;
  23956. }
  23957. /**
  23958. * @hidden
  23959. **/
  23960. class _InstanceDataStorage {
  23961. visibleInstances: any;
  23962. batchCache: _InstancesBatch;
  23963. instancesBufferSize: number;
  23964. instancesBuffer: Nullable<Buffer>;
  23965. instancesData: Float32Array;
  23966. overridenInstanceCount: number;
  23967. isFrozen: boolean;
  23968. previousBatch: Nullable<_InstancesBatch>;
  23969. hardwareInstancedRendering: boolean;
  23970. sideOrientation: number;
  23971. }
  23972. /**
  23973. * @hidden
  23974. **/
  23975. export class _InstancesBatch {
  23976. mustReturn: boolean;
  23977. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23978. renderSelf: boolean[];
  23979. hardwareInstancedRendering: boolean[];
  23980. }
  23981. /**
  23982. * Class used to represent renderable models
  23983. */
  23984. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23985. /**
  23986. * Mesh side orientation : usually the external or front surface
  23987. */
  23988. static readonly FRONTSIDE: number;
  23989. /**
  23990. * Mesh side orientation : usually the internal or back surface
  23991. */
  23992. static readonly BACKSIDE: number;
  23993. /**
  23994. * Mesh side orientation : both internal and external or front and back surfaces
  23995. */
  23996. static readonly DOUBLESIDE: number;
  23997. /**
  23998. * Mesh side orientation : by default, `FRONTSIDE`
  23999. */
  24000. static readonly DEFAULTSIDE: number;
  24001. /**
  24002. * Mesh cap setting : no cap
  24003. */
  24004. static readonly NO_CAP: number;
  24005. /**
  24006. * Mesh cap setting : one cap at the beginning of the mesh
  24007. */
  24008. static readonly CAP_START: number;
  24009. /**
  24010. * Mesh cap setting : one cap at the end of the mesh
  24011. */
  24012. static readonly CAP_END: number;
  24013. /**
  24014. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24015. */
  24016. static readonly CAP_ALL: number;
  24017. /**
  24018. * Mesh pattern setting : no flip or rotate
  24019. */
  24020. static readonly NO_FLIP: number;
  24021. /**
  24022. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24023. */
  24024. static readonly FLIP_TILE: number;
  24025. /**
  24026. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24027. */
  24028. static readonly ROTATE_TILE: number;
  24029. /**
  24030. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24031. */
  24032. static readonly FLIP_ROW: number;
  24033. /**
  24034. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24035. */
  24036. static readonly ROTATE_ROW: number;
  24037. /**
  24038. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24039. */
  24040. static readonly FLIP_N_ROTATE_TILE: number;
  24041. /**
  24042. * Mesh pattern setting : rotate pattern and rotate
  24043. */
  24044. static readonly FLIP_N_ROTATE_ROW: number;
  24045. /**
  24046. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24047. */
  24048. static readonly CENTER: number;
  24049. /**
  24050. * Mesh tile positioning : part tiles on left
  24051. */
  24052. static readonly LEFT: number;
  24053. /**
  24054. * Mesh tile positioning : part tiles on right
  24055. */
  24056. static readonly RIGHT: number;
  24057. /**
  24058. * Mesh tile positioning : part tiles on top
  24059. */
  24060. static readonly TOP: number;
  24061. /**
  24062. * Mesh tile positioning : part tiles on bottom
  24063. */
  24064. static readonly BOTTOM: number;
  24065. /**
  24066. * Gets the default side orientation.
  24067. * @param orientation the orientation to value to attempt to get
  24068. * @returns the default orientation
  24069. * @hidden
  24070. */
  24071. static _GetDefaultSideOrientation(orientation?: number): number;
  24072. private _internalMeshDataInfo;
  24073. /**
  24074. * An event triggered before rendering the mesh
  24075. */
  24076. readonly onBeforeRenderObservable: Observable<Mesh>;
  24077. /**
  24078. * An event triggered before binding the mesh
  24079. */
  24080. readonly onBeforeBindObservable: Observable<Mesh>;
  24081. /**
  24082. * An event triggered after rendering the mesh
  24083. */
  24084. readonly onAfterRenderObservable: Observable<Mesh>;
  24085. /**
  24086. * An event triggered before drawing the mesh
  24087. */
  24088. readonly onBeforeDrawObservable: Observable<Mesh>;
  24089. private _onBeforeDrawObserver;
  24090. /**
  24091. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24092. */
  24093. onBeforeDraw: () => void;
  24094. readonly hasInstances: boolean;
  24095. /**
  24096. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24097. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24098. */
  24099. delayLoadState: number;
  24100. /**
  24101. * Gets the list of instances created from this mesh
  24102. * it is not supposed to be modified manually.
  24103. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24104. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24105. */
  24106. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24107. /**
  24108. * Gets the file containing delay loading data for this mesh
  24109. */
  24110. delayLoadingFile: string;
  24111. /** @hidden */
  24112. _binaryInfo: any;
  24113. /**
  24114. * User defined function used to change how LOD level selection is done
  24115. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24116. */
  24117. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24118. /**
  24119. * Gets or sets the morph target manager
  24120. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24121. */
  24122. morphTargetManager: Nullable<MorphTargetManager>;
  24123. /** @hidden */
  24124. _creationDataStorage: Nullable<_CreationDataStorage>;
  24125. /** @hidden */
  24126. _geometry: Nullable<Geometry>;
  24127. /** @hidden */
  24128. _delayInfo: Array<string>;
  24129. /** @hidden */
  24130. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24131. /** @hidden */
  24132. _instanceDataStorage: _InstanceDataStorage;
  24133. private _effectiveMaterial;
  24134. /** @hidden */
  24135. _shouldGenerateFlatShading: boolean;
  24136. /** @hidden */
  24137. _originalBuilderSideOrientation: number;
  24138. /**
  24139. * Use this property to change the original side orientation defined at construction time
  24140. */
  24141. overrideMaterialSideOrientation: Nullable<number>;
  24142. /**
  24143. * Gets the source mesh (the one used to clone this one from)
  24144. */
  24145. readonly source: Nullable<Mesh>;
  24146. /**
  24147. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24148. */
  24149. isUnIndexed: boolean;
  24150. /**
  24151. * @constructor
  24152. * @param name The value used by scene.getMeshByName() to do a lookup.
  24153. * @param scene The scene to add this mesh to.
  24154. * @param parent The parent of this mesh, if it has one
  24155. * @param source An optional Mesh from which geometry is shared, cloned.
  24156. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24157. * When false, achieved by calling a clone(), also passing False.
  24158. * This will make creation of children, recursive.
  24159. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24160. */
  24161. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24162. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24163. /**
  24164. * Gets the class name
  24165. * @returns the string "Mesh".
  24166. */
  24167. getClassName(): string;
  24168. /** @hidden */
  24169. readonly _isMesh: boolean;
  24170. /**
  24171. * Returns a description of this mesh
  24172. * @param fullDetails define if full details about this mesh must be used
  24173. * @returns a descriptive string representing this mesh
  24174. */
  24175. toString(fullDetails?: boolean): string;
  24176. /** @hidden */
  24177. _unBindEffect(): void;
  24178. /**
  24179. * Gets a boolean indicating if this mesh has LOD
  24180. */
  24181. readonly hasLODLevels: boolean;
  24182. /**
  24183. * Gets the list of MeshLODLevel associated with the current mesh
  24184. * @returns an array of MeshLODLevel
  24185. */
  24186. getLODLevels(): MeshLODLevel[];
  24187. private _sortLODLevels;
  24188. /**
  24189. * Add a mesh as LOD level triggered at the given distance.
  24190. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24191. * @param distance The distance from the center of the object to show this level
  24192. * @param mesh The mesh to be added as LOD level (can be null)
  24193. * @return This mesh (for chaining)
  24194. */
  24195. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24196. /**
  24197. * Returns the LOD level mesh at the passed distance or null if not found.
  24198. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24199. * @param distance The distance from the center of the object to show this level
  24200. * @returns a Mesh or `null`
  24201. */
  24202. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24203. /**
  24204. * Remove a mesh from the LOD array
  24205. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24206. * @param mesh defines the mesh to be removed
  24207. * @return This mesh (for chaining)
  24208. */
  24209. removeLODLevel(mesh: Mesh): Mesh;
  24210. /**
  24211. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24212. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24213. * @param camera defines the camera to use to compute distance
  24214. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24215. * @return This mesh (for chaining)
  24216. */
  24217. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24218. /**
  24219. * Gets the mesh internal Geometry object
  24220. */
  24221. readonly geometry: Nullable<Geometry>;
  24222. /**
  24223. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24224. * @returns the total number of vertices
  24225. */
  24226. getTotalVertices(): number;
  24227. /**
  24228. * Returns the content of an associated vertex buffer
  24229. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24230. * - VertexBuffer.PositionKind
  24231. * - VertexBuffer.UVKind
  24232. * - VertexBuffer.UV2Kind
  24233. * - VertexBuffer.UV3Kind
  24234. * - VertexBuffer.UV4Kind
  24235. * - VertexBuffer.UV5Kind
  24236. * - VertexBuffer.UV6Kind
  24237. * - VertexBuffer.ColorKind
  24238. * - VertexBuffer.MatricesIndicesKind
  24239. * - VertexBuffer.MatricesIndicesExtraKind
  24240. * - VertexBuffer.MatricesWeightsKind
  24241. * - VertexBuffer.MatricesWeightsExtraKind
  24242. * @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
  24243. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24244. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24245. */
  24246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24247. /**
  24248. * Returns the mesh VertexBuffer object from the requested `kind`
  24249. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24250. * - VertexBuffer.PositionKind
  24251. * - VertexBuffer.NormalKind
  24252. * - VertexBuffer.UVKind
  24253. * - VertexBuffer.UV2Kind
  24254. * - VertexBuffer.UV3Kind
  24255. * - VertexBuffer.UV4Kind
  24256. * - VertexBuffer.UV5Kind
  24257. * - VertexBuffer.UV6Kind
  24258. * - VertexBuffer.ColorKind
  24259. * - VertexBuffer.MatricesIndicesKind
  24260. * - VertexBuffer.MatricesIndicesExtraKind
  24261. * - VertexBuffer.MatricesWeightsKind
  24262. * - VertexBuffer.MatricesWeightsExtraKind
  24263. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24264. */
  24265. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24266. /**
  24267. * Tests if a specific vertex buffer is associated with this mesh
  24268. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24269. * - VertexBuffer.PositionKind
  24270. * - VertexBuffer.NormalKind
  24271. * - VertexBuffer.UVKind
  24272. * - VertexBuffer.UV2Kind
  24273. * - VertexBuffer.UV3Kind
  24274. * - VertexBuffer.UV4Kind
  24275. * - VertexBuffer.UV5Kind
  24276. * - VertexBuffer.UV6Kind
  24277. * - VertexBuffer.ColorKind
  24278. * - VertexBuffer.MatricesIndicesKind
  24279. * - VertexBuffer.MatricesIndicesExtraKind
  24280. * - VertexBuffer.MatricesWeightsKind
  24281. * - VertexBuffer.MatricesWeightsExtraKind
  24282. * @returns a boolean
  24283. */
  24284. isVerticesDataPresent(kind: string): boolean;
  24285. /**
  24286. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24287. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24288. * - VertexBuffer.PositionKind
  24289. * - VertexBuffer.UVKind
  24290. * - VertexBuffer.UV2Kind
  24291. * - VertexBuffer.UV3Kind
  24292. * - VertexBuffer.UV4Kind
  24293. * - VertexBuffer.UV5Kind
  24294. * - VertexBuffer.UV6Kind
  24295. * - VertexBuffer.ColorKind
  24296. * - VertexBuffer.MatricesIndicesKind
  24297. * - VertexBuffer.MatricesIndicesExtraKind
  24298. * - VertexBuffer.MatricesWeightsKind
  24299. * - VertexBuffer.MatricesWeightsExtraKind
  24300. * @returns a boolean
  24301. */
  24302. isVertexBufferUpdatable(kind: string): boolean;
  24303. /**
  24304. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24305. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24306. * - VertexBuffer.PositionKind
  24307. * - VertexBuffer.NormalKind
  24308. * - VertexBuffer.UVKind
  24309. * - VertexBuffer.UV2Kind
  24310. * - VertexBuffer.UV3Kind
  24311. * - VertexBuffer.UV4Kind
  24312. * - VertexBuffer.UV5Kind
  24313. * - VertexBuffer.UV6Kind
  24314. * - VertexBuffer.ColorKind
  24315. * - VertexBuffer.MatricesIndicesKind
  24316. * - VertexBuffer.MatricesIndicesExtraKind
  24317. * - VertexBuffer.MatricesWeightsKind
  24318. * - VertexBuffer.MatricesWeightsExtraKind
  24319. * @returns an array of strings
  24320. */
  24321. getVerticesDataKinds(): string[];
  24322. /**
  24323. * Returns a positive integer : the total number of indices in this mesh geometry.
  24324. * @returns the numner of indices or zero if the mesh has no geometry.
  24325. */
  24326. getTotalIndices(): number;
  24327. /**
  24328. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24329. * @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.
  24330. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24331. * @returns the indices array or an empty array if the mesh has no geometry
  24332. */
  24333. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24334. readonly isBlocked: boolean;
  24335. /**
  24336. * Determine if the current mesh is ready to be rendered
  24337. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24338. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24339. * @returns true if all associated assets are ready (material, textures, shaders)
  24340. */
  24341. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24342. /**
  24343. * 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.
  24344. */
  24345. readonly areNormalsFrozen: boolean;
  24346. /**
  24347. * 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.
  24348. * @returns the current mesh
  24349. */
  24350. freezeNormals(): Mesh;
  24351. /**
  24352. * 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
  24353. * @returns the current mesh
  24354. */
  24355. unfreezeNormals(): Mesh;
  24356. /**
  24357. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24358. */
  24359. overridenInstanceCount: number;
  24360. /** @hidden */
  24361. _preActivate(): Mesh;
  24362. /** @hidden */
  24363. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24364. /** @hidden */
  24365. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24366. /**
  24367. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24368. * This means the mesh underlying bounding box and sphere are recomputed.
  24369. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24370. * @returns the current mesh
  24371. */
  24372. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24373. /** @hidden */
  24374. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24375. /**
  24376. * This function will subdivide the mesh into multiple submeshes
  24377. * @param count defines the expected number of submeshes
  24378. */
  24379. subdivide(count: number): void;
  24380. /**
  24381. * Copy a FloatArray into a specific associated vertex buffer
  24382. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24383. * - VertexBuffer.PositionKind
  24384. * - VertexBuffer.UVKind
  24385. * - VertexBuffer.UV2Kind
  24386. * - VertexBuffer.UV3Kind
  24387. * - VertexBuffer.UV4Kind
  24388. * - VertexBuffer.UV5Kind
  24389. * - VertexBuffer.UV6Kind
  24390. * - VertexBuffer.ColorKind
  24391. * - VertexBuffer.MatricesIndicesKind
  24392. * - VertexBuffer.MatricesIndicesExtraKind
  24393. * - VertexBuffer.MatricesWeightsKind
  24394. * - VertexBuffer.MatricesWeightsExtraKind
  24395. * @param data defines the data source
  24396. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24397. * @param stride defines the data stride size (can be null)
  24398. * @returns the current mesh
  24399. */
  24400. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24401. /**
  24402. * Flags an associated vertex buffer as updatable
  24403. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24404. * - VertexBuffer.PositionKind
  24405. * - VertexBuffer.UVKind
  24406. * - VertexBuffer.UV2Kind
  24407. * - VertexBuffer.UV3Kind
  24408. * - VertexBuffer.UV4Kind
  24409. * - VertexBuffer.UV5Kind
  24410. * - VertexBuffer.UV6Kind
  24411. * - VertexBuffer.ColorKind
  24412. * - VertexBuffer.MatricesIndicesKind
  24413. * - VertexBuffer.MatricesIndicesExtraKind
  24414. * - VertexBuffer.MatricesWeightsKind
  24415. * - VertexBuffer.MatricesWeightsExtraKind
  24416. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24417. */
  24418. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24419. /**
  24420. * Sets the mesh global Vertex Buffer
  24421. * @param buffer defines the buffer to use
  24422. * @returns the current mesh
  24423. */
  24424. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24425. /**
  24426. * Update a specific associated vertex buffer
  24427. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24428. * - VertexBuffer.PositionKind
  24429. * - VertexBuffer.UVKind
  24430. * - VertexBuffer.UV2Kind
  24431. * - VertexBuffer.UV3Kind
  24432. * - VertexBuffer.UV4Kind
  24433. * - VertexBuffer.UV5Kind
  24434. * - VertexBuffer.UV6Kind
  24435. * - VertexBuffer.ColorKind
  24436. * - VertexBuffer.MatricesIndicesKind
  24437. * - VertexBuffer.MatricesIndicesExtraKind
  24438. * - VertexBuffer.MatricesWeightsKind
  24439. * - VertexBuffer.MatricesWeightsExtraKind
  24440. * @param data defines the data source
  24441. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24442. * @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)
  24443. * @returns the current mesh
  24444. */
  24445. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24446. /**
  24447. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24448. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24449. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24450. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24451. * @returns the current mesh
  24452. */
  24453. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24454. /**
  24455. * Creates a un-shared specific occurence of the geometry for the mesh.
  24456. * @returns the current mesh
  24457. */
  24458. makeGeometryUnique(): Mesh;
  24459. /**
  24460. * Set the index buffer of this mesh
  24461. * @param indices defines the source data
  24462. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24463. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24464. * @returns the current mesh
  24465. */
  24466. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24467. /**
  24468. * Update the current index buffer
  24469. * @param indices defines the source data
  24470. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24471. * @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)
  24472. * @returns the current mesh
  24473. */
  24474. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24475. /**
  24476. * Invert the geometry to move from a right handed system to a left handed one.
  24477. * @returns the current mesh
  24478. */
  24479. toLeftHanded(): Mesh;
  24480. /** @hidden */
  24481. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24482. /** @hidden */
  24483. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24484. /**
  24485. * Registers for this mesh a javascript function called just before the rendering process
  24486. * @param func defines the function to call before rendering this mesh
  24487. * @returns the current mesh
  24488. */
  24489. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24490. /**
  24491. * Disposes a previously registered javascript function called before the rendering
  24492. * @param func defines the function to remove
  24493. * @returns the current mesh
  24494. */
  24495. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24496. /**
  24497. * Registers for this mesh a javascript function called just after the rendering is complete
  24498. * @param func defines the function to call after rendering this mesh
  24499. * @returns the current mesh
  24500. */
  24501. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24502. /**
  24503. * Disposes a previously registered javascript function called after the rendering.
  24504. * @param func defines the function to remove
  24505. * @returns the current mesh
  24506. */
  24507. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24508. /** @hidden */
  24509. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24510. /** @hidden */
  24511. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24512. /** @hidden */
  24513. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24514. /** @hidden */
  24515. _rebuild(): void;
  24516. /** @hidden */
  24517. _freeze(): void;
  24518. /** @hidden */
  24519. _unFreeze(): void;
  24520. /**
  24521. * 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
  24522. * @param subMesh defines the subMesh to render
  24523. * @param enableAlphaMode defines if alpha mode can be changed
  24524. * @returns the current mesh
  24525. */
  24526. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24527. private _onBeforeDraw;
  24528. /**
  24529. * Renormalize the mesh and patch it up if there are no weights
  24530. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24531. * However in the case of zero weights then we set just a single influence to 1.
  24532. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24533. */
  24534. cleanMatrixWeights(): void;
  24535. private normalizeSkinFourWeights;
  24536. private normalizeSkinWeightsAndExtra;
  24537. /**
  24538. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24539. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24540. * the user know there was an issue with importing the mesh
  24541. * @returns a validation object with skinned, valid and report string
  24542. */
  24543. validateSkinning(): {
  24544. skinned: boolean;
  24545. valid: boolean;
  24546. report: string;
  24547. };
  24548. /** @hidden */
  24549. _checkDelayState(): Mesh;
  24550. private _queueLoad;
  24551. /**
  24552. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24553. * A mesh is in the frustum if its bounding box intersects the frustum
  24554. * @param frustumPlanes defines the frustum to test
  24555. * @returns true if the mesh is in the frustum planes
  24556. */
  24557. isInFrustum(frustumPlanes: Plane[]): boolean;
  24558. /**
  24559. * Sets the mesh material by the material or multiMaterial `id` property
  24560. * @param id is a string identifying the material or the multiMaterial
  24561. * @returns the current mesh
  24562. */
  24563. setMaterialByID(id: string): Mesh;
  24564. /**
  24565. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24566. * @returns an array of IAnimatable
  24567. */
  24568. getAnimatables(): IAnimatable[];
  24569. /**
  24570. * Modifies the mesh geometry according to the passed transformation matrix.
  24571. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24572. * The mesh normals are modified using the same transformation.
  24573. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24574. * @param transform defines the transform matrix to use
  24575. * @see http://doc.babylonjs.com/resources/baking_transformations
  24576. * @returns the current mesh
  24577. */
  24578. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24579. /**
  24580. * Modifies the mesh geometry according to its own current World Matrix.
  24581. * The mesh World Matrix is then reset.
  24582. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24583. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24584. * @see http://doc.babylonjs.com/resources/baking_transformations
  24585. * @returns the current mesh
  24586. */
  24587. bakeCurrentTransformIntoVertices(): Mesh;
  24588. /** @hidden */
  24589. readonly _positions: Nullable<Vector3[]>;
  24590. /** @hidden */
  24591. _resetPointsArrayCache(): Mesh;
  24592. /** @hidden */
  24593. _generatePointsArray(): boolean;
  24594. /**
  24595. * Returns a new Mesh object generated from the current mesh properties.
  24596. * This method must not get confused with createInstance()
  24597. * @param name is a string, the name given to the new mesh
  24598. * @param newParent can be any Node object (default `null`)
  24599. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24600. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24601. * @returns a new mesh
  24602. */
  24603. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24604. /**
  24605. * Releases resources associated with this mesh.
  24606. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24607. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24608. */
  24609. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24610. /**
  24611. * Modifies the mesh geometry according to a displacement map.
  24612. * 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.
  24613. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24614. * @param url is a string, the URL from the image file is to be downloaded.
  24615. * @param minHeight is the lower limit of the displacement.
  24616. * @param maxHeight is the upper limit of the displacement.
  24617. * @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.
  24618. * @param uvOffset is an optional vector2 used to offset UV.
  24619. * @param uvScale is an optional vector2 used to scale UV.
  24620. * @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.
  24621. * @returns the Mesh.
  24622. */
  24623. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24624. /**
  24625. * Modifies the mesh geometry according to a displacementMap buffer.
  24626. * 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.
  24627. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24628. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24629. * @param heightMapWidth is the width of the buffer image.
  24630. * @param heightMapHeight is the height of the buffer image.
  24631. * @param minHeight is the lower limit of the displacement.
  24632. * @param maxHeight is the upper limit of the displacement.
  24633. * @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.
  24634. * @param uvOffset is an optional vector2 used to offset UV.
  24635. * @param uvScale is an optional vector2 used to scale UV.
  24636. * @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.
  24637. * @returns the Mesh.
  24638. */
  24639. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24640. /**
  24641. * Modify the mesh to get a flat shading rendering.
  24642. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24643. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24644. * @returns current mesh
  24645. */
  24646. convertToFlatShadedMesh(): Mesh;
  24647. /**
  24648. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24649. * In other words, more vertices, no more indices and a single bigger VBO.
  24650. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24651. * @returns current mesh
  24652. */
  24653. convertToUnIndexedMesh(): Mesh;
  24654. /**
  24655. * Inverses facet orientations.
  24656. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24657. * @param flipNormals will also inverts the normals
  24658. * @returns current mesh
  24659. */
  24660. flipFaces(flipNormals?: boolean): Mesh;
  24661. /**
  24662. * Increase the number of facets and hence vertices in a mesh
  24663. * Vertex normals are interpolated from existing vertex normals
  24664. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24665. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24666. */
  24667. increaseVertices(numberPerEdge: number): void;
  24668. /**
  24669. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24670. * This will undo any application of covertToFlatShadedMesh
  24671. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24672. */
  24673. forceSharedVertices(): void;
  24674. /** @hidden */
  24675. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24676. /** @hidden */
  24677. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24678. /**
  24679. * Creates a new InstancedMesh object from the mesh model.
  24680. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24681. * @param name defines the name of the new instance
  24682. * @returns a new InstancedMesh
  24683. */
  24684. createInstance(name: string): InstancedMesh;
  24685. /**
  24686. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24687. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24688. * @returns the current mesh
  24689. */
  24690. synchronizeInstances(): Mesh;
  24691. /**
  24692. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24693. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24694. * This should be used together with the simplification to avoid disappearing triangles.
  24695. * @param successCallback an optional success callback to be called after the optimization finished.
  24696. * @returns the current mesh
  24697. */
  24698. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24699. /**
  24700. * Serialize current mesh
  24701. * @param serializationObject defines the object which will receive the serialization data
  24702. */
  24703. serialize(serializationObject: any): void;
  24704. /** @hidden */
  24705. _syncGeometryWithMorphTargetManager(): void;
  24706. /** @hidden */
  24707. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24708. /**
  24709. * Returns a new Mesh object parsed from the source provided.
  24710. * @param parsedMesh is the source
  24711. * @param scene defines the hosting scene
  24712. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24713. * @returns a new Mesh
  24714. */
  24715. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24716. /**
  24717. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24718. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24719. * @param name defines the name of the mesh to create
  24720. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24721. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24722. * @param closePath creates a seam between the first and the last points of each path of the path array
  24723. * @param offset is taken in account only if the `pathArray` is containing a single path
  24724. * @param scene defines the hosting scene
  24725. * @param updatable defines if the mesh must be flagged as updatable
  24726. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24727. * @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)
  24728. * @returns a new Mesh
  24729. */
  24730. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24731. /**
  24732. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24733. * @param name defines the name of the mesh to create
  24734. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24735. * @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
  24736. * @param scene defines the hosting scene
  24737. * @param updatable defines if the mesh must be flagged as updatable
  24738. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24739. * @returns a new Mesh
  24740. */
  24741. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24742. /**
  24743. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24744. * @param name defines the name of the mesh to create
  24745. * @param size sets the size (float) of each box side (default 1)
  24746. * @param scene defines the hosting scene
  24747. * @param updatable defines if the mesh must be flagged as updatable
  24748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24749. * @returns a new Mesh
  24750. */
  24751. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24752. /**
  24753. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24754. * @param name defines the name of the mesh to create
  24755. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24756. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24757. * @param scene defines the hosting scene
  24758. * @param updatable defines if the mesh must be flagged as updatable
  24759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24760. * @returns a new Mesh
  24761. */
  24762. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24763. /**
  24764. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24765. * @param name defines the name of the mesh to create
  24766. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24767. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24768. * @param scene defines the hosting scene
  24769. * @returns a new Mesh
  24770. */
  24771. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24772. /**
  24773. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24774. * @param name defines the name of the mesh to create
  24775. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24776. * @param diameterTop set the top cap diameter (floats, default 1)
  24777. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24778. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24779. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24780. * @param scene defines the hosting scene
  24781. * @param updatable defines if the mesh must be flagged as updatable
  24782. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24783. * @returns a new Mesh
  24784. */
  24785. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24786. /**
  24787. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24788. * @param name defines the name of the mesh to create
  24789. * @param diameter sets the diameter size (float) of the torus (default 1)
  24790. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24791. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24792. * @param scene defines the hosting scene
  24793. * @param updatable defines if the mesh must be flagged as updatable
  24794. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24795. * @returns a new Mesh
  24796. */
  24797. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24798. /**
  24799. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24800. * @param name defines the name of the mesh to create
  24801. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24802. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24803. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24804. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24805. * @param p the number of windings on X axis (positive integers, default 2)
  24806. * @param q the number of windings on Y axis (positive integers, default 3)
  24807. * @param scene defines the hosting scene
  24808. * @param updatable defines if the mesh must be flagged as updatable
  24809. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24810. * @returns a new Mesh
  24811. */
  24812. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24813. /**
  24814. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24815. * @param name defines the name of the mesh to create
  24816. * @param points is an array successive Vector3
  24817. * @param scene defines the hosting scene
  24818. * @param updatable defines if the mesh must be flagged as updatable
  24819. * @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).
  24820. * @returns a new Mesh
  24821. */
  24822. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24823. /**
  24824. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24825. * @param name defines the name of the mesh to create
  24826. * @param points is an array successive Vector3
  24827. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24828. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24829. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24830. * @param scene defines the hosting scene
  24831. * @param updatable defines if the mesh must be flagged as updatable
  24832. * @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)
  24833. * @returns a new Mesh
  24834. */
  24835. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24836. /**
  24837. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24838. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24839. * 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.
  24840. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24841. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24842. * Remember you can only change the shape positions, not their number when updating a polygon.
  24843. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24844. * @param name defines the name of the mesh to create
  24845. * @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
  24846. * @param scene defines the hosting scene
  24847. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24848. * @param updatable defines if the mesh must be flagged as updatable
  24849. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24850. * @param earcutInjection can be used to inject your own earcut reference
  24851. * @returns a new Mesh
  24852. */
  24853. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24854. /**
  24855. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24856. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24857. * @param name defines the name of the mesh to create
  24858. * @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
  24859. * @param depth defines the height of extrusion
  24860. * @param scene defines the hosting scene
  24861. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24862. * @param updatable defines if the mesh must be flagged as updatable
  24863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24864. * @param earcutInjection can be used to inject your own earcut reference
  24865. * @returns a new Mesh
  24866. */
  24867. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24868. /**
  24869. * Creates an extruded shape mesh.
  24870. * 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
  24871. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24872. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24873. * @param name defines the name of the mesh to create
  24874. * @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
  24875. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24876. * @param scale is the value to scale the shape
  24877. * @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
  24878. * @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
  24879. * @param scene defines the hosting scene
  24880. * @param updatable defines if the mesh must be flagged as updatable
  24881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24882. * @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)
  24883. * @returns a new Mesh
  24884. */
  24885. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24886. /**
  24887. * Creates an custom extruded shape mesh.
  24888. * The custom extrusion is a parametric shape.
  24889. * It has no predefined shape. Its final shape will depend on the input parameters.
  24890. * Please consider using the same method from the MeshBuilder class instead
  24891. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24892. * @param name defines the name of the mesh to create
  24893. * @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
  24894. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24895. * @param scaleFunction is a custom Javascript function called on each path point
  24896. * @param rotationFunction is a custom Javascript function called on each path point
  24897. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24898. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24899. * @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
  24900. * @param scene defines the hosting scene
  24901. * @param updatable defines if the mesh must be flagged as updatable
  24902. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24903. * @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)
  24904. * @returns a new Mesh
  24905. */
  24906. 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;
  24907. /**
  24908. * Creates lathe mesh.
  24909. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24910. * Please consider using the same method from the MeshBuilder class instead
  24911. * @param name defines the name of the mesh to create
  24912. * @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
  24913. * @param radius is the radius value of the lathe
  24914. * @param tessellation is the side number of the lathe.
  24915. * @param scene defines the hosting scene
  24916. * @param updatable defines if the mesh must be flagged as updatable
  24917. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24918. * @returns a new Mesh
  24919. */
  24920. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24921. /**
  24922. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24923. * @param name defines the name of the mesh to create
  24924. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24925. * @param scene defines the hosting scene
  24926. * @param updatable defines if the mesh must be flagged as updatable
  24927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24928. * @returns a new Mesh
  24929. */
  24930. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24931. /**
  24932. * Creates a ground mesh.
  24933. * Please consider using the same method from the MeshBuilder class instead
  24934. * @param name defines the name of the mesh to create
  24935. * @param width set the width of the ground
  24936. * @param height set the height of the ground
  24937. * @param subdivisions sets the number of subdivisions per side
  24938. * @param scene defines the hosting scene
  24939. * @param updatable defines if the mesh must be flagged as updatable
  24940. * @returns a new Mesh
  24941. */
  24942. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24943. /**
  24944. * Creates a tiled ground mesh.
  24945. * Please consider using the same method from the MeshBuilder class instead
  24946. * @param name defines the name of the mesh to create
  24947. * @param xmin set the ground minimum X coordinate
  24948. * @param zmin set the ground minimum Y coordinate
  24949. * @param xmax set the ground maximum X coordinate
  24950. * @param zmax set the ground maximum Z coordinate
  24951. * @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
  24952. * @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
  24953. * @param scene defines the hosting scene
  24954. * @param updatable defines if the mesh must be flagged as updatable
  24955. * @returns a new Mesh
  24956. */
  24957. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24958. w: number;
  24959. h: number;
  24960. }, precision: {
  24961. w: number;
  24962. h: number;
  24963. }, scene: Scene, updatable?: boolean): Mesh;
  24964. /**
  24965. * Creates a ground mesh from a height map.
  24966. * Please consider using the same method from the MeshBuilder class instead
  24967. * @see http://doc.babylonjs.com/babylon101/height_map
  24968. * @param name defines the name of the mesh to create
  24969. * @param url sets the URL of the height map image resource
  24970. * @param width set the ground width size
  24971. * @param height set the ground height size
  24972. * @param subdivisions sets the number of subdivision per side
  24973. * @param minHeight is the minimum altitude on the ground
  24974. * @param maxHeight is the maximum altitude on the ground
  24975. * @param scene defines the hosting scene
  24976. * @param updatable defines if the mesh must be flagged as updatable
  24977. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24978. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24979. * @returns a new Mesh
  24980. */
  24981. 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;
  24982. /**
  24983. * Creates a tube mesh.
  24984. * The tube is a parametric shape.
  24985. * It has no predefined shape. Its final shape will depend on the input parameters.
  24986. * Please consider using the same method from the MeshBuilder class instead
  24987. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24988. * @param name defines the name of the mesh to create
  24989. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24990. * @param radius sets the tube radius size
  24991. * @param tessellation is the number of sides on the tubular surface
  24992. * @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
  24993. * @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
  24994. * @param scene defines the hosting scene
  24995. * @param updatable defines if the mesh must be flagged as updatable
  24996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24997. * @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)
  24998. * @returns a new Mesh
  24999. */
  25000. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25001. (i: number, distance: number): number;
  25002. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25003. /**
  25004. * Creates a polyhedron mesh.
  25005. * Please consider using the same method from the MeshBuilder class instead.
  25006. * * 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
  25007. * * The parameter `size` (positive float, default 1) sets the polygon size
  25008. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25009. * * 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`
  25010. * * 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
  25011. * * 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)`)
  25012. * * 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
  25013. * * 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
  25014. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25015. * * If you create a double-sided mesh, you can choose what parts of 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
  25016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25017. * @param name defines the name of the mesh to create
  25018. * @param options defines the options used to create the mesh
  25019. * @param scene defines the hosting scene
  25020. * @returns a new Mesh
  25021. */
  25022. static CreatePolyhedron(name: string, options: {
  25023. type?: number;
  25024. size?: number;
  25025. sizeX?: number;
  25026. sizeY?: number;
  25027. sizeZ?: number;
  25028. custom?: any;
  25029. faceUV?: Vector4[];
  25030. faceColors?: Color4[];
  25031. updatable?: boolean;
  25032. sideOrientation?: number;
  25033. }, scene: Scene): Mesh;
  25034. /**
  25035. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25036. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25037. * * 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`)
  25038. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25039. * * 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
  25040. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25041. * * If you create a double-sided mesh, you can choose what parts of 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
  25042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25043. * @param name defines the name of the mesh
  25044. * @param options defines the options used to create the mesh
  25045. * @param scene defines the hosting scene
  25046. * @returns a new Mesh
  25047. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25048. */
  25049. static CreateIcoSphere(name: string, options: {
  25050. radius?: number;
  25051. flat?: boolean;
  25052. subdivisions?: number;
  25053. sideOrientation?: number;
  25054. updatable?: boolean;
  25055. }, scene: Scene): Mesh;
  25056. /**
  25057. * Creates a decal mesh.
  25058. * Please consider using the same method from the MeshBuilder class instead.
  25059. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25060. * @param name defines the name of the mesh
  25061. * @param sourceMesh defines the mesh receiving the decal
  25062. * @param position sets the position of the decal in world coordinates
  25063. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25064. * @param size sets the decal scaling
  25065. * @param angle sets the angle to rotate the decal
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25069. /**
  25070. * Prepare internal position array for software CPU skinning
  25071. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25072. */
  25073. setPositionsForCPUSkinning(): Float32Array;
  25074. /**
  25075. * Prepare internal normal array for software CPU skinning
  25076. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25077. */
  25078. setNormalsForCPUSkinning(): Float32Array;
  25079. /**
  25080. * Updates the vertex buffer by applying transformation from the bones
  25081. * @param skeleton defines the skeleton to apply to current mesh
  25082. * @returns the current mesh
  25083. */
  25084. applySkeleton(skeleton: Skeleton): Mesh;
  25085. /**
  25086. * 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
  25087. * @param meshes defines the list of meshes to scan
  25088. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25089. */
  25090. static MinMax(meshes: AbstractMesh[]): {
  25091. min: Vector3;
  25092. max: Vector3;
  25093. };
  25094. /**
  25095. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25096. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25097. * @returns a vector3
  25098. */
  25099. static Center(meshesOrMinMaxVector: {
  25100. min: Vector3;
  25101. max: Vector3;
  25102. } | AbstractMesh[]): Vector3;
  25103. /**
  25104. * Merge the array of meshes into a single mesh for performance reasons.
  25105. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25106. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25107. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25108. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25109. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25110. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25111. * @returns a new mesh
  25112. */
  25113. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25114. /** @hidden */
  25115. addInstance(instance: InstancedMesh): void;
  25116. /** @hidden */
  25117. removeInstance(instance: InstancedMesh): void;
  25118. }
  25119. }
  25120. declare module "babylonjs/Cameras/camera" {
  25121. import { SmartArray } from "babylonjs/Misc/smartArray";
  25122. import { Observable } from "babylonjs/Misc/observable";
  25123. import { Nullable } from "babylonjs/types";
  25124. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25125. import { Scene } from "babylonjs/scene";
  25126. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25127. import { Node } from "babylonjs/node";
  25128. import { Mesh } from "babylonjs/Meshes/mesh";
  25129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25130. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25131. import { Viewport } from "babylonjs/Maths/math.viewport";
  25132. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25134. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25135. import { Ray } from "babylonjs/Culling/ray";
  25136. /**
  25137. * This is the base class of all the camera used in the application.
  25138. * @see http://doc.babylonjs.com/features/cameras
  25139. */
  25140. export class Camera extends Node {
  25141. /** @hidden */
  25142. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25143. /**
  25144. * This is the default projection mode used by the cameras.
  25145. * It helps recreating a feeling of perspective and better appreciate depth.
  25146. * This is the best way to simulate real life cameras.
  25147. */
  25148. static readonly PERSPECTIVE_CAMERA: number;
  25149. /**
  25150. * This helps creating camera with an orthographic mode.
  25151. * 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.
  25152. */
  25153. static readonly ORTHOGRAPHIC_CAMERA: number;
  25154. /**
  25155. * This is the default FOV mode for perspective cameras.
  25156. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25157. */
  25158. static readonly FOVMODE_VERTICAL_FIXED: number;
  25159. /**
  25160. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25161. */
  25162. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25163. /**
  25164. * This specifies ther is no need for a camera rig.
  25165. * Basically only one eye is rendered corresponding to the camera.
  25166. */
  25167. static readonly RIG_MODE_NONE: number;
  25168. /**
  25169. * Simulates a camera Rig with one blue eye and one red eye.
  25170. * This can be use with 3d blue and red glasses.
  25171. */
  25172. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25173. /**
  25174. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25175. */
  25176. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25177. /**
  25178. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25179. */
  25180. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25181. /**
  25182. * Defines that both eyes of the camera will be rendered over under each other.
  25183. */
  25184. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25185. /**
  25186. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25187. */
  25188. static readonly RIG_MODE_VR: number;
  25189. /**
  25190. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25191. */
  25192. static readonly RIG_MODE_WEBVR: number;
  25193. /**
  25194. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25195. */
  25196. static readonly RIG_MODE_CUSTOM: number;
  25197. /**
  25198. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25199. */
  25200. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25201. /**
  25202. * Define the input manager associated with the camera.
  25203. */
  25204. inputs: CameraInputsManager<Camera>;
  25205. /** @hidden */
  25206. _position: Vector3;
  25207. /**
  25208. * Define the current local position of the camera in the scene
  25209. */
  25210. position: Vector3;
  25211. /**
  25212. * The vector the camera should consider as up.
  25213. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25214. */
  25215. upVector: Vector3;
  25216. /**
  25217. * Define the current limit on the left side for an orthographic camera
  25218. * In scene unit
  25219. */
  25220. orthoLeft: Nullable<number>;
  25221. /**
  25222. * Define the current limit on the right side for an orthographic camera
  25223. * In scene unit
  25224. */
  25225. orthoRight: Nullable<number>;
  25226. /**
  25227. * Define the current limit on the bottom side for an orthographic camera
  25228. * In scene unit
  25229. */
  25230. orthoBottom: Nullable<number>;
  25231. /**
  25232. * Define the current limit on the top side for an orthographic camera
  25233. * In scene unit
  25234. */
  25235. orthoTop: Nullable<number>;
  25236. /**
  25237. * Field Of View is set in Radians. (default is 0.8)
  25238. */
  25239. fov: number;
  25240. /**
  25241. * Define the minimum distance the camera can see from.
  25242. * This is important to note that the depth buffer are not infinite and the closer it starts
  25243. * the more your scene might encounter depth fighting issue.
  25244. */
  25245. minZ: number;
  25246. /**
  25247. * Define the maximum distance the camera can see to.
  25248. * This is important to note that the depth buffer are not infinite and the further it end
  25249. * the more your scene might encounter depth fighting issue.
  25250. */
  25251. maxZ: number;
  25252. /**
  25253. * Define the default inertia of the camera.
  25254. * This helps giving a smooth feeling to the camera movement.
  25255. */
  25256. inertia: number;
  25257. /**
  25258. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25259. */
  25260. mode: number;
  25261. /**
  25262. * Define wether the camera is intermediate.
  25263. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25264. */
  25265. isIntermediate: boolean;
  25266. /**
  25267. * Define the viewport of the camera.
  25268. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25269. */
  25270. viewport: Viewport;
  25271. /**
  25272. * Restricts the camera to viewing objects with the same layerMask.
  25273. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25274. */
  25275. layerMask: number;
  25276. /**
  25277. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25278. */
  25279. fovMode: number;
  25280. /**
  25281. * Rig mode of the camera.
  25282. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25283. * This is normally controlled byt the camera themselves as internal use.
  25284. */
  25285. cameraRigMode: number;
  25286. /**
  25287. * Defines the distance between both "eyes" in case of a RIG
  25288. */
  25289. interaxialDistance: number;
  25290. /**
  25291. * Defines if stereoscopic rendering is done side by side or over under.
  25292. */
  25293. isStereoscopicSideBySide: boolean;
  25294. /**
  25295. * 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
  25296. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25297. * else in the scene. (Eg. security camera)
  25298. *
  25299. * 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)
  25300. */
  25301. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25302. /**
  25303. * When set, the camera will render to this render target instead of the default canvas
  25304. *
  25305. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25306. */
  25307. outputRenderTarget: Nullable<RenderTargetTexture>;
  25308. /**
  25309. * Observable triggered when the camera view matrix has changed.
  25310. */
  25311. onViewMatrixChangedObservable: Observable<Camera>;
  25312. /**
  25313. * Observable triggered when the camera Projection matrix has changed.
  25314. */
  25315. onProjectionMatrixChangedObservable: Observable<Camera>;
  25316. /**
  25317. * Observable triggered when the inputs have been processed.
  25318. */
  25319. onAfterCheckInputsObservable: Observable<Camera>;
  25320. /**
  25321. * Observable triggered when reset has been called and applied to the camera.
  25322. */
  25323. onRestoreStateObservable: Observable<Camera>;
  25324. /** @hidden */
  25325. _cameraRigParams: any;
  25326. /** @hidden */
  25327. _rigCameras: Camera[];
  25328. /** @hidden */
  25329. _rigPostProcess: Nullable<PostProcess>;
  25330. protected _webvrViewMatrix: Matrix;
  25331. /** @hidden */
  25332. _skipRendering: boolean;
  25333. /** @hidden */
  25334. _projectionMatrix: Matrix;
  25335. /** @hidden */
  25336. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25337. /** @hidden */
  25338. _activeMeshes: SmartArray<AbstractMesh>;
  25339. protected _globalPosition: Vector3;
  25340. /** @hidden */
  25341. _computedViewMatrix: Matrix;
  25342. private _doNotComputeProjectionMatrix;
  25343. private _transformMatrix;
  25344. private _frustumPlanes;
  25345. private _refreshFrustumPlanes;
  25346. private _storedFov;
  25347. private _stateStored;
  25348. /**
  25349. * Instantiates a new camera object.
  25350. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25351. * @see http://doc.babylonjs.com/features/cameras
  25352. * @param name Defines the name of the camera in the scene
  25353. * @param position Defines the position of the camera
  25354. * @param scene Defines the scene the camera belongs too
  25355. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25356. */
  25357. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25358. /**
  25359. * Store current camera state (fov, position, etc..)
  25360. * @returns the camera
  25361. */
  25362. storeState(): Camera;
  25363. /**
  25364. * Restores the camera state values if it has been stored. You must call storeState() first
  25365. */
  25366. protected _restoreStateValues(): boolean;
  25367. /**
  25368. * Restored camera state. You must call storeState() first.
  25369. * @returns true if restored and false otherwise
  25370. */
  25371. restoreState(): boolean;
  25372. /**
  25373. * Gets the class name of the camera.
  25374. * @returns the class name
  25375. */
  25376. getClassName(): string;
  25377. /** @hidden */
  25378. readonly _isCamera: boolean;
  25379. /**
  25380. * Gets a string representation of the camera useful for debug purpose.
  25381. * @param fullDetails Defines that a more verboe level of logging is required
  25382. * @returns the string representation
  25383. */
  25384. toString(fullDetails?: boolean): string;
  25385. /**
  25386. * Gets the current world space position of the camera.
  25387. */
  25388. readonly globalPosition: Vector3;
  25389. /**
  25390. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25391. * @returns the active meshe list
  25392. */
  25393. getActiveMeshes(): SmartArray<AbstractMesh>;
  25394. /**
  25395. * Check wether a mesh is part of the current active mesh list of the camera
  25396. * @param mesh Defines the mesh to check
  25397. * @returns true if active, false otherwise
  25398. */
  25399. isActiveMesh(mesh: Mesh): boolean;
  25400. /**
  25401. * Is this camera ready to be used/rendered
  25402. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25403. * @return true if the camera is ready
  25404. */
  25405. isReady(completeCheck?: boolean): boolean;
  25406. /** @hidden */
  25407. _initCache(): void;
  25408. /** @hidden */
  25409. _updateCache(ignoreParentClass?: boolean): void;
  25410. /** @hidden */
  25411. _isSynchronized(): boolean;
  25412. /** @hidden */
  25413. _isSynchronizedViewMatrix(): boolean;
  25414. /** @hidden */
  25415. _isSynchronizedProjectionMatrix(): boolean;
  25416. /**
  25417. * Attach the input controls to a specific dom element to get the input from.
  25418. * @param element Defines the element the controls should be listened from
  25419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25420. */
  25421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25422. /**
  25423. * Detach the current controls from the specified dom element.
  25424. * @param element Defines the element to stop listening the inputs from
  25425. */
  25426. detachControl(element: HTMLElement): void;
  25427. /**
  25428. * Update the camera state according to the different inputs gathered during the frame.
  25429. */
  25430. update(): void;
  25431. /** @hidden */
  25432. _checkInputs(): void;
  25433. /** @hidden */
  25434. readonly rigCameras: Camera[];
  25435. /**
  25436. * Gets the post process used by the rig cameras
  25437. */
  25438. readonly rigPostProcess: Nullable<PostProcess>;
  25439. /**
  25440. * Internal, gets the first post proces.
  25441. * @returns the first post process to be run on this camera.
  25442. */
  25443. _getFirstPostProcess(): Nullable<PostProcess>;
  25444. private _cascadePostProcessesToRigCams;
  25445. /**
  25446. * Attach a post process to the camera.
  25447. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25448. * @param postProcess The post process to attach to the camera
  25449. * @param insertAt The position of the post process in case several of them are in use in the scene
  25450. * @returns the position the post process has been inserted at
  25451. */
  25452. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25453. /**
  25454. * Detach a post process to the camera.
  25455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25456. * @param postProcess The post process to detach from the camera
  25457. */
  25458. detachPostProcess(postProcess: PostProcess): void;
  25459. /**
  25460. * Gets the current world matrix of the camera
  25461. */
  25462. getWorldMatrix(): Matrix;
  25463. /** @hidden */
  25464. _getViewMatrix(): Matrix;
  25465. /**
  25466. * Gets the current view matrix of the camera.
  25467. * @param force forces the camera to recompute the matrix without looking at the cached state
  25468. * @returns the view matrix
  25469. */
  25470. getViewMatrix(force?: boolean): Matrix;
  25471. /**
  25472. * Freeze the projection matrix.
  25473. * It will prevent the cache check of the camera projection compute and can speed up perf
  25474. * if no parameter of the camera are meant to change
  25475. * @param projection Defines manually a projection if necessary
  25476. */
  25477. freezeProjectionMatrix(projection?: Matrix): void;
  25478. /**
  25479. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25480. */
  25481. unfreezeProjectionMatrix(): void;
  25482. /**
  25483. * Gets the current projection matrix of the camera.
  25484. * @param force forces the camera to recompute the matrix without looking at the cached state
  25485. * @returns the projection matrix
  25486. */
  25487. getProjectionMatrix(force?: boolean): Matrix;
  25488. /**
  25489. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25490. * @returns a Matrix
  25491. */
  25492. getTransformationMatrix(): Matrix;
  25493. private _updateFrustumPlanes;
  25494. /**
  25495. * Checks if a cullable object (mesh...) is in the camera frustum
  25496. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25497. * @param target The object to check
  25498. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25499. * @returns true if the object is in frustum otherwise false
  25500. */
  25501. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25502. /**
  25503. * Checks if a cullable object (mesh...) is in the camera frustum
  25504. * Unlike isInFrustum this cheks the full bounding box
  25505. * @param target The object to check
  25506. * @returns true if the object is in frustum otherwise false
  25507. */
  25508. isCompletelyInFrustum(target: ICullable): boolean;
  25509. /**
  25510. * Gets a ray in the forward direction from the camera.
  25511. * @param length Defines the length of the ray to create
  25512. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25513. * @param origin Defines the start point of the ray which defaults to the camera position
  25514. * @returns the forward ray
  25515. */
  25516. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25517. /**
  25518. * Releases resources associated with this node.
  25519. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25520. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25521. */
  25522. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25523. /** @hidden */
  25524. _isLeftCamera: boolean;
  25525. /**
  25526. * Gets the left camera of a rig setup in case of Rigged Camera
  25527. */
  25528. readonly isLeftCamera: boolean;
  25529. /** @hidden */
  25530. _isRightCamera: boolean;
  25531. /**
  25532. * Gets the right camera of a rig setup in case of Rigged Camera
  25533. */
  25534. readonly isRightCamera: boolean;
  25535. /**
  25536. * Gets the left camera of a rig setup in case of Rigged Camera
  25537. */
  25538. readonly leftCamera: Nullable<FreeCamera>;
  25539. /**
  25540. * Gets the right camera of a rig setup in case of Rigged Camera
  25541. */
  25542. readonly rightCamera: Nullable<FreeCamera>;
  25543. /**
  25544. * Gets the left camera target of a rig setup in case of Rigged Camera
  25545. * @returns the target position
  25546. */
  25547. getLeftTarget(): Nullable<Vector3>;
  25548. /**
  25549. * Gets the right camera target of a rig setup in case of Rigged Camera
  25550. * @returns the target position
  25551. */
  25552. getRightTarget(): Nullable<Vector3>;
  25553. /**
  25554. * @hidden
  25555. */
  25556. setCameraRigMode(mode: number, rigParams: any): void;
  25557. /** @hidden */
  25558. static _setStereoscopicRigMode(camera: Camera): void;
  25559. /** @hidden */
  25560. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25561. /** @hidden */
  25562. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25563. /** @hidden */
  25564. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25565. /** @hidden */
  25566. _getVRProjectionMatrix(): Matrix;
  25567. protected _updateCameraRotationMatrix(): void;
  25568. protected _updateWebVRCameraRotationMatrix(): void;
  25569. /**
  25570. * This function MUST be overwritten by the different WebVR cameras available.
  25571. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25572. * @hidden
  25573. */
  25574. _getWebVRProjectionMatrix(): Matrix;
  25575. /**
  25576. * This function MUST be overwritten by the different WebVR cameras available.
  25577. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25578. * @hidden
  25579. */
  25580. _getWebVRViewMatrix(): Matrix;
  25581. /** @hidden */
  25582. setCameraRigParameter(name: string, value: any): void;
  25583. /**
  25584. * needs to be overridden by children so sub has required properties to be copied
  25585. * @hidden
  25586. */
  25587. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25588. /**
  25589. * May need to be overridden by children
  25590. * @hidden
  25591. */
  25592. _updateRigCameras(): void;
  25593. /** @hidden */
  25594. _setupInputs(): void;
  25595. /**
  25596. * Serialiaze the camera setup to a json represention
  25597. * @returns the JSON representation
  25598. */
  25599. serialize(): any;
  25600. /**
  25601. * Clones the current camera.
  25602. * @param name The cloned camera name
  25603. * @returns the cloned camera
  25604. */
  25605. clone(name: string): Camera;
  25606. /**
  25607. * Gets the direction of the camera relative to a given local axis.
  25608. * @param localAxis Defines the reference axis to provide a relative direction.
  25609. * @return the direction
  25610. */
  25611. getDirection(localAxis: Vector3): Vector3;
  25612. /**
  25613. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25614. * @param localAxis Defines the reference axis to provide a relative direction.
  25615. * @param result Defines the vector to store the result in
  25616. */
  25617. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25618. /**
  25619. * Gets a camera constructor for a given camera type
  25620. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25621. * @param name The name of the camera the result will be able to instantiate
  25622. * @param scene The scene the result will construct the camera in
  25623. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25624. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25625. * @returns a factory method to construc the camera
  25626. */
  25627. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25628. /**
  25629. * Compute the world matrix of the camera.
  25630. * @returns the camera workd matrix
  25631. */
  25632. computeWorldMatrix(): Matrix;
  25633. /**
  25634. * Parse a JSON and creates the camera from the parsed information
  25635. * @param parsedCamera The JSON to parse
  25636. * @param scene The scene to instantiate the camera in
  25637. * @returns the newly constructed camera
  25638. */
  25639. static Parse(parsedCamera: any, scene: Scene): Camera;
  25640. }
  25641. }
  25642. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25643. import { Nullable } from "babylonjs/types";
  25644. import { Scene } from "babylonjs/scene";
  25645. import { Vector4 } from "babylonjs/Maths/math.vector";
  25646. import { Mesh } from "babylonjs/Meshes/mesh";
  25647. /**
  25648. * Class containing static functions to help procedurally build meshes
  25649. */
  25650. export class DiscBuilder {
  25651. /**
  25652. * Creates a plane polygonal mesh. By default, this is a disc
  25653. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25654. * * 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
  25655. * * 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
  25656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25659. * @param name defines the name of the mesh
  25660. * @param options defines the options used to create the mesh
  25661. * @param scene defines the hosting scene
  25662. * @returns the plane polygonal mesh
  25663. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25664. */
  25665. static CreateDisc(name: string, options: {
  25666. radius?: number;
  25667. tessellation?: number;
  25668. arc?: number;
  25669. updatable?: boolean;
  25670. sideOrientation?: number;
  25671. frontUVs?: Vector4;
  25672. backUVs?: Vector4;
  25673. }, scene?: Nullable<Scene>): Mesh;
  25674. }
  25675. }
  25676. declare module "babylonjs/Particles/solidParticleSystem" {
  25677. import { Vector3 } from "babylonjs/Maths/math.vector";
  25678. import { Mesh } from "babylonjs/Meshes/mesh";
  25679. import { Scene, IDisposable } from "babylonjs/scene";
  25680. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25681. /**
  25682. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25683. *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.
  25684. * The SPS is also a particle system. It provides some methods to manage the particles.
  25685. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25686. *
  25687. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25688. */
  25689. export class SolidParticleSystem implements IDisposable {
  25690. /**
  25691. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25692. * Example : var p = SPS.particles[i];
  25693. */
  25694. particles: SolidParticle[];
  25695. /**
  25696. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25697. */
  25698. nbParticles: number;
  25699. /**
  25700. * If the particles must ever face the camera (default false). Useful for planar particles.
  25701. */
  25702. billboard: boolean;
  25703. /**
  25704. * Recompute normals when adding a shape
  25705. */
  25706. recomputeNormals: boolean;
  25707. /**
  25708. * This a counter ofr your own usage. It's not set by any SPS functions.
  25709. */
  25710. counter: number;
  25711. /**
  25712. * The SPS name. This name is also given to the underlying mesh.
  25713. */
  25714. name: string;
  25715. /**
  25716. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25717. */
  25718. mesh: Mesh;
  25719. /**
  25720. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25721. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25722. */
  25723. vars: any;
  25724. /**
  25725. * This array is populated when the SPS is set as 'pickable'.
  25726. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25727. * Each element of this array is an object `{idx: int, faceId: int}`.
  25728. * `idx` is the picked particle index in the `SPS.particles` array
  25729. * `faceId` is the picked face index counted within this particle.
  25730. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25731. */
  25732. pickedParticles: {
  25733. idx: number;
  25734. faceId: number;
  25735. }[];
  25736. /**
  25737. * This array is populated when `enableDepthSort` is set to true.
  25738. * Each element of this array is an instance of the class DepthSortedParticle.
  25739. */
  25740. depthSortedParticles: DepthSortedParticle[];
  25741. /**
  25742. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25743. * @hidden
  25744. */
  25745. _bSphereOnly: boolean;
  25746. /**
  25747. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25748. * @hidden
  25749. */
  25750. _bSphereRadiusFactor: number;
  25751. private _scene;
  25752. private _positions;
  25753. private _indices;
  25754. private _normals;
  25755. private _colors;
  25756. private _uvs;
  25757. private _indices32;
  25758. private _positions32;
  25759. private _normals32;
  25760. private _fixedNormal32;
  25761. private _colors32;
  25762. private _uvs32;
  25763. private _index;
  25764. private _updatable;
  25765. private _pickable;
  25766. private _isVisibilityBoxLocked;
  25767. private _alwaysVisible;
  25768. private _depthSort;
  25769. private _shapeCounter;
  25770. private _copy;
  25771. private _color;
  25772. private _computeParticleColor;
  25773. private _computeParticleTexture;
  25774. private _computeParticleRotation;
  25775. private _computeParticleVertex;
  25776. private _computeBoundingBox;
  25777. private _depthSortParticles;
  25778. private _camera;
  25779. private _mustUnrotateFixedNormals;
  25780. private _particlesIntersect;
  25781. private _needs32Bits;
  25782. /**
  25783. * Creates a SPS (Solid Particle System) object.
  25784. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25785. * @param scene (Scene) is the scene in which the SPS is added.
  25786. * @param options defines the options of the sps e.g.
  25787. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25788. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25789. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25790. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25791. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25792. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25793. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25794. */
  25795. constructor(name: string, scene: Scene, options?: {
  25796. updatable?: boolean;
  25797. isPickable?: boolean;
  25798. enableDepthSort?: boolean;
  25799. particleIntersection?: boolean;
  25800. boundingSphereOnly?: boolean;
  25801. bSphereRadiusFactor?: number;
  25802. });
  25803. /**
  25804. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25805. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25806. * @returns the created mesh
  25807. */
  25808. buildMesh(): Mesh;
  25809. /**
  25810. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25811. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25812. * Thus the particles generated from `digest()` have their property `position` set yet.
  25813. * @param mesh ( Mesh ) is the mesh to be digested
  25814. * @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
  25815. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25816. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25817. * @returns the current SPS
  25818. */
  25819. digest(mesh: Mesh, options?: {
  25820. facetNb?: number;
  25821. number?: number;
  25822. delta?: number;
  25823. }): SolidParticleSystem;
  25824. private _unrotateFixedNormals;
  25825. private _resetCopy;
  25826. private _meshBuilder;
  25827. private _posToShape;
  25828. private _uvsToShapeUV;
  25829. private _addParticle;
  25830. /**
  25831. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25832. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25833. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25834. * @param nb (positive integer) the number of particles to be created from this model
  25835. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25836. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25837. * @returns the number of shapes in the system
  25838. */
  25839. addShape(mesh: Mesh, nb: number, options?: {
  25840. positionFunction?: any;
  25841. vertexFunction?: any;
  25842. }): number;
  25843. private _rebuildParticle;
  25844. /**
  25845. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25846. * @returns the SPS.
  25847. */
  25848. rebuildMesh(): SolidParticleSystem;
  25849. /**
  25850. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25851. * This method calls `updateParticle()` for each particle of the SPS.
  25852. * For an animated SPS, it is usually called within the render loop.
  25853. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25854. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25855. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25856. * @returns the SPS.
  25857. */
  25858. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25859. /**
  25860. * Disposes the SPS.
  25861. */
  25862. dispose(): void;
  25863. /**
  25864. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25865. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25866. * @returns the SPS.
  25867. */
  25868. refreshVisibleSize(): SolidParticleSystem;
  25869. /**
  25870. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25871. * @param size the size (float) of the visibility box
  25872. * note : this doesn't lock the SPS mesh bounding box.
  25873. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25874. */
  25875. setVisibilityBox(size: number): void;
  25876. /**
  25877. * Gets whether the SPS as always visible or not
  25878. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25879. */
  25880. /**
  25881. * Sets the SPS as always visible or not
  25882. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25883. */
  25884. isAlwaysVisible: boolean;
  25885. /**
  25886. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25888. */
  25889. /**
  25890. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25892. */
  25893. isVisibilityBoxLocked: boolean;
  25894. /**
  25895. * Tells to `setParticles()` to compute the particle rotations or not.
  25896. * Default value : true. The SPS is faster when it's set to false.
  25897. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25898. */
  25899. /**
  25900. * Gets if `setParticles()` computes the particle rotations or not.
  25901. * Default value : true. The SPS is faster when it's set to false.
  25902. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25903. */
  25904. computeParticleRotation: boolean;
  25905. /**
  25906. * Tells to `setParticles()` to compute the particle colors or not.
  25907. * Default value : true. The SPS is faster when it's set to false.
  25908. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25909. */
  25910. /**
  25911. * Gets if `setParticles()` computes the particle colors or not.
  25912. * Default value : true. The SPS is faster when it's set to false.
  25913. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25914. */
  25915. computeParticleColor: boolean;
  25916. /**
  25917. * Gets if `setParticles()` computes the particle textures or not.
  25918. * Default value : true. The SPS is faster when it's set to false.
  25919. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25920. */
  25921. computeParticleTexture: boolean;
  25922. /**
  25923. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25924. * Default value : false. The SPS is faster when it's set to false.
  25925. * Note : the particle custom vertex positions aren't stored values.
  25926. */
  25927. /**
  25928. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25929. * Default value : false. The SPS is faster when it's set to false.
  25930. * Note : the particle custom vertex positions aren't stored values.
  25931. */
  25932. computeParticleVertex: boolean;
  25933. /**
  25934. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25935. */
  25936. /**
  25937. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25938. */
  25939. computeBoundingBox: boolean;
  25940. /**
  25941. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25942. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25943. * Default : `true`
  25944. */
  25945. /**
  25946. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25947. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25948. * Default : `true`
  25949. */
  25950. depthSortParticles: boolean;
  25951. /**
  25952. * This function does nothing. It may be overwritten to set all the particle first values.
  25953. * The SPS doesn't call this function, you may have to call it by your own.
  25954. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25955. */
  25956. initParticles(): void;
  25957. /**
  25958. * This function does nothing. It may be overwritten to recycle a particle.
  25959. * The SPS doesn't call this function, you may have to call it by your own.
  25960. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25961. * @param particle The particle to recycle
  25962. * @returns the recycled particle
  25963. */
  25964. recycleParticle(particle: SolidParticle): SolidParticle;
  25965. /**
  25966. * Updates a particle : this function should be overwritten by the user.
  25967. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25968. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25969. * @example : just set a particle position or velocity and recycle conditions
  25970. * @param particle The particle to update
  25971. * @returns the updated particle
  25972. */
  25973. updateParticle(particle: SolidParticle): SolidParticle;
  25974. /**
  25975. * Updates a vertex of a particle : it can be overwritten by the user.
  25976. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25977. * @param particle the current particle
  25978. * @param vertex the current index of the current particle
  25979. * @param pt the index of the current vertex in the particle shape
  25980. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25981. * @example : just set a vertex particle position
  25982. * @returns the updated vertex
  25983. */
  25984. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25985. /**
  25986. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25987. * This does nothing and may be overwritten by the user.
  25988. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25989. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25990. * @param update the boolean update value actually passed to setParticles()
  25991. */
  25992. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25993. /**
  25994. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25995. * This will be passed three parameters.
  25996. * This does nothing and may be overwritten by the user.
  25997. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25998. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25999. * @param update the boolean update value actually passed to setParticles()
  26000. */
  26001. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26002. }
  26003. }
  26004. declare module "babylonjs/Particles/solidParticle" {
  26005. import { Nullable } from "babylonjs/types";
  26006. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26007. import { Color4 } from "babylonjs/Maths/math.color";
  26008. import { Mesh } from "babylonjs/Meshes/mesh";
  26009. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26010. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26011. import { Plane } from "babylonjs/Maths/math.plane";
  26012. /**
  26013. * Represents one particle of a solid particle system.
  26014. */
  26015. export class SolidParticle {
  26016. /**
  26017. * particle global index
  26018. */
  26019. idx: number;
  26020. /**
  26021. * The color of the particle
  26022. */
  26023. color: Nullable<Color4>;
  26024. /**
  26025. * The world space position of the particle.
  26026. */
  26027. position: Vector3;
  26028. /**
  26029. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26030. */
  26031. rotation: Vector3;
  26032. /**
  26033. * The world space rotation quaternion of the particle.
  26034. */
  26035. rotationQuaternion: Nullable<Quaternion>;
  26036. /**
  26037. * The scaling of the particle.
  26038. */
  26039. scaling: Vector3;
  26040. /**
  26041. * The uvs of the particle.
  26042. */
  26043. uvs: Vector4;
  26044. /**
  26045. * The current speed of the particle.
  26046. */
  26047. velocity: Vector3;
  26048. /**
  26049. * The pivot point in the particle local space.
  26050. */
  26051. pivot: Vector3;
  26052. /**
  26053. * Must the particle be translated from its pivot point in its local space ?
  26054. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26055. * Default : false
  26056. */
  26057. translateFromPivot: boolean;
  26058. /**
  26059. * Is the particle active or not ?
  26060. */
  26061. alive: boolean;
  26062. /**
  26063. * Is the particle visible or not ?
  26064. */
  26065. isVisible: boolean;
  26066. /**
  26067. * Index of this particle in the global "positions" array (Internal use)
  26068. * @hidden
  26069. */
  26070. _pos: number;
  26071. /**
  26072. * @hidden Index of this particle in the global "indices" array (Internal use)
  26073. */
  26074. _ind: number;
  26075. /**
  26076. * @hidden ModelShape of this particle (Internal use)
  26077. */
  26078. _model: ModelShape;
  26079. /**
  26080. * ModelShape id of this particle
  26081. */
  26082. shapeId: number;
  26083. /**
  26084. * Index of the particle in its shape id
  26085. */
  26086. idxInShape: number;
  26087. /**
  26088. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26089. */
  26090. _modelBoundingInfo: BoundingInfo;
  26091. /**
  26092. * @hidden Particle BoundingInfo object (Internal use)
  26093. */
  26094. _boundingInfo: BoundingInfo;
  26095. /**
  26096. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26097. */
  26098. _sps: SolidParticleSystem;
  26099. /**
  26100. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26101. */
  26102. _stillInvisible: boolean;
  26103. /**
  26104. * @hidden Last computed particle rotation matrix
  26105. */
  26106. _rotationMatrix: number[];
  26107. /**
  26108. * Parent particle Id, if any.
  26109. * Default null.
  26110. */
  26111. parentId: Nullable<number>;
  26112. /**
  26113. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26114. * The possible values are :
  26115. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26116. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26117. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26118. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26119. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26120. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26121. * */
  26122. cullingStrategy: number;
  26123. /**
  26124. * @hidden Internal global position in the SPS.
  26125. */
  26126. _globalPosition: Vector3;
  26127. /**
  26128. * Creates a Solid Particle object.
  26129. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26130. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26131. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26132. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26133. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26134. * @param shapeId (integer) is the model shape identifier in the SPS.
  26135. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26136. * @param sps defines the sps it is associated to
  26137. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26138. */
  26139. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26140. /**
  26141. * Legacy support, changed scale to scaling
  26142. */
  26143. /**
  26144. * Legacy support, changed scale to scaling
  26145. */
  26146. scale: Vector3;
  26147. /**
  26148. * Legacy support, changed quaternion to rotationQuaternion
  26149. */
  26150. /**
  26151. * Legacy support, changed quaternion to rotationQuaternion
  26152. */
  26153. quaternion: Nullable<Quaternion>;
  26154. /**
  26155. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26156. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26157. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26158. * @returns true if it intersects
  26159. */
  26160. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26161. /**
  26162. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26163. * A particle is in the frustum if its bounding box intersects the frustum
  26164. * @param frustumPlanes defines the frustum to test
  26165. * @returns true if the particle is in the frustum planes
  26166. */
  26167. isInFrustum(frustumPlanes: Plane[]): boolean;
  26168. /**
  26169. * get the rotation matrix of the particle
  26170. * @hidden
  26171. */
  26172. getRotationMatrix(m: Matrix): void;
  26173. }
  26174. /**
  26175. * Represents the shape of the model used by one particle of a solid particle system.
  26176. * SPS internal tool, don't use it manually.
  26177. */
  26178. export class ModelShape {
  26179. /**
  26180. * The shape id
  26181. * @hidden
  26182. */
  26183. shapeID: number;
  26184. /**
  26185. * flat array of model positions (internal use)
  26186. * @hidden
  26187. */
  26188. _shape: Vector3[];
  26189. /**
  26190. * flat array of model UVs (internal use)
  26191. * @hidden
  26192. */
  26193. _shapeUV: number[];
  26194. /**
  26195. * length of the shape in the model indices array (internal use)
  26196. * @hidden
  26197. */
  26198. _indicesLength: number;
  26199. /**
  26200. * Custom position function (internal use)
  26201. * @hidden
  26202. */
  26203. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26204. /**
  26205. * Custom vertex function (internal use)
  26206. * @hidden
  26207. */
  26208. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26209. /**
  26210. * 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.
  26211. * SPS internal tool, don't use it manually.
  26212. * @hidden
  26213. */
  26214. 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>);
  26215. }
  26216. /**
  26217. * Represents a Depth Sorted Particle in the solid particle system.
  26218. */
  26219. export class DepthSortedParticle {
  26220. /**
  26221. * Index of the particle in the "indices" array
  26222. */
  26223. ind: number;
  26224. /**
  26225. * Length of the particle shape in the "indices" array
  26226. */
  26227. indicesLength: number;
  26228. /**
  26229. * Squared distance from the particle to the camera
  26230. */
  26231. sqDistance: number;
  26232. }
  26233. }
  26234. declare module "babylonjs/Collisions/meshCollisionData" {
  26235. import { Collider } from "babylonjs/Collisions/collider";
  26236. import { Vector3 } from "babylonjs/Maths/math.vector";
  26237. import { Nullable } from "babylonjs/types";
  26238. import { Observer } from "babylonjs/Misc/observable";
  26239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26240. /**
  26241. * @hidden
  26242. */
  26243. export class _MeshCollisionData {
  26244. _checkCollisions: boolean;
  26245. _collisionMask: number;
  26246. _collisionGroup: number;
  26247. _collider: Nullable<Collider>;
  26248. _oldPositionForCollisions: Vector3;
  26249. _diffPositionForCollisions: Vector3;
  26250. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26251. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26252. }
  26253. }
  26254. declare module "babylonjs/Meshes/abstractMesh" {
  26255. import { Observable } from "babylonjs/Misc/observable";
  26256. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26257. import { Camera } from "babylonjs/Cameras/camera";
  26258. import { Scene, IDisposable } from "babylonjs/scene";
  26259. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26260. import { Node } from "babylonjs/node";
  26261. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26262. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26263. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26264. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26265. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26266. import { Material } from "babylonjs/Materials/material";
  26267. import { Light } from "babylonjs/Lights/light";
  26268. import { Skeleton } from "babylonjs/Bones/skeleton";
  26269. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26270. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26271. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26272. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26273. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26274. import { Plane } from "babylonjs/Maths/math.plane";
  26275. import { Ray } from "babylonjs/Culling/ray";
  26276. import { Collider } from "babylonjs/Collisions/collider";
  26277. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26278. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26279. /** @hidden */
  26280. class _FacetDataStorage {
  26281. facetPositions: Vector3[];
  26282. facetNormals: Vector3[];
  26283. facetPartitioning: number[][];
  26284. facetNb: number;
  26285. partitioningSubdivisions: number;
  26286. partitioningBBoxRatio: number;
  26287. facetDataEnabled: boolean;
  26288. facetParameters: any;
  26289. bbSize: Vector3;
  26290. subDiv: {
  26291. max: number;
  26292. X: number;
  26293. Y: number;
  26294. Z: number;
  26295. };
  26296. facetDepthSort: boolean;
  26297. facetDepthSortEnabled: boolean;
  26298. depthSortedIndices: IndicesArray;
  26299. depthSortedFacets: {
  26300. ind: number;
  26301. sqDistance: number;
  26302. }[];
  26303. facetDepthSortFunction: (f1: {
  26304. ind: number;
  26305. sqDistance: number;
  26306. }, f2: {
  26307. ind: number;
  26308. sqDistance: number;
  26309. }) => number;
  26310. facetDepthSortFrom: Vector3;
  26311. facetDepthSortOrigin: Vector3;
  26312. invertedMatrix: Matrix;
  26313. }
  26314. /**
  26315. * @hidden
  26316. **/
  26317. class _InternalAbstractMeshDataInfo {
  26318. _hasVertexAlpha: boolean;
  26319. _useVertexColors: boolean;
  26320. _numBoneInfluencers: number;
  26321. _applyFog: boolean;
  26322. _receiveShadows: boolean;
  26323. _facetData: _FacetDataStorage;
  26324. _visibility: number;
  26325. _skeleton: Nullable<Skeleton>;
  26326. _layerMask: number;
  26327. _computeBonesUsingShaders: boolean;
  26328. _isActive: boolean;
  26329. _onlyForInstances: boolean;
  26330. _isActiveIntermediate: boolean;
  26331. _onlyForInstancesIntermediate: boolean;
  26332. }
  26333. /**
  26334. * Class used to store all common mesh properties
  26335. */
  26336. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26337. /** No occlusion */
  26338. static OCCLUSION_TYPE_NONE: number;
  26339. /** Occlusion set to optimisitic */
  26340. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26341. /** Occlusion set to strict */
  26342. static OCCLUSION_TYPE_STRICT: number;
  26343. /** Use an accurante occlusion algorithm */
  26344. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26345. /** Use a conservative occlusion algorithm */
  26346. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26347. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26348. * Test order :
  26349. * Is the bounding sphere outside the frustum ?
  26350. * If not, are the bounding box vertices outside the frustum ?
  26351. * It not, then the cullable object is in the frustum.
  26352. */
  26353. static readonly CULLINGSTRATEGY_STANDARD: number;
  26354. /** Culling strategy : Bounding Sphere Only.
  26355. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26356. * It's also less accurate than the standard because some not visible objects can still be selected.
  26357. * Test : is the bounding sphere outside the frustum ?
  26358. * If not, then the cullable object is in the frustum.
  26359. */
  26360. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26361. /** Culling strategy : Optimistic Inclusion.
  26362. * This in an inclusion test first, then the standard exclusion test.
  26363. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26364. * 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.
  26365. * Anyway, it's as accurate as the standard strategy.
  26366. * Test :
  26367. * Is the cullable object bounding sphere center in the frustum ?
  26368. * If not, apply the default culling strategy.
  26369. */
  26370. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26371. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26372. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26373. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26374. * 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.
  26375. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26376. * Test :
  26377. * Is the cullable object bounding sphere center in the frustum ?
  26378. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26379. */
  26380. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26381. /**
  26382. * No billboard
  26383. */
  26384. static readonly BILLBOARDMODE_NONE: number;
  26385. /** Billboard on X axis */
  26386. static readonly BILLBOARDMODE_X: number;
  26387. /** Billboard on Y axis */
  26388. static readonly BILLBOARDMODE_Y: number;
  26389. /** Billboard on Z axis */
  26390. static readonly BILLBOARDMODE_Z: number;
  26391. /** Billboard on all axes */
  26392. static readonly BILLBOARDMODE_ALL: number;
  26393. /** Billboard on using position instead of orientation */
  26394. static readonly BILLBOARDMODE_USE_POSITION: number;
  26395. /** @hidden */
  26396. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26397. /**
  26398. * The culling strategy to use to check whether the mesh must be rendered or not.
  26399. * This value can be changed at any time and will be used on the next render mesh selection.
  26400. * The possible values are :
  26401. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26402. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26403. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26404. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26405. * Please read each static variable documentation to get details about the culling process.
  26406. * */
  26407. cullingStrategy: number;
  26408. /**
  26409. * Gets the number of facets in the mesh
  26410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26411. */
  26412. readonly facetNb: number;
  26413. /**
  26414. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26415. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26416. */
  26417. partitioningSubdivisions: number;
  26418. /**
  26419. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26420. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26422. */
  26423. partitioningBBoxRatio: number;
  26424. /**
  26425. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26426. * Works only for updatable meshes.
  26427. * Doesn't work with multi-materials
  26428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26429. */
  26430. mustDepthSortFacets: boolean;
  26431. /**
  26432. * The location (Vector3) where the facet depth sort must be computed from.
  26433. * By default, the active camera position.
  26434. * Used only when facet depth sort is enabled
  26435. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26436. */
  26437. facetDepthSortFrom: Vector3;
  26438. /**
  26439. * gets a boolean indicating if facetData is enabled
  26440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26441. */
  26442. readonly isFacetDataEnabled: boolean;
  26443. /** @hidden */
  26444. _updateNonUniformScalingState(value: boolean): boolean;
  26445. /**
  26446. * An event triggered when this mesh collides with another one
  26447. */
  26448. onCollideObservable: Observable<AbstractMesh>;
  26449. /** Set a function to call when this mesh collides with another one */
  26450. onCollide: () => void;
  26451. /**
  26452. * An event triggered when the collision's position changes
  26453. */
  26454. onCollisionPositionChangeObservable: Observable<Vector3>;
  26455. /** Set a function to call when the collision's position changes */
  26456. onCollisionPositionChange: () => void;
  26457. /**
  26458. * An event triggered when material is changed
  26459. */
  26460. onMaterialChangedObservable: Observable<AbstractMesh>;
  26461. /**
  26462. * Gets or sets the orientation for POV movement & rotation
  26463. */
  26464. definedFacingForward: boolean;
  26465. /** @hidden */
  26466. _occlusionQuery: Nullable<WebGLQuery>;
  26467. /** @hidden */
  26468. _renderingGroup: Nullable<RenderingGroup>;
  26469. /**
  26470. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26471. */
  26472. /**
  26473. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26474. */
  26475. visibility: number;
  26476. /** Gets or sets the alpha index used to sort transparent meshes
  26477. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26478. */
  26479. alphaIndex: number;
  26480. /**
  26481. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26482. */
  26483. isVisible: boolean;
  26484. /**
  26485. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26486. */
  26487. isPickable: boolean;
  26488. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26489. showSubMeshesBoundingBox: boolean;
  26490. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26491. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26492. */
  26493. isBlocker: boolean;
  26494. /**
  26495. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26496. */
  26497. enablePointerMoveEvents: boolean;
  26498. /**
  26499. * Specifies the rendering group id for this mesh (0 by default)
  26500. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26501. */
  26502. renderingGroupId: number;
  26503. private _material;
  26504. /** Gets or sets current material */
  26505. material: Nullable<Material>;
  26506. /**
  26507. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26508. * @see http://doc.babylonjs.com/babylon101/shadows
  26509. */
  26510. receiveShadows: boolean;
  26511. /** Defines color to use when rendering outline */
  26512. outlineColor: Color3;
  26513. /** Define width to use when rendering outline */
  26514. outlineWidth: number;
  26515. /** Defines color to use when rendering overlay */
  26516. overlayColor: Color3;
  26517. /** Defines alpha to use when rendering overlay */
  26518. overlayAlpha: number;
  26519. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26520. hasVertexAlpha: boolean;
  26521. /** 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) */
  26522. useVertexColors: boolean;
  26523. /**
  26524. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26525. */
  26526. computeBonesUsingShaders: boolean;
  26527. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26528. numBoneInfluencers: number;
  26529. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26530. applyFog: boolean;
  26531. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26532. useOctreeForRenderingSelection: boolean;
  26533. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26534. useOctreeForPicking: boolean;
  26535. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26536. useOctreeForCollisions: boolean;
  26537. /**
  26538. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26539. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26540. */
  26541. layerMask: number;
  26542. /**
  26543. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26544. */
  26545. alwaysSelectAsActiveMesh: boolean;
  26546. /**
  26547. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26548. */
  26549. doNotSyncBoundingInfo: boolean;
  26550. /**
  26551. * Gets or sets the current action manager
  26552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26553. */
  26554. actionManager: Nullable<AbstractActionManager>;
  26555. private _meshCollisionData;
  26556. /**
  26557. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26558. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26559. */
  26560. ellipsoid: Vector3;
  26561. /**
  26562. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26563. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26564. */
  26565. ellipsoidOffset: Vector3;
  26566. /**
  26567. * Gets or sets a collision mask used to mask collisions (default is -1).
  26568. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26569. */
  26570. collisionMask: number;
  26571. /**
  26572. * Gets or sets the current collision group mask (-1 by default).
  26573. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26574. */
  26575. collisionGroup: number;
  26576. /**
  26577. * Defines edge width used when edgesRenderer is enabled
  26578. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26579. */
  26580. edgesWidth: number;
  26581. /**
  26582. * Defines edge color used when edgesRenderer is enabled
  26583. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26584. */
  26585. edgesColor: Color4;
  26586. /** @hidden */
  26587. _edgesRenderer: Nullable<IEdgesRenderer>;
  26588. /** @hidden */
  26589. _masterMesh: Nullable<AbstractMesh>;
  26590. /** @hidden */
  26591. _boundingInfo: Nullable<BoundingInfo>;
  26592. /** @hidden */
  26593. _renderId: number;
  26594. /**
  26595. * Gets or sets the list of subMeshes
  26596. * @see http://doc.babylonjs.com/how_to/multi_materials
  26597. */
  26598. subMeshes: SubMesh[];
  26599. /** @hidden */
  26600. _intersectionsInProgress: AbstractMesh[];
  26601. /** @hidden */
  26602. _unIndexed: boolean;
  26603. /** @hidden */
  26604. _lightSources: Light[];
  26605. /** Gets the list of lights affecting that mesh */
  26606. readonly lightSources: Light[];
  26607. /** @hidden */
  26608. readonly _positions: Nullable<Vector3[]>;
  26609. /** @hidden */
  26610. _waitingData: {
  26611. lods: Nullable<any>;
  26612. actions: Nullable<any>;
  26613. freezeWorldMatrix: Nullable<boolean>;
  26614. };
  26615. /** @hidden */
  26616. _bonesTransformMatrices: Nullable<Float32Array>;
  26617. /** @hidden */
  26618. _transformMatrixTexture: Nullable<RawTexture>;
  26619. /**
  26620. * Gets or sets a skeleton to apply skining transformations
  26621. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26622. */
  26623. skeleton: Nullable<Skeleton>;
  26624. /**
  26625. * An event triggered when the mesh is rebuilt.
  26626. */
  26627. onRebuildObservable: Observable<AbstractMesh>;
  26628. /**
  26629. * Creates a new AbstractMesh
  26630. * @param name defines the name of the mesh
  26631. * @param scene defines the hosting scene
  26632. */
  26633. constructor(name: string, scene?: Nullable<Scene>);
  26634. /**
  26635. * Returns the string "AbstractMesh"
  26636. * @returns "AbstractMesh"
  26637. */
  26638. getClassName(): string;
  26639. /**
  26640. * Gets a string representation of the current mesh
  26641. * @param fullDetails defines a boolean indicating if full details must be included
  26642. * @returns a string representation of the current mesh
  26643. */
  26644. toString(fullDetails?: boolean): string;
  26645. /**
  26646. * @hidden
  26647. */
  26648. protected _getEffectiveParent(): Nullable<Node>;
  26649. /** @hidden */
  26650. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26651. /** @hidden */
  26652. _rebuild(): void;
  26653. /** @hidden */
  26654. _resyncLightSources(): void;
  26655. /** @hidden */
  26656. _resyncLighSource(light: Light): void;
  26657. /** @hidden */
  26658. _unBindEffect(): void;
  26659. /** @hidden */
  26660. _removeLightSource(light: Light, dispose: boolean): void;
  26661. private _markSubMeshesAsDirty;
  26662. /** @hidden */
  26663. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26664. /** @hidden */
  26665. _markSubMeshesAsAttributesDirty(): void;
  26666. /** @hidden */
  26667. _markSubMeshesAsMiscDirty(): void;
  26668. /**
  26669. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26670. */
  26671. scaling: Vector3;
  26672. /**
  26673. * Returns true if the mesh is blocked. Implemented by child classes
  26674. */
  26675. readonly isBlocked: boolean;
  26676. /**
  26677. * Returns the mesh itself by default. Implemented by child classes
  26678. * @param camera defines the camera to use to pick the right LOD level
  26679. * @returns the currentAbstractMesh
  26680. */
  26681. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26682. /**
  26683. * Returns 0 by default. Implemented by child classes
  26684. * @returns an integer
  26685. */
  26686. getTotalVertices(): number;
  26687. /**
  26688. * Returns a positive integer : the total number of indices in this mesh geometry.
  26689. * @returns the numner of indices or zero if the mesh has no geometry.
  26690. */
  26691. getTotalIndices(): number;
  26692. /**
  26693. * Returns null by default. Implemented by child classes
  26694. * @returns null
  26695. */
  26696. getIndices(): Nullable<IndicesArray>;
  26697. /**
  26698. * Returns the array of the requested vertex data kind. Implemented by child classes
  26699. * @param kind defines the vertex data kind to use
  26700. * @returns null
  26701. */
  26702. getVerticesData(kind: string): Nullable<FloatArray>;
  26703. /**
  26704. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26705. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26706. * Note that a new underlying VertexBuffer object is created each call.
  26707. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26708. * @param kind defines vertex data kind:
  26709. * * VertexBuffer.PositionKind
  26710. * * VertexBuffer.UVKind
  26711. * * VertexBuffer.UV2Kind
  26712. * * VertexBuffer.UV3Kind
  26713. * * VertexBuffer.UV4Kind
  26714. * * VertexBuffer.UV5Kind
  26715. * * VertexBuffer.UV6Kind
  26716. * * VertexBuffer.ColorKind
  26717. * * VertexBuffer.MatricesIndicesKind
  26718. * * VertexBuffer.MatricesIndicesExtraKind
  26719. * * VertexBuffer.MatricesWeightsKind
  26720. * * VertexBuffer.MatricesWeightsExtraKind
  26721. * @param data defines the data source
  26722. * @param updatable defines if the data must be flagged as updatable (or static)
  26723. * @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
  26724. * @returns the current mesh
  26725. */
  26726. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26727. /**
  26728. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26729. * If the mesh has no geometry, it is simply returned as it is.
  26730. * @param kind defines vertex data kind:
  26731. * * VertexBuffer.PositionKind
  26732. * * VertexBuffer.UVKind
  26733. * * VertexBuffer.UV2Kind
  26734. * * VertexBuffer.UV3Kind
  26735. * * VertexBuffer.UV4Kind
  26736. * * VertexBuffer.UV5Kind
  26737. * * VertexBuffer.UV6Kind
  26738. * * VertexBuffer.ColorKind
  26739. * * VertexBuffer.MatricesIndicesKind
  26740. * * VertexBuffer.MatricesIndicesExtraKind
  26741. * * VertexBuffer.MatricesWeightsKind
  26742. * * VertexBuffer.MatricesWeightsExtraKind
  26743. * @param data defines the data source
  26744. * @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
  26745. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26746. * @returns the current mesh
  26747. */
  26748. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26749. /**
  26750. * Sets the mesh indices,
  26751. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26752. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26753. * @param totalVertices Defines the total number of vertices
  26754. * @returns the current mesh
  26755. */
  26756. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26757. /**
  26758. * Gets a boolean indicating if specific vertex data is present
  26759. * @param kind defines the vertex data kind to use
  26760. * @returns true is data kind is present
  26761. */
  26762. isVerticesDataPresent(kind: string): boolean;
  26763. /**
  26764. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26765. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26766. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26767. * @returns a BoundingInfo
  26768. */
  26769. getBoundingInfo(): BoundingInfo;
  26770. /**
  26771. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26772. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26773. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26774. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26775. * @returns the current mesh
  26776. */
  26777. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26778. /**
  26779. * Overwrite the current bounding info
  26780. * @param boundingInfo defines the new bounding info
  26781. * @returns the current mesh
  26782. */
  26783. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26784. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26785. readonly useBones: boolean;
  26786. /** @hidden */
  26787. _preActivate(): void;
  26788. /** @hidden */
  26789. _preActivateForIntermediateRendering(renderId: number): void;
  26790. /** @hidden */
  26791. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26792. /** @hidden */
  26793. _postActivate(): void;
  26794. /** @hidden */
  26795. _freeze(): void;
  26796. /** @hidden */
  26797. _unFreeze(): void;
  26798. /**
  26799. * Gets the current world matrix
  26800. * @returns a Matrix
  26801. */
  26802. getWorldMatrix(): Matrix;
  26803. /** @hidden */
  26804. _getWorldMatrixDeterminant(): number;
  26805. /**
  26806. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26807. */
  26808. readonly isAnInstance: boolean;
  26809. /**
  26810. * Gets a boolean indicating if this mesh has instances
  26811. */
  26812. readonly hasInstances: boolean;
  26813. /**
  26814. * Perform relative position change from the point of view of behind the front of the mesh.
  26815. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26816. * Supports definition of mesh facing forward or backward
  26817. * @param amountRight defines the distance on the right axis
  26818. * @param amountUp defines the distance on the up axis
  26819. * @param amountForward defines the distance on the forward axis
  26820. * @returns the current mesh
  26821. */
  26822. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26823. /**
  26824. * Calculate relative position change from the point of view of behind the front of the mesh.
  26825. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26826. * Supports definition of mesh facing forward or backward
  26827. * @param amountRight defines the distance on the right axis
  26828. * @param amountUp defines the distance on the up axis
  26829. * @param amountForward defines the distance on the forward axis
  26830. * @returns the new displacement vector
  26831. */
  26832. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26833. /**
  26834. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26835. * Supports definition of mesh facing forward or backward
  26836. * @param flipBack defines the flip
  26837. * @param twirlClockwise defines the twirl
  26838. * @param tiltRight defines the tilt
  26839. * @returns the current mesh
  26840. */
  26841. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26842. /**
  26843. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26844. * Supports definition of mesh facing forward or backward.
  26845. * @param flipBack defines the flip
  26846. * @param twirlClockwise defines the twirl
  26847. * @param tiltRight defines the tilt
  26848. * @returns the new rotation vector
  26849. */
  26850. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26851. /**
  26852. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26853. * This means the mesh underlying bounding box and sphere are recomputed.
  26854. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26855. * @returns the current mesh
  26856. */
  26857. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26858. /** @hidden */
  26859. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26860. /** @hidden */
  26861. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26862. /** @hidden */
  26863. _updateBoundingInfo(): AbstractMesh;
  26864. /** @hidden */
  26865. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26866. /** @hidden */
  26867. protected _afterComputeWorldMatrix(): void;
  26868. /** @hidden */
  26869. readonly _effectiveMesh: AbstractMesh;
  26870. /**
  26871. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26872. * A mesh is in the frustum if its bounding box intersects the frustum
  26873. * @param frustumPlanes defines the frustum to test
  26874. * @returns true if the mesh is in the frustum planes
  26875. */
  26876. isInFrustum(frustumPlanes: Plane[]): boolean;
  26877. /**
  26878. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26879. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26880. * @param frustumPlanes defines the frustum to test
  26881. * @returns true if the mesh is completely in the frustum planes
  26882. */
  26883. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26884. /**
  26885. * True if the mesh intersects another mesh or a SolidParticle object
  26886. * @param mesh defines a target mesh or SolidParticle to test
  26887. * @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)
  26888. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26889. * @returns true if there is an intersection
  26890. */
  26891. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26892. /**
  26893. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26894. * @param point defines the point to test
  26895. * @returns true if there is an intersection
  26896. */
  26897. intersectsPoint(point: Vector3): boolean;
  26898. /**
  26899. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26900. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26901. */
  26902. checkCollisions: boolean;
  26903. /**
  26904. * Gets Collider object used to compute collisions (not physics)
  26905. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26906. */
  26907. readonly collider: Nullable<Collider>;
  26908. /**
  26909. * Move the mesh using collision engine
  26910. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26911. * @param displacement defines the requested displacement vector
  26912. * @returns the current mesh
  26913. */
  26914. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26915. private _onCollisionPositionChange;
  26916. /** @hidden */
  26917. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26918. /** @hidden */
  26919. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26920. /** @hidden */
  26921. _checkCollision(collider: Collider): AbstractMesh;
  26922. /** @hidden */
  26923. _generatePointsArray(): boolean;
  26924. /**
  26925. * Checks if the passed Ray intersects with the mesh
  26926. * @param ray defines the ray to use
  26927. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26928. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26929. * @returns the picking info
  26930. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26931. */
  26932. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26933. /**
  26934. * Clones the current mesh
  26935. * @param name defines the mesh name
  26936. * @param newParent defines the new mesh parent
  26937. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26938. * @returns the new mesh
  26939. */
  26940. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26941. /**
  26942. * Disposes all the submeshes of the current meshnp
  26943. * @returns the current mesh
  26944. */
  26945. releaseSubMeshes(): AbstractMesh;
  26946. /**
  26947. * Releases resources associated with this abstract mesh.
  26948. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26949. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26950. */
  26951. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26952. /**
  26953. * Adds the passed mesh as a child to the current mesh
  26954. * @param mesh defines the child mesh
  26955. * @returns the current mesh
  26956. */
  26957. addChild(mesh: AbstractMesh): AbstractMesh;
  26958. /**
  26959. * Removes the passed mesh from the current mesh children list
  26960. * @param mesh defines the child mesh
  26961. * @returns the current mesh
  26962. */
  26963. removeChild(mesh: AbstractMesh): AbstractMesh;
  26964. /** @hidden */
  26965. private _initFacetData;
  26966. /**
  26967. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26968. * This method can be called within the render loop.
  26969. * 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
  26970. * @returns the current mesh
  26971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26972. */
  26973. updateFacetData(): AbstractMesh;
  26974. /**
  26975. * Returns the facetLocalNormals array.
  26976. * The normals are expressed in the mesh local spac
  26977. * @returns an array of Vector3
  26978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26979. */
  26980. getFacetLocalNormals(): Vector3[];
  26981. /**
  26982. * Returns the facetLocalPositions array.
  26983. * The facet positions are expressed in the mesh local space
  26984. * @returns an array of Vector3
  26985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26986. */
  26987. getFacetLocalPositions(): Vector3[];
  26988. /**
  26989. * Returns the facetLocalPartioning array
  26990. * @returns an array of array of numbers
  26991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26992. */
  26993. getFacetLocalPartitioning(): number[][];
  26994. /**
  26995. * Returns the i-th facet position in the world system.
  26996. * This method allocates a new Vector3 per call
  26997. * @param i defines the facet index
  26998. * @returns a new Vector3
  26999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27000. */
  27001. getFacetPosition(i: number): Vector3;
  27002. /**
  27003. * Sets the reference Vector3 with the i-th facet position in the world system
  27004. * @param i defines the facet index
  27005. * @param ref defines the target vector
  27006. * @returns the current mesh
  27007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27008. */
  27009. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27010. /**
  27011. * Returns the i-th facet normal in the world system.
  27012. * This method allocates a new Vector3 per call
  27013. * @param i defines the facet index
  27014. * @returns a new Vector3
  27015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27016. */
  27017. getFacetNormal(i: number): Vector3;
  27018. /**
  27019. * Sets the reference Vector3 with the i-th facet normal in the world system
  27020. * @param i defines the facet index
  27021. * @param ref defines the target vector
  27022. * @returns the current mesh
  27023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27024. */
  27025. getFacetNormalToRef(i: number, ref: Vector3): this;
  27026. /**
  27027. * 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)
  27028. * @param x defines x coordinate
  27029. * @param y defines y coordinate
  27030. * @param z defines z coordinate
  27031. * @returns the array of facet indexes
  27032. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27033. */
  27034. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27035. /**
  27036. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27037. * @param projected sets as the (x,y,z) world projection on the facet
  27038. * @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
  27039. * @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
  27040. * @param x defines x coordinate
  27041. * @param y defines y coordinate
  27042. * @param z defines z coordinate
  27043. * @returns the face index if found (or null instead)
  27044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27045. */
  27046. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27047. /**
  27048. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27049. * @param projected sets as the (x,y,z) local projection on the facet
  27050. * @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
  27051. * @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
  27052. * @param x defines x coordinate
  27053. * @param y defines y coordinate
  27054. * @param z defines z coordinate
  27055. * @returns the face index if found (or null instead)
  27056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27057. */
  27058. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27059. /**
  27060. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27061. * @returns the parameters
  27062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27063. */
  27064. getFacetDataParameters(): any;
  27065. /**
  27066. * Disables the feature FacetData and frees the related memory
  27067. * @returns the current mesh
  27068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27069. */
  27070. disableFacetData(): AbstractMesh;
  27071. /**
  27072. * Updates the AbstractMesh indices array
  27073. * @param indices defines the data source
  27074. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27075. * @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)
  27076. * @returns the current mesh
  27077. */
  27078. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27079. /**
  27080. * Creates new normals data for the mesh
  27081. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27082. * @returns the current mesh
  27083. */
  27084. createNormals(updatable: boolean): AbstractMesh;
  27085. /**
  27086. * Align the mesh with a normal
  27087. * @param normal defines the normal to use
  27088. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27089. * @returns the current mesh
  27090. */
  27091. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27092. /** @hidden */
  27093. _checkOcclusionQuery(): boolean;
  27094. /**
  27095. * Disables the mesh edge rendering mode
  27096. * @returns the currentAbstractMesh
  27097. */
  27098. disableEdgesRendering(): AbstractMesh;
  27099. /**
  27100. * Enables the edge rendering mode on the mesh.
  27101. * This mode makes the mesh edges visible
  27102. * @param epsilon defines the maximal distance between two angles to detect a face
  27103. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27104. * @returns the currentAbstractMesh
  27105. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27106. */
  27107. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27108. }
  27109. }
  27110. declare module "babylonjs/Actions/actionEvent" {
  27111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27112. import { Nullable } from "babylonjs/types";
  27113. import { Sprite } from "babylonjs/Sprites/sprite";
  27114. import { Scene } from "babylonjs/scene";
  27115. import { Vector2 } from "babylonjs/Maths/math.vector";
  27116. /**
  27117. * Interface used to define ActionEvent
  27118. */
  27119. export interface IActionEvent {
  27120. /** The mesh or sprite that triggered the action */
  27121. source: any;
  27122. /** The X mouse cursor position at the time of the event */
  27123. pointerX: number;
  27124. /** The Y mouse cursor position at the time of the event */
  27125. pointerY: number;
  27126. /** The mesh that is currently pointed at (can be null) */
  27127. meshUnderPointer: Nullable<AbstractMesh>;
  27128. /** the original (browser) event that triggered the ActionEvent */
  27129. sourceEvent?: any;
  27130. /** additional data for the event */
  27131. additionalData?: any;
  27132. }
  27133. /**
  27134. * ActionEvent is the event being sent when an action is triggered.
  27135. */
  27136. export class ActionEvent implements IActionEvent {
  27137. /** The mesh or sprite that triggered the action */
  27138. source: any;
  27139. /** The X mouse cursor position at the time of the event */
  27140. pointerX: number;
  27141. /** The Y mouse cursor position at the time of the event */
  27142. pointerY: number;
  27143. /** The mesh that is currently pointed at (can be null) */
  27144. meshUnderPointer: Nullable<AbstractMesh>;
  27145. /** the original (browser) event that triggered the ActionEvent */
  27146. sourceEvent?: any;
  27147. /** additional data for the event */
  27148. additionalData?: any;
  27149. /**
  27150. * Creates a new ActionEvent
  27151. * @param source The mesh or sprite that triggered the action
  27152. * @param pointerX The X mouse cursor position at the time of the event
  27153. * @param pointerY The Y mouse cursor position at the time of the event
  27154. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27155. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27156. * @param additionalData additional data for the event
  27157. */
  27158. constructor(
  27159. /** The mesh or sprite that triggered the action */
  27160. source: any,
  27161. /** The X mouse cursor position at the time of the event */
  27162. pointerX: number,
  27163. /** The Y mouse cursor position at the time of the event */
  27164. pointerY: number,
  27165. /** The mesh that is currently pointed at (can be null) */
  27166. meshUnderPointer: Nullable<AbstractMesh>,
  27167. /** the original (browser) event that triggered the ActionEvent */
  27168. sourceEvent?: any,
  27169. /** additional data for the event */
  27170. additionalData?: any);
  27171. /**
  27172. * Helper function to auto-create an ActionEvent from a source mesh.
  27173. * @param source The source mesh that triggered the event
  27174. * @param evt The original (browser) event
  27175. * @param additionalData additional data for the event
  27176. * @returns the new ActionEvent
  27177. */
  27178. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27179. /**
  27180. * Helper function to auto-create an ActionEvent from a source sprite
  27181. * @param source The source sprite that triggered the event
  27182. * @param scene Scene associated with the sprite
  27183. * @param evt The original (browser) event
  27184. * @param additionalData additional data for the event
  27185. * @returns the new ActionEvent
  27186. */
  27187. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27188. /**
  27189. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27190. * @param scene the scene where the event occurred
  27191. * @param evt The original (browser) event
  27192. * @returns the new ActionEvent
  27193. */
  27194. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27195. /**
  27196. * Helper function to auto-create an ActionEvent from a primitive
  27197. * @param prim defines the target primitive
  27198. * @param pointerPos defines the pointer position
  27199. * @param evt The original (browser) event
  27200. * @param additionalData additional data for the event
  27201. * @returns the new ActionEvent
  27202. */
  27203. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27204. }
  27205. }
  27206. declare module "babylonjs/Actions/abstractActionManager" {
  27207. import { IDisposable } from "babylonjs/scene";
  27208. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27209. import { IAction } from "babylonjs/Actions/action";
  27210. import { Nullable } from "babylonjs/types";
  27211. /**
  27212. * Abstract class used to decouple action Manager from scene and meshes.
  27213. * Do not instantiate.
  27214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27215. */
  27216. export abstract class AbstractActionManager implements IDisposable {
  27217. /** Gets the list of active triggers */
  27218. static Triggers: {
  27219. [key: string]: number;
  27220. };
  27221. /** Gets the cursor to use when hovering items */
  27222. hoverCursor: string;
  27223. /** Gets the list of actions */
  27224. actions: IAction[];
  27225. /**
  27226. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27227. */
  27228. isRecursive: boolean;
  27229. /**
  27230. * Releases all associated resources
  27231. */
  27232. abstract dispose(): void;
  27233. /**
  27234. * Does this action manager has pointer triggers
  27235. */
  27236. abstract readonly hasPointerTriggers: boolean;
  27237. /**
  27238. * Does this action manager has pick triggers
  27239. */
  27240. abstract readonly hasPickTriggers: boolean;
  27241. /**
  27242. * Process a specific trigger
  27243. * @param trigger defines the trigger to process
  27244. * @param evt defines the event details to be processed
  27245. */
  27246. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27247. /**
  27248. * Does this action manager handles actions of any of the given triggers
  27249. * @param triggers defines the triggers to be tested
  27250. * @return a boolean indicating whether one (or more) of the triggers is handled
  27251. */
  27252. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27253. /**
  27254. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27255. * speed.
  27256. * @param triggerA defines the trigger to be tested
  27257. * @param triggerB defines the trigger to be tested
  27258. * @return a boolean indicating whether one (or more) of the triggers is handled
  27259. */
  27260. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27261. /**
  27262. * Does this action manager handles actions of a given trigger
  27263. * @param trigger defines the trigger to be tested
  27264. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27265. * @return whether the trigger is handled
  27266. */
  27267. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27268. /**
  27269. * Serialize this manager to a JSON object
  27270. * @param name defines the property name to store this manager
  27271. * @returns a JSON representation of this manager
  27272. */
  27273. abstract serialize(name: string): any;
  27274. /**
  27275. * Registers an action to this action manager
  27276. * @param action defines the action to be registered
  27277. * @return the action amended (prepared) after registration
  27278. */
  27279. abstract registerAction(action: IAction): Nullable<IAction>;
  27280. /**
  27281. * Unregisters an action to this action manager
  27282. * @param action defines the action to be unregistered
  27283. * @return a boolean indicating whether the action has been unregistered
  27284. */
  27285. abstract unregisterAction(action: IAction): Boolean;
  27286. /**
  27287. * Does exist one action manager with at least one trigger
  27288. **/
  27289. static readonly HasTriggers: boolean;
  27290. /**
  27291. * Does exist one action manager with at least one pick trigger
  27292. **/
  27293. static readonly HasPickTriggers: boolean;
  27294. /**
  27295. * Does exist one action manager that handles actions of a given trigger
  27296. * @param trigger defines the trigger to be tested
  27297. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27298. **/
  27299. static HasSpecificTrigger(trigger: number): boolean;
  27300. }
  27301. }
  27302. declare module "babylonjs/node" {
  27303. import { Scene } from "babylonjs/scene";
  27304. import { Nullable } from "babylonjs/types";
  27305. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27306. import { Engine } from "babylonjs/Engines/engine";
  27307. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27308. import { Observable } from "babylonjs/Misc/observable";
  27309. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27310. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27311. import { Animatable } from "babylonjs/Animations/animatable";
  27312. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27313. import { Animation } from "babylonjs/Animations/animation";
  27314. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27316. /**
  27317. * Defines how a node can be built from a string name.
  27318. */
  27319. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27320. /**
  27321. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27322. */
  27323. export class Node implements IBehaviorAware<Node> {
  27324. /** @hidden */
  27325. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27326. private static _NodeConstructors;
  27327. /**
  27328. * Add a new node constructor
  27329. * @param type defines the type name of the node to construct
  27330. * @param constructorFunc defines the constructor function
  27331. */
  27332. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27333. /**
  27334. * Returns a node constructor based on type name
  27335. * @param type defines the type name
  27336. * @param name defines the new node name
  27337. * @param scene defines the hosting scene
  27338. * @param options defines optional options to transmit to constructors
  27339. * @returns the new constructor or null
  27340. */
  27341. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27342. /**
  27343. * Gets or sets the name of the node
  27344. */
  27345. name: string;
  27346. /**
  27347. * Gets or sets the id of the node
  27348. */
  27349. id: string;
  27350. /**
  27351. * Gets or sets the unique id of the node
  27352. */
  27353. uniqueId: number;
  27354. /**
  27355. * Gets or sets a string used to store user defined state for the node
  27356. */
  27357. state: string;
  27358. /**
  27359. * Gets or sets an object used to store user defined information for the node
  27360. */
  27361. metadata: any;
  27362. /**
  27363. * For internal use only. Please do not use.
  27364. */
  27365. reservedDataStore: any;
  27366. /**
  27367. * List of inspectable custom properties (used by the Inspector)
  27368. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27369. */
  27370. inspectableCustomProperties: IInspectable[];
  27371. /**
  27372. * Gets or sets a boolean used to define if the node must be serialized
  27373. */
  27374. doNotSerialize: boolean;
  27375. /** @hidden */
  27376. _isDisposed: boolean;
  27377. /**
  27378. * Gets a list of Animations associated with the node
  27379. */
  27380. animations: import("babylonjs/Animations/animation").Animation[];
  27381. protected _ranges: {
  27382. [name: string]: Nullable<AnimationRange>;
  27383. };
  27384. /**
  27385. * Callback raised when the node is ready to be used
  27386. */
  27387. onReady: Nullable<(node: Node) => void>;
  27388. private _isEnabled;
  27389. private _isParentEnabled;
  27390. private _isReady;
  27391. /** @hidden */
  27392. _currentRenderId: number;
  27393. private _parentUpdateId;
  27394. /** @hidden */
  27395. _childUpdateId: number;
  27396. /** @hidden */
  27397. _waitingParentId: Nullable<string>;
  27398. /** @hidden */
  27399. _scene: Scene;
  27400. /** @hidden */
  27401. _cache: any;
  27402. private _parentNode;
  27403. private _children;
  27404. /** @hidden */
  27405. _worldMatrix: Matrix;
  27406. /** @hidden */
  27407. _worldMatrixDeterminant: number;
  27408. /** @hidden */
  27409. _worldMatrixDeterminantIsDirty: boolean;
  27410. /** @hidden */
  27411. private _sceneRootNodesIndex;
  27412. /**
  27413. * Gets a boolean indicating if the node has been disposed
  27414. * @returns true if the node was disposed
  27415. */
  27416. isDisposed(): boolean;
  27417. /**
  27418. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27419. * @see https://doc.babylonjs.com/how_to/parenting
  27420. */
  27421. parent: Nullable<Node>;
  27422. private addToSceneRootNodes;
  27423. private removeFromSceneRootNodes;
  27424. private _animationPropertiesOverride;
  27425. /**
  27426. * Gets or sets the animation properties override
  27427. */
  27428. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27429. /**
  27430. * Gets a string idenfifying the name of the class
  27431. * @returns "Node" string
  27432. */
  27433. getClassName(): string;
  27434. /** @hidden */
  27435. readonly _isNode: boolean;
  27436. /**
  27437. * An event triggered when the mesh is disposed
  27438. */
  27439. onDisposeObservable: Observable<Node>;
  27440. private _onDisposeObserver;
  27441. /**
  27442. * Sets a callback that will be raised when the node will be disposed
  27443. */
  27444. onDispose: () => void;
  27445. /**
  27446. * Creates a new Node
  27447. * @param name the name and id to be given to this node
  27448. * @param scene the scene this node will be added to
  27449. * @param addToRootNodes the node will be added to scene.rootNodes
  27450. */
  27451. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27452. /**
  27453. * Gets the scene of the node
  27454. * @returns a scene
  27455. */
  27456. getScene(): Scene;
  27457. /**
  27458. * Gets the engine of the node
  27459. * @returns a Engine
  27460. */
  27461. getEngine(): Engine;
  27462. private _behaviors;
  27463. /**
  27464. * Attach a behavior to the node
  27465. * @see http://doc.babylonjs.com/features/behaviour
  27466. * @param behavior defines the behavior to attach
  27467. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27468. * @returns the current Node
  27469. */
  27470. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27471. /**
  27472. * Remove an attached behavior
  27473. * @see http://doc.babylonjs.com/features/behaviour
  27474. * @param behavior defines the behavior to attach
  27475. * @returns the current Node
  27476. */
  27477. removeBehavior(behavior: Behavior<Node>): Node;
  27478. /**
  27479. * Gets the list of attached behaviors
  27480. * @see http://doc.babylonjs.com/features/behaviour
  27481. */
  27482. readonly behaviors: Behavior<Node>[];
  27483. /**
  27484. * Gets an attached behavior by name
  27485. * @param name defines the name of the behavior to look for
  27486. * @see http://doc.babylonjs.com/features/behaviour
  27487. * @returns null if behavior was not found else the requested behavior
  27488. */
  27489. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27490. /**
  27491. * Returns the latest update of the World matrix
  27492. * @returns a Matrix
  27493. */
  27494. getWorldMatrix(): Matrix;
  27495. /** @hidden */
  27496. _getWorldMatrixDeterminant(): number;
  27497. /**
  27498. * Returns directly the latest state of the mesh World matrix.
  27499. * A Matrix is returned.
  27500. */
  27501. readonly worldMatrixFromCache: Matrix;
  27502. /** @hidden */
  27503. _initCache(): void;
  27504. /** @hidden */
  27505. updateCache(force?: boolean): void;
  27506. /** @hidden */
  27507. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27508. /** @hidden */
  27509. _updateCache(ignoreParentClass?: boolean): void;
  27510. /** @hidden */
  27511. _isSynchronized(): boolean;
  27512. /** @hidden */
  27513. _markSyncedWithParent(): void;
  27514. /** @hidden */
  27515. isSynchronizedWithParent(): boolean;
  27516. /** @hidden */
  27517. isSynchronized(): boolean;
  27518. /**
  27519. * Is this node ready to be used/rendered
  27520. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27521. * @return true if the node is ready
  27522. */
  27523. isReady(completeCheck?: boolean): boolean;
  27524. /**
  27525. * Is this node enabled?
  27526. * 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
  27527. * @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
  27528. * @return whether this node (and its parent) is enabled
  27529. */
  27530. isEnabled(checkAncestors?: boolean): boolean;
  27531. /** @hidden */
  27532. protected _syncParentEnabledState(): void;
  27533. /**
  27534. * Set the enabled state of this node
  27535. * @param value defines the new enabled state
  27536. */
  27537. setEnabled(value: boolean): void;
  27538. /**
  27539. * Is this node a descendant of the given node?
  27540. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27541. * @param ancestor defines the parent node to inspect
  27542. * @returns a boolean indicating if this node is a descendant of the given node
  27543. */
  27544. isDescendantOf(ancestor: Node): boolean;
  27545. /** @hidden */
  27546. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27547. /**
  27548. * Will return all nodes that have this node as ascendant
  27549. * @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
  27550. * @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
  27551. * @return all children nodes of all types
  27552. */
  27553. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27554. /**
  27555. * Get all child-meshes of this node
  27556. * @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)
  27557. * @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
  27558. * @returns an array of AbstractMesh
  27559. */
  27560. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27561. /**
  27562. * Get all direct children of this node
  27563. * @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
  27564. * @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)
  27565. * @returns an array of Node
  27566. */
  27567. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27568. /** @hidden */
  27569. _setReady(state: boolean): void;
  27570. /**
  27571. * Get an animation by name
  27572. * @param name defines the name of the animation to look for
  27573. * @returns null if not found else the requested animation
  27574. */
  27575. getAnimationByName(name: string): Nullable<Animation>;
  27576. /**
  27577. * Creates an animation range for this node
  27578. * @param name defines the name of the range
  27579. * @param from defines the starting key
  27580. * @param to defines the end key
  27581. */
  27582. createAnimationRange(name: string, from: number, to: number): void;
  27583. /**
  27584. * Delete a specific animation range
  27585. * @param name defines the name of the range to delete
  27586. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27587. */
  27588. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27589. /**
  27590. * Get an animation range by name
  27591. * @param name defines the name of the animation range to look for
  27592. * @returns null if not found else the requested animation range
  27593. */
  27594. getAnimationRange(name: string): Nullable<AnimationRange>;
  27595. /**
  27596. * Gets the list of all animation ranges defined on this node
  27597. * @returns an array
  27598. */
  27599. getAnimationRanges(): Nullable<AnimationRange>[];
  27600. /**
  27601. * Will start the animation sequence
  27602. * @param name defines the range frames for animation sequence
  27603. * @param loop defines if the animation should loop (false by default)
  27604. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27605. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27606. * @returns the object created for this animation. If range does not exist, it will return null
  27607. */
  27608. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27609. /**
  27610. * Serialize animation ranges into a JSON compatible object
  27611. * @returns serialization object
  27612. */
  27613. serializeAnimationRanges(): any;
  27614. /**
  27615. * Computes the world matrix of the node
  27616. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27617. * @returns the world matrix
  27618. */
  27619. computeWorldMatrix(force?: boolean): Matrix;
  27620. /**
  27621. * Releases resources associated with this node.
  27622. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27623. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27624. */
  27625. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27626. /**
  27627. * Parse animation range data from a serialization object and store them into a given node
  27628. * @param node defines where to store the animation ranges
  27629. * @param parsedNode defines the serialization object to read data from
  27630. * @param scene defines the hosting scene
  27631. */
  27632. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27633. /**
  27634. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27635. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27636. * @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
  27637. * @returns the new bounding vectors
  27638. */
  27639. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27640. min: Vector3;
  27641. max: Vector3;
  27642. };
  27643. }
  27644. }
  27645. declare module "babylonjs/Animations/animation" {
  27646. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27647. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27648. import { Color3 } from "babylonjs/Maths/math.color";
  27649. import { Nullable } from "babylonjs/types";
  27650. import { Scene } from "babylonjs/scene";
  27651. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27652. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27653. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27654. import { Node } from "babylonjs/node";
  27655. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27656. import { Size } from "babylonjs/Maths/math.size";
  27657. import { Animatable } from "babylonjs/Animations/animatable";
  27658. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27659. /**
  27660. * @hidden
  27661. */
  27662. export class _IAnimationState {
  27663. key: number;
  27664. repeatCount: number;
  27665. workValue?: any;
  27666. loopMode?: number;
  27667. offsetValue?: any;
  27668. highLimitValue?: any;
  27669. }
  27670. /**
  27671. * Class used to store any kind of animation
  27672. */
  27673. export class Animation {
  27674. /**Name of the animation */
  27675. name: string;
  27676. /**Property to animate */
  27677. targetProperty: string;
  27678. /**The frames per second of the animation */
  27679. framePerSecond: number;
  27680. /**The data type of the animation */
  27681. dataType: number;
  27682. /**The loop mode of the animation */
  27683. loopMode?: number | undefined;
  27684. /**Specifies if blending should be enabled */
  27685. enableBlending?: boolean | undefined;
  27686. /**
  27687. * Use matrix interpolation instead of using direct key value when animating matrices
  27688. */
  27689. static AllowMatricesInterpolation: boolean;
  27690. /**
  27691. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27692. */
  27693. static AllowMatrixDecomposeForInterpolation: boolean;
  27694. /**
  27695. * Stores the key frames of the animation
  27696. */
  27697. private _keys;
  27698. /**
  27699. * Stores the easing function of the animation
  27700. */
  27701. private _easingFunction;
  27702. /**
  27703. * @hidden Internal use only
  27704. */
  27705. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27706. /**
  27707. * The set of event that will be linked to this animation
  27708. */
  27709. private _events;
  27710. /**
  27711. * Stores an array of target property paths
  27712. */
  27713. targetPropertyPath: string[];
  27714. /**
  27715. * Stores the blending speed of the animation
  27716. */
  27717. blendingSpeed: number;
  27718. /**
  27719. * Stores the animation ranges for the animation
  27720. */
  27721. private _ranges;
  27722. /**
  27723. * @hidden Internal use
  27724. */
  27725. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27726. /**
  27727. * Sets up an animation
  27728. * @param property The property to animate
  27729. * @param animationType The animation type to apply
  27730. * @param framePerSecond The frames per second of the animation
  27731. * @param easingFunction The easing function used in the animation
  27732. * @returns The created animation
  27733. */
  27734. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27735. /**
  27736. * Create and start an animation on a node
  27737. * @param name defines the name of the global animation that will be run on all nodes
  27738. * @param node defines the root node where the animation will take place
  27739. * @param targetProperty defines property to animate
  27740. * @param framePerSecond defines the number of frame per second yo use
  27741. * @param totalFrame defines the number of frames in total
  27742. * @param from defines the initial value
  27743. * @param to defines the final value
  27744. * @param loopMode defines which loop mode you want to use (off by default)
  27745. * @param easingFunction defines the easing function to use (linear by default)
  27746. * @param onAnimationEnd defines the callback to call when animation end
  27747. * @returns the animatable created for this animation
  27748. */
  27749. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27750. /**
  27751. * Create and start an animation on a node and its descendants
  27752. * @param name defines the name of the global animation that will be run on all nodes
  27753. * @param node defines the root node where the animation will take place
  27754. * @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
  27755. * @param targetProperty defines property to animate
  27756. * @param framePerSecond defines the number of frame per second to use
  27757. * @param totalFrame defines the number of frames in total
  27758. * @param from defines the initial value
  27759. * @param to defines the final value
  27760. * @param loopMode defines which loop mode you want to use (off by default)
  27761. * @param easingFunction defines the easing function to use (linear by default)
  27762. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27763. * @returns the list of animatables created for all nodes
  27764. * @example https://www.babylonjs-playground.com/#MH0VLI
  27765. */
  27766. 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[]>;
  27767. /**
  27768. * Creates a new animation, merges it with the existing animations and starts it
  27769. * @param name Name of the animation
  27770. * @param node Node which contains the scene that begins the animations
  27771. * @param targetProperty Specifies which property to animate
  27772. * @param framePerSecond The frames per second of the animation
  27773. * @param totalFrame The total number of frames
  27774. * @param from The frame at the beginning of the animation
  27775. * @param to The frame at the end of the animation
  27776. * @param loopMode Specifies the loop mode of the animation
  27777. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27778. * @param onAnimationEnd Callback to run once the animation is complete
  27779. * @returns Nullable animation
  27780. */
  27781. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27782. /**
  27783. * Transition property of an host to the target Value
  27784. * @param property The property to transition
  27785. * @param targetValue The target Value of the property
  27786. * @param host The object where the property to animate belongs
  27787. * @param scene Scene used to run the animation
  27788. * @param frameRate Framerate (in frame/s) to use
  27789. * @param transition The transition type we want to use
  27790. * @param duration The duration of the animation, in milliseconds
  27791. * @param onAnimationEnd Callback trigger at the end of the animation
  27792. * @returns Nullable animation
  27793. */
  27794. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27795. /**
  27796. * Return the array of runtime animations currently using this animation
  27797. */
  27798. readonly runtimeAnimations: RuntimeAnimation[];
  27799. /**
  27800. * Specifies if any of the runtime animations are currently running
  27801. */
  27802. readonly hasRunningRuntimeAnimations: boolean;
  27803. /**
  27804. * Initializes the animation
  27805. * @param name Name of the animation
  27806. * @param targetProperty Property to animate
  27807. * @param framePerSecond The frames per second of the animation
  27808. * @param dataType The data type of the animation
  27809. * @param loopMode The loop mode of the animation
  27810. * @param enableBlending Specifies if blending should be enabled
  27811. */
  27812. constructor(
  27813. /**Name of the animation */
  27814. name: string,
  27815. /**Property to animate */
  27816. targetProperty: string,
  27817. /**The frames per second of the animation */
  27818. framePerSecond: number,
  27819. /**The data type of the animation */
  27820. dataType: number,
  27821. /**The loop mode of the animation */
  27822. loopMode?: number | undefined,
  27823. /**Specifies if blending should be enabled */
  27824. enableBlending?: boolean | undefined);
  27825. /**
  27826. * Converts the animation to a string
  27827. * @param fullDetails support for multiple levels of logging within scene loading
  27828. * @returns String form of the animation
  27829. */
  27830. toString(fullDetails?: boolean): string;
  27831. /**
  27832. * Add an event to this animation
  27833. * @param event Event to add
  27834. */
  27835. addEvent(event: AnimationEvent): void;
  27836. /**
  27837. * Remove all events found at the given frame
  27838. * @param frame The frame to remove events from
  27839. */
  27840. removeEvents(frame: number): void;
  27841. /**
  27842. * Retrieves all the events from the animation
  27843. * @returns Events from the animation
  27844. */
  27845. getEvents(): AnimationEvent[];
  27846. /**
  27847. * Creates an animation range
  27848. * @param name Name of the animation range
  27849. * @param from Starting frame of the animation range
  27850. * @param to Ending frame of the animation
  27851. */
  27852. createRange(name: string, from: number, to: number): void;
  27853. /**
  27854. * Deletes an animation range by name
  27855. * @param name Name of the animation range to delete
  27856. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27857. */
  27858. deleteRange(name: string, deleteFrames?: boolean): void;
  27859. /**
  27860. * Gets the animation range by name, or null if not defined
  27861. * @param name Name of the animation range
  27862. * @returns Nullable animation range
  27863. */
  27864. getRange(name: string): Nullable<AnimationRange>;
  27865. /**
  27866. * Gets the key frames from the animation
  27867. * @returns The key frames of the animation
  27868. */
  27869. getKeys(): Array<IAnimationKey>;
  27870. /**
  27871. * Gets the highest frame rate of the animation
  27872. * @returns Highest frame rate of the animation
  27873. */
  27874. getHighestFrame(): number;
  27875. /**
  27876. * Gets the easing function of the animation
  27877. * @returns Easing function of the animation
  27878. */
  27879. getEasingFunction(): IEasingFunction;
  27880. /**
  27881. * Sets the easing function of the animation
  27882. * @param easingFunction A custom mathematical formula for animation
  27883. */
  27884. setEasingFunction(easingFunction: EasingFunction): void;
  27885. /**
  27886. * Interpolates a scalar linearly
  27887. * @param startValue Start value of the animation curve
  27888. * @param endValue End value of the animation curve
  27889. * @param gradient Scalar amount to interpolate
  27890. * @returns Interpolated scalar value
  27891. */
  27892. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27893. /**
  27894. * Interpolates a scalar cubically
  27895. * @param startValue Start value of the animation curve
  27896. * @param outTangent End tangent of the animation
  27897. * @param endValue End value of the animation curve
  27898. * @param inTangent Start tangent of the animation curve
  27899. * @param gradient Scalar amount to interpolate
  27900. * @returns Interpolated scalar value
  27901. */
  27902. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27903. /**
  27904. * Interpolates a quaternion using a spherical linear interpolation
  27905. * @param startValue Start value of the animation curve
  27906. * @param endValue End value of the animation curve
  27907. * @param gradient Scalar amount to interpolate
  27908. * @returns Interpolated quaternion value
  27909. */
  27910. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27911. /**
  27912. * Interpolates a quaternion cubically
  27913. * @param startValue Start value of the animation curve
  27914. * @param outTangent End tangent of the animation curve
  27915. * @param endValue End value of the animation curve
  27916. * @param inTangent Start tangent of the animation curve
  27917. * @param gradient Scalar amount to interpolate
  27918. * @returns Interpolated quaternion value
  27919. */
  27920. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27921. /**
  27922. * Interpolates a Vector3 linearl
  27923. * @param startValue Start value of the animation curve
  27924. * @param endValue End value of the animation curve
  27925. * @param gradient Scalar amount to interpolate
  27926. * @returns Interpolated scalar value
  27927. */
  27928. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27929. /**
  27930. * Interpolates a Vector3 cubically
  27931. * @param startValue Start value of the animation curve
  27932. * @param outTangent End tangent of the animation
  27933. * @param endValue End value of the animation curve
  27934. * @param inTangent Start tangent of the animation curve
  27935. * @param gradient Scalar amount to interpolate
  27936. * @returns InterpolatedVector3 value
  27937. */
  27938. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27939. /**
  27940. * Interpolates a Vector2 linearly
  27941. * @param startValue Start value of the animation curve
  27942. * @param endValue End value of the animation curve
  27943. * @param gradient Scalar amount to interpolate
  27944. * @returns Interpolated Vector2 value
  27945. */
  27946. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27947. /**
  27948. * Interpolates a Vector2 cubically
  27949. * @param startValue Start value of the animation curve
  27950. * @param outTangent End tangent of the animation
  27951. * @param endValue End value of the animation curve
  27952. * @param inTangent Start tangent of the animation curve
  27953. * @param gradient Scalar amount to interpolate
  27954. * @returns Interpolated Vector2 value
  27955. */
  27956. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27957. /**
  27958. * Interpolates a size linearly
  27959. * @param startValue Start value of the animation curve
  27960. * @param endValue End value of the animation curve
  27961. * @param gradient Scalar amount to interpolate
  27962. * @returns Interpolated Size value
  27963. */
  27964. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27965. /**
  27966. * Interpolates a Color3 linearly
  27967. * @param startValue Start value of the animation curve
  27968. * @param endValue End value of the animation curve
  27969. * @param gradient Scalar amount to interpolate
  27970. * @returns Interpolated Color3 value
  27971. */
  27972. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27973. /**
  27974. * @hidden Internal use only
  27975. */
  27976. _getKeyValue(value: any): any;
  27977. /**
  27978. * @hidden Internal use only
  27979. */
  27980. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27981. /**
  27982. * Defines the function to use to interpolate matrices
  27983. * @param startValue defines the start matrix
  27984. * @param endValue defines the end matrix
  27985. * @param gradient defines the gradient between both matrices
  27986. * @param result defines an optional target matrix where to store the interpolation
  27987. * @returns the interpolated matrix
  27988. */
  27989. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27990. /**
  27991. * Makes a copy of the animation
  27992. * @returns Cloned animation
  27993. */
  27994. clone(): Animation;
  27995. /**
  27996. * Sets the key frames of the animation
  27997. * @param values The animation key frames to set
  27998. */
  27999. setKeys(values: Array<IAnimationKey>): void;
  28000. /**
  28001. * Serializes the animation to an object
  28002. * @returns Serialized object
  28003. */
  28004. serialize(): any;
  28005. /**
  28006. * Float animation type
  28007. */
  28008. private static _ANIMATIONTYPE_FLOAT;
  28009. /**
  28010. * Vector3 animation type
  28011. */
  28012. private static _ANIMATIONTYPE_VECTOR3;
  28013. /**
  28014. * Quaternion animation type
  28015. */
  28016. private static _ANIMATIONTYPE_QUATERNION;
  28017. /**
  28018. * Matrix animation type
  28019. */
  28020. private static _ANIMATIONTYPE_MATRIX;
  28021. /**
  28022. * Color3 animation type
  28023. */
  28024. private static _ANIMATIONTYPE_COLOR3;
  28025. /**
  28026. * Vector2 animation type
  28027. */
  28028. private static _ANIMATIONTYPE_VECTOR2;
  28029. /**
  28030. * Size animation type
  28031. */
  28032. private static _ANIMATIONTYPE_SIZE;
  28033. /**
  28034. * Relative Loop Mode
  28035. */
  28036. private static _ANIMATIONLOOPMODE_RELATIVE;
  28037. /**
  28038. * Cycle Loop Mode
  28039. */
  28040. private static _ANIMATIONLOOPMODE_CYCLE;
  28041. /**
  28042. * Constant Loop Mode
  28043. */
  28044. private static _ANIMATIONLOOPMODE_CONSTANT;
  28045. /**
  28046. * Get the float animation type
  28047. */
  28048. static readonly ANIMATIONTYPE_FLOAT: number;
  28049. /**
  28050. * Get the Vector3 animation type
  28051. */
  28052. static readonly ANIMATIONTYPE_VECTOR3: number;
  28053. /**
  28054. * Get the Vector2 animation type
  28055. */
  28056. static readonly ANIMATIONTYPE_VECTOR2: number;
  28057. /**
  28058. * Get the Size animation type
  28059. */
  28060. static readonly ANIMATIONTYPE_SIZE: number;
  28061. /**
  28062. * Get the Quaternion animation type
  28063. */
  28064. static readonly ANIMATIONTYPE_QUATERNION: number;
  28065. /**
  28066. * Get the Matrix animation type
  28067. */
  28068. static readonly ANIMATIONTYPE_MATRIX: number;
  28069. /**
  28070. * Get the Color3 animation type
  28071. */
  28072. static readonly ANIMATIONTYPE_COLOR3: number;
  28073. /**
  28074. * Get the Relative Loop Mode
  28075. */
  28076. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28077. /**
  28078. * Get the Cycle Loop Mode
  28079. */
  28080. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28081. /**
  28082. * Get the Constant Loop Mode
  28083. */
  28084. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28085. /** @hidden */
  28086. static _UniversalLerp(left: any, right: any, amount: number): any;
  28087. /**
  28088. * Parses an animation object and creates an animation
  28089. * @param parsedAnimation Parsed animation object
  28090. * @returns Animation object
  28091. */
  28092. static Parse(parsedAnimation: any): Animation;
  28093. /**
  28094. * Appends the serialized animations from the source animations
  28095. * @param source Source containing the animations
  28096. * @param destination Target to store the animations
  28097. */
  28098. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28099. }
  28100. }
  28101. declare module "babylonjs/Animations/animatable.interface" {
  28102. import { Nullable } from "babylonjs/types";
  28103. import { Animation } from "babylonjs/Animations/animation";
  28104. /**
  28105. * Interface containing an array of animations
  28106. */
  28107. export interface IAnimatable {
  28108. /**
  28109. * Array of animations
  28110. */
  28111. animations: Nullable<Array<Animation>>;
  28112. }
  28113. }
  28114. declare module "babylonjs/Materials/fresnelParameters" {
  28115. import { Color3 } from "babylonjs/Maths/math.color";
  28116. /**
  28117. * This represents all the required information to add a fresnel effect on a material:
  28118. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28119. */
  28120. export class FresnelParameters {
  28121. private _isEnabled;
  28122. /**
  28123. * Define if the fresnel effect is enable or not.
  28124. */
  28125. isEnabled: boolean;
  28126. /**
  28127. * Define the color used on edges (grazing angle)
  28128. */
  28129. leftColor: Color3;
  28130. /**
  28131. * Define the color used on center
  28132. */
  28133. rightColor: Color3;
  28134. /**
  28135. * Define bias applied to computed fresnel term
  28136. */
  28137. bias: number;
  28138. /**
  28139. * Defined the power exponent applied to fresnel term
  28140. */
  28141. power: number;
  28142. /**
  28143. * Clones the current fresnel and its valuues
  28144. * @returns a clone fresnel configuration
  28145. */
  28146. clone(): FresnelParameters;
  28147. /**
  28148. * Serializes the current fresnel parameters to a JSON representation.
  28149. * @return the JSON serialization
  28150. */
  28151. serialize(): any;
  28152. /**
  28153. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28154. * @param parsedFresnelParameters Define the JSON representation
  28155. * @returns the parsed parameters
  28156. */
  28157. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28158. }
  28159. }
  28160. declare module "babylonjs/Misc/decorators" {
  28161. import { Nullable } from "babylonjs/types";
  28162. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28163. import { Scene } from "babylonjs/scene";
  28164. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28165. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28166. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28167. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28168. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28169. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28170. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28171. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28172. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28173. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28174. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28175. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28176. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28177. /**
  28178. * Decorator used to define property that can be serialized as reference to a camera
  28179. * @param sourceName defines the name of the property to decorate
  28180. */
  28181. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28182. /**
  28183. * Class used to help serialization objects
  28184. */
  28185. export class SerializationHelper {
  28186. /** @hidden */
  28187. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28188. /** @hidden */
  28189. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28190. /** @hidden */
  28191. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28192. /** @hidden */
  28193. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28194. /**
  28195. * Appends the serialized animations from the source animations
  28196. * @param source Source containing the animations
  28197. * @param destination Target to store the animations
  28198. */
  28199. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28200. /**
  28201. * Static function used to serialized a specific entity
  28202. * @param entity defines the entity to serialize
  28203. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28204. * @returns a JSON compatible object representing the serialization of the entity
  28205. */
  28206. static Serialize<T>(entity: T, serializationObject?: any): any;
  28207. /**
  28208. * Creates a new entity from a serialization data object
  28209. * @param creationFunction defines a function used to instanciated the new entity
  28210. * @param source defines the source serialization data
  28211. * @param scene defines the hosting scene
  28212. * @param rootUrl defines the root url for resources
  28213. * @returns a new entity
  28214. */
  28215. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28216. /**
  28217. * Clones an object
  28218. * @param creationFunction defines the function used to instanciate the new object
  28219. * @param source defines the source object
  28220. * @returns the cloned object
  28221. */
  28222. static Clone<T>(creationFunction: () => T, source: T): T;
  28223. /**
  28224. * Instanciates a new object based on a source one (some data will be shared between both object)
  28225. * @param creationFunction defines the function used to instanciate the new object
  28226. * @param source defines the source object
  28227. * @returns the new object
  28228. */
  28229. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28230. }
  28231. }
  28232. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28233. import { Nullable } from "babylonjs/types";
  28234. /**
  28235. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28236. */
  28237. export interface CubeMapInfo {
  28238. /**
  28239. * The pixel array for the front face.
  28240. * This is stored in format, left to right, up to down format.
  28241. */
  28242. front: Nullable<ArrayBufferView>;
  28243. /**
  28244. * The pixel array for the back face.
  28245. * This is stored in format, left to right, up to down format.
  28246. */
  28247. back: Nullable<ArrayBufferView>;
  28248. /**
  28249. * The pixel array for the left face.
  28250. * This is stored in format, left to right, up to down format.
  28251. */
  28252. left: Nullable<ArrayBufferView>;
  28253. /**
  28254. * The pixel array for the right face.
  28255. * This is stored in format, left to right, up to down format.
  28256. */
  28257. right: Nullable<ArrayBufferView>;
  28258. /**
  28259. * The pixel array for the up face.
  28260. * This is stored in format, left to right, up to down format.
  28261. */
  28262. up: Nullable<ArrayBufferView>;
  28263. /**
  28264. * The pixel array for the down face.
  28265. * This is stored in format, left to right, up to down format.
  28266. */
  28267. down: Nullable<ArrayBufferView>;
  28268. /**
  28269. * The size of the cubemap stored.
  28270. *
  28271. * Each faces will be size * size pixels.
  28272. */
  28273. size: number;
  28274. /**
  28275. * The format of the texture.
  28276. *
  28277. * RGBA, RGB.
  28278. */
  28279. format: number;
  28280. /**
  28281. * The type of the texture data.
  28282. *
  28283. * UNSIGNED_INT, FLOAT.
  28284. */
  28285. type: number;
  28286. /**
  28287. * Specifies whether the texture is in gamma space.
  28288. */
  28289. gammaSpace: boolean;
  28290. }
  28291. /**
  28292. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28293. */
  28294. export class PanoramaToCubeMapTools {
  28295. private static FACE_FRONT;
  28296. private static FACE_BACK;
  28297. private static FACE_RIGHT;
  28298. private static FACE_LEFT;
  28299. private static FACE_DOWN;
  28300. private static FACE_UP;
  28301. /**
  28302. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28303. *
  28304. * @param float32Array The source data.
  28305. * @param inputWidth The width of the input panorama.
  28306. * @param inputHeight The height of the input panorama.
  28307. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28308. * @return The cubemap data
  28309. */
  28310. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28311. private static CreateCubemapTexture;
  28312. private static CalcProjectionSpherical;
  28313. }
  28314. }
  28315. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28316. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28318. import { Nullable } from "babylonjs/types";
  28319. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28320. /**
  28321. * Helper class dealing with the extraction of spherical polynomial dataArray
  28322. * from a cube map.
  28323. */
  28324. export class CubeMapToSphericalPolynomialTools {
  28325. private static FileFaces;
  28326. /**
  28327. * Converts a texture to the according Spherical Polynomial data.
  28328. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28329. *
  28330. * @param texture The texture to extract the information from.
  28331. * @return The Spherical Polynomial data.
  28332. */
  28333. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28334. /**
  28335. * Converts a cubemap to the according Spherical Polynomial data.
  28336. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28337. *
  28338. * @param cubeInfo The Cube map to extract the information from.
  28339. * @return The Spherical Polynomial data.
  28340. */
  28341. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28342. }
  28343. }
  28344. declare module "babylonjs/Misc/guid" {
  28345. /**
  28346. * Class used to manipulate GUIDs
  28347. */
  28348. export class GUID {
  28349. /**
  28350. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28351. * Be aware Math.random() could cause collisions, but:
  28352. * "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"
  28353. * @returns a pseudo random id
  28354. */
  28355. static RandomId(): string;
  28356. }
  28357. }
  28358. declare module "babylonjs/Materials/Textures/baseTexture" {
  28359. import { Observable } from "babylonjs/Misc/observable";
  28360. import { Nullable } from "babylonjs/types";
  28361. import { Scene } from "babylonjs/scene";
  28362. import { Matrix } from "babylonjs/Maths/math.vector";
  28363. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28364. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28365. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28366. import { ISize } from "babylonjs/Maths/math.size";
  28367. /**
  28368. * Base class of all the textures in babylon.
  28369. * It groups all the common properties the materials, post process, lights... might need
  28370. * in order to make a correct use of the texture.
  28371. */
  28372. export class BaseTexture implements IAnimatable {
  28373. /**
  28374. * Default anisotropic filtering level for the application.
  28375. * It is set to 4 as a good tradeoff between perf and quality.
  28376. */
  28377. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28378. /**
  28379. * Gets or sets the unique id of the texture
  28380. */
  28381. uniqueId: number;
  28382. /**
  28383. * Define the name of the texture.
  28384. */
  28385. name: string;
  28386. /**
  28387. * Gets or sets an object used to store user defined information.
  28388. */
  28389. metadata: any;
  28390. /**
  28391. * For internal use only. Please do not use.
  28392. */
  28393. reservedDataStore: any;
  28394. private _hasAlpha;
  28395. /**
  28396. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28397. */
  28398. hasAlpha: boolean;
  28399. /**
  28400. * Defines if the alpha value should be determined via the rgb values.
  28401. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28402. */
  28403. getAlphaFromRGB: boolean;
  28404. /**
  28405. * Intensity or strength of the texture.
  28406. * It is commonly used by materials to fine tune the intensity of the texture
  28407. */
  28408. level: number;
  28409. /**
  28410. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28411. * This is part of the texture as textures usually maps to one uv set.
  28412. */
  28413. coordinatesIndex: number;
  28414. private _coordinatesMode;
  28415. /**
  28416. * How a texture is mapped.
  28417. *
  28418. * | Value | Type | Description |
  28419. * | ----- | ----------------------------------- | ----------- |
  28420. * | 0 | EXPLICIT_MODE | |
  28421. * | 1 | SPHERICAL_MODE | |
  28422. * | 2 | PLANAR_MODE | |
  28423. * | 3 | CUBIC_MODE | |
  28424. * | 4 | PROJECTION_MODE | |
  28425. * | 5 | SKYBOX_MODE | |
  28426. * | 6 | INVCUBIC_MODE | |
  28427. * | 7 | EQUIRECTANGULAR_MODE | |
  28428. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28429. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28430. */
  28431. coordinatesMode: number;
  28432. /**
  28433. * | Value | Type | Description |
  28434. * | ----- | ------------------ | ----------- |
  28435. * | 0 | CLAMP_ADDRESSMODE | |
  28436. * | 1 | WRAP_ADDRESSMODE | |
  28437. * | 2 | MIRROR_ADDRESSMODE | |
  28438. */
  28439. wrapU: number;
  28440. /**
  28441. * | Value | Type | Description |
  28442. * | ----- | ------------------ | ----------- |
  28443. * | 0 | CLAMP_ADDRESSMODE | |
  28444. * | 1 | WRAP_ADDRESSMODE | |
  28445. * | 2 | MIRROR_ADDRESSMODE | |
  28446. */
  28447. wrapV: number;
  28448. /**
  28449. * | Value | Type | Description |
  28450. * | ----- | ------------------ | ----------- |
  28451. * | 0 | CLAMP_ADDRESSMODE | |
  28452. * | 1 | WRAP_ADDRESSMODE | |
  28453. * | 2 | MIRROR_ADDRESSMODE | |
  28454. */
  28455. wrapR: number;
  28456. /**
  28457. * With compliant hardware and browser (supporting anisotropic filtering)
  28458. * this defines the level of anisotropic filtering in the texture.
  28459. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28460. */
  28461. anisotropicFilteringLevel: number;
  28462. /**
  28463. * Define if the texture is a cube texture or if false a 2d texture.
  28464. */
  28465. isCube: boolean;
  28466. /**
  28467. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28468. */
  28469. is3D: boolean;
  28470. /**
  28471. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28472. * HDR texture are usually stored in linear space.
  28473. * This only impacts the PBR and Background materials
  28474. */
  28475. gammaSpace: boolean;
  28476. /**
  28477. * Gets whether or not the texture contains RGBD data.
  28478. */
  28479. readonly isRGBD: boolean;
  28480. /**
  28481. * Is Z inverted in the texture (useful in a cube texture).
  28482. */
  28483. invertZ: boolean;
  28484. /**
  28485. * Are mip maps generated for this texture or not.
  28486. */
  28487. readonly noMipmap: boolean;
  28488. /**
  28489. * @hidden
  28490. */
  28491. lodLevelInAlpha: boolean;
  28492. /**
  28493. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28494. */
  28495. lodGenerationOffset: number;
  28496. /**
  28497. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28498. */
  28499. lodGenerationScale: number;
  28500. /**
  28501. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28502. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28503. * average roughness values.
  28504. */
  28505. linearSpecularLOD: boolean;
  28506. /**
  28507. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28508. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28509. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28510. */
  28511. irradianceTexture: Nullable<BaseTexture>;
  28512. /**
  28513. * Define if the texture is a render target.
  28514. */
  28515. isRenderTarget: boolean;
  28516. /**
  28517. * Define the unique id of the texture in the scene.
  28518. */
  28519. readonly uid: string;
  28520. /**
  28521. * Return a string representation of the texture.
  28522. * @returns the texture as a string
  28523. */
  28524. toString(): string;
  28525. /**
  28526. * Get the class name of the texture.
  28527. * @returns "BaseTexture"
  28528. */
  28529. getClassName(): string;
  28530. /**
  28531. * Define the list of animation attached to the texture.
  28532. */
  28533. animations: import("babylonjs/Animations/animation").Animation[];
  28534. /**
  28535. * An event triggered when the texture is disposed.
  28536. */
  28537. onDisposeObservable: Observable<BaseTexture>;
  28538. private _onDisposeObserver;
  28539. /**
  28540. * Callback triggered when the texture has been disposed.
  28541. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28542. */
  28543. onDispose: () => void;
  28544. /**
  28545. * Define the current state of the loading sequence when in delayed load mode.
  28546. */
  28547. delayLoadState: number;
  28548. private _scene;
  28549. /** @hidden */
  28550. _texture: Nullable<InternalTexture>;
  28551. private _uid;
  28552. /**
  28553. * Define if the texture is preventinga material to render or not.
  28554. * If not and the texture is not ready, the engine will use a default black texture instead.
  28555. */
  28556. readonly isBlocking: boolean;
  28557. /**
  28558. * Instantiates a new BaseTexture.
  28559. * Base class of all the textures in babylon.
  28560. * It groups all the common properties the materials, post process, lights... might need
  28561. * in order to make a correct use of the texture.
  28562. * @param scene Define the scene the texture blongs to
  28563. */
  28564. constructor(scene: Nullable<Scene>);
  28565. /**
  28566. * Get the scene the texture belongs to.
  28567. * @returns the scene or null if undefined
  28568. */
  28569. getScene(): Nullable<Scene>;
  28570. /**
  28571. * Get the texture transform matrix used to offset tile the texture for istance.
  28572. * @returns the transformation matrix
  28573. */
  28574. getTextureMatrix(): Matrix;
  28575. /**
  28576. * Get the texture reflection matrix used to rotate/transform the reflection.
  28577. * @returns the reflection matrix
  28578. */
  28579. getReflectionTextureMatrix(): Matrix;
  28580. /**
  28581. * Get the underlying lower level texture from Babylon.
  28582. * @returns the insternal texture
  28583. */
  28584. getInternalTexture(): Nullable<InternalTexture>;
  28585. /**
  28586. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28587. * @returns true if ready or not blocking
  28588. */
  28589. isReadyOrNotBlocking(): boolean;
  28590. /**
  28591. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28592. * @returns true if fully ready
  28593. */
  28594. isReady(): boolean;
  28595. private _cachedSize;
  28596. /**
  28597. * Get the size of the texture.
  28598. * @returns the texture size.
  28599. */
  28600. getSize(): ISize;
  28601. /**
  28602. * Get the base size of the texture.
  28603. * It can be different from the size if the texture has been resized for POT for instance
  28604. * @returns the base size
  28605. */
  28606. getBaseSize(): ISize;
  28607. /**
  28608. * Update the sampling mode of the texture.
  28609. * Default is Trilinear mode.
  28610. *
  28611. * | Value | Type | Description |
  28612. * | ----- | ------------------ | ----------- |
  28613. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28614. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28615. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28616. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28617. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28618. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28619. * | 7 | NEAREST_LINEAR | |
  28620. * | 8 | NEAREST_NEAREST | |
  28621. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28622. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28623. * | 11 | LINEAR_LINEAR | |
  28624. * | 12 | LINEAR_NEAREST | |
  28625. *
  28626. * > _mag_: magnification filter (close to the viewer)
  28627. * > _min_: minification filter (far from the viewer)
  28628. * > _mip_: filter used between mip map levels
  28629. *@param samplingMode Define the new sampling mode of the texture
  28630. */
  28631. updateSamplingMode(samplingMode: number): void;
  28632. /**
  28633. * Scales the texture if is `canRescale()`
  28634. * @param ratio the resize factor we want to use to rescale
  28635. */
  28636. scale(ratio: number): void;
  28637. /**
  28638. * Get if the texture can rescale.
  28639. */
  28640. readonly canRescale: boolean;
  28641. /** @hidden */
  28642. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28643. /** @hidden */
  28644. _rebuild(): void;
  28645. /**
  28646. * Triggers the load sequence in delayed load mode.
  28647. */
  28648. delayLoad(): void;
  28649. /**
  28650. * Clones the texture.
  28651. * @returns the cloned texture
  28652. */
  28653. clone(): Nullable<BaseTexture>;
  28654. /**
  28655. * Get the texture underlying type (INT, FLOAT...)
  28656. */
  28657. readonly textureType: number;
  28658. /**
  28659. * Get the texture underlying format (RGB, RGBA...)
  28660. */
  28661. readonly textureFormat: number;
  28662. /**
  28663. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28664. * This will returns an RGBA array buffer containing either in values (0-255) or
  28665. * float values (0-1) depending of the underlying buffer type.
  28666. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28667. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28668. * @param buffer defines a user defined buffer to fill with data (can be null)
  28669. * @returns The Array buffer containing the pixels data.
  28670. */
  28671. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28672. /**
  28673. * Release and destroy the underlying lower level texture aka internalTexture.
  28674. */
  28675. releaseInternalTexture(): void;
  28676. /**
  28677. * Get the polynomial representation of the texture data.
  28678. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28679. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28680. */
  28681. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28682. /** @hidden */
  28683. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28684. /** @hidden */
  28685. readonly _lodTextureMid: Nullable<BaseTexture>;
  28686. /** @hidden */
  28687. readonly _lodTextureLow: Nullable<BaseTexture>;
  28688. /**
  28689. * Dispose the texture and release its associated resources.
  28690. */
  28691. dispose(): void;
  28692. /**
  28693. * Serialize the texture into a JSON representation that can be parsed later on.
  28694. * @returns the JSON representation of the texture
  28695. */
  28696. serialize(): any;
  28697. /**
  28698. * Helper function to be called back once a list of texture contains only ready textures.
  28699. * @param textures Define the list of textures to wait for
  28700. * @param callback Define the callback triggered once the entire list will be ready
  28701. */
  28702. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28703. }
  28704. }
  28705. declare module "babylonjs/Materials/Textures/internalTexture" {
  28706. import { Observable } from "babylonjs/Misc/observable";
  28707. import { Nullable, int } from "babylonjs/types";
  28708. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28709. import { Engine } from "babylonjs/Engines/engine";
  28710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28711. /**
  28712. * Class used to store data associated with WebGL texture data for the engine
  28713. * This class should not be used directly
  28714. */
  28715. export class InternalTexture {
  28716. /** @hidden */
  28717. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28718. /**
  28719. * The source of the texture data is unknown
  28720. */
  28721. static DATASOURCE_UNKNOWN: number;
  28722. /**
  28723. * Texture data comes from an URL
  28724. */
  28725. static DATASOURCE_URL: number;
  28726. /**
  28727. * Texture data is only used for temporary storage
  28728. */
  28729. static DATASOURCE_TEMP: number;
  28730. /**
  28731. * Texture data comes from raw data (ArrayBuffer)
  28732. */
  28733. static DATASOURCE_RAW: number;
  28734. /**
  28735. * Texture content is dynamic (video or dynamic texture)
  28736. */
  28737. static DATASOURCE_DYNAMIC: number;
  28738. /**
  28739. * Texture content is generated by rendering to it
  28740. */
  28741. static DATASOURCE_RENDERTARGET: number;
  28742. /**
  28743. * Texture content is part of a multi render target process
  28744. */
  28745. static DATASOURCE_MULTIRENDERTARGET: number;
  28746. /**
  28747. * Texture data comes from a cube data file
  28748. */
  28749. static DATASOURCE_CUBE: number;
  28750. /**
  28751. * Texture data comes from a raw cube data
  28752. */
  28753. static DATASOURCE_CUBERAW: number;
  28754. /**
  28755. * Texture data come from a prefiltered cube data file
  28756. */
  28757. static DATASOURCE_CUBEPREFILTERED: number;
  28758. /**
  28759. * Texture content is raw 3D data
  28760. */
  28761. static DATASOURCE_RAW3D: number;
  28762. /**
  28763. * Texture content is a depth texture
  28764. */
  28765. static DATASOURCE_DEPTHTEXTURE: number;
  28766. /**
  28767. * Texture data comes from a raw cube data encoded with RGBD
  28768. */
  28769. static DATASOURCE_CUBERAW_RGBD: number;
  28770. /**
  28771. * Defines if the texture is ready
  28772. */
  28773. isReady: boolean;
  28774. /**
  28775. * Defines if the texture is a cube texture
  28776. */
  28777. isCube: boolean;
  28778. /**
  28779. * Defines if the texture contains 3D data
  28780. */
  28781. is3D: boolean;
  28782. /**
  28783. * Defines if the texture contains multiview data
  28784. */
  28785. isMultiview: boolean;
  28786. /**
  28787. * Gets the URL used to load this texture
  28788. */
  28789. url: string;
  28790. /**
  28791. * Gets the sampling mode of the texture
  28792. */
  28793. samplingMode: number;
  28794. /**
  28795. * Gets a boolean indicating if the texture needs mipmaps generation
  28796. */
  28797. generateMipMaps: boolean;
  28798. /**
  28799. * Gets the number of samples used by the texture (WebGL2+ only)
  28800. */
  28801. samples: number;
  28802. /**
  28803. * Gets the type of the texture (int, float...)
  28804. */
  28805. type: number;
  28806. /**
  28807. * Gets the format of the texture (RGB, RGBA...)
  28808. */
  28809. format: number;
  28810. /**
  28811. * Observable called when the texture is loaded
  28812. */
  28813. onLoadedObservable: Observable<InternalTexture>;
  28814. /**
  28815. * Gets the width of the texture
  28816. */
  28817. width: number;
  28818. /**
  28819. * Gets the height of the texture
  28820. */
  28821. height: number;
  28822. /**
  28823. * Gets the depth of the texture
  28824. */
  28825. depth: number;
  28826. /**
  28827. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28828. */
  28829. baseWidth: number;
  28830. /**
  28831. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28832. */
  28833. baseHeight: number;
  28834. /**
  28835. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28836. */
  28837. baseDepth: number;
  28838. /**
  28839. * Gets a boolean indicating if the texture is inverted on Y axis
  28840. */
  28841. invertY: boolean;
  28842. /** @hidden */
  28843. _invertVScale: boolean;
  28844. /** @hidden */
  28845. _associatedChannel: number;
  28846. /** @hidden */
  28847. _dataSource: number;
  28848. /** @hidden */
  28849. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28850. /** @hidden */
  28851. _bufferView: Nullable<ArrayBufferView>;
  28852. /** @hidden */
  28853. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28854. /** @hidden */
  28855. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28856. /** @hidden */
  28857. _size: number;
  28858. /** @hidden */
  28859. _extension: string;
  28860. /** @hidden */
  28861. _files: Nullable<string[]>;
  28862. /** @hidden */
  28863. _workingCanvas: Nullable<HTMLCanvasElement>;
  28864. /** @hidden */
  28865. _workingContext: Nullable<CanvasRenderingContext2D>;
  28866. /** @hidden */
  28867. _framebuffer: Nullable<WebGLFramebuffer>;
  28868. /** @hidden */
  28869. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28870. /** @hidden */
  28871. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28872. /** @hidden */
  28873. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28874. /** @hidden */
  28875. _attachments: Nullable<number[]>;
  28876. /** @hidden */
  28877. _cachedCoordinatesMode: Nullable<number>;
  28878. /** @hidden */
  28879. _cachedWrapU: Nullable<number>;
  28880. /** @hidden */
  28881. _cachedWrapV: Nullable<number>;
  28882. /** @hidden */
  28883. _cachedWrapR: Nullable<number>;
  28884. /** @hidden */
  28885. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28886. /** @hidden */
  28887. _isDisabled: boolean;
  28888. /** @hidden */
  28889. _compression: Nullable<string>;
  28890. /** @hidden */
  28891. _generateStencilBuffer: boolean;
  28892. /** @hidden */
  28893. _generateDepthBuffer: boolean;
  28894. /** @hidden */
  28895. _comparisonFunction: number;
  28896. /** @hidden */
  28897. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28898. /** @hidden */
  28899. _lodGenerationScale: number;
  28900. /** @hidden */
  28901. _lodGenerationOffset: number;
  28902. /** @hidden */
  28903. _colorTextureArray: Nullable<WebGLTexture>;
  28904. /** @hidden */
  28905. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28906. /** @hidden */
  28907. _lodTextureHigh: Nullable<BaseTexture>;
  28908. /** @hidden */
  28909. _lodTextureMid: Nullable<BaseTexture>;
  28910. /** @hidden */
  28911. _lodTextureLow: Nullable<BaseTexture>;
  28912. /** @hidden */
  28913. _isRGBD: boolean;
  28914. /** @hidden */
  28915. _linearSpecularLOD: boolean;
  28916. /** @hidden */
  28917. _irradianceTexture: Nullable<BaseTexture>;
  28918. /** @hidden */
  28919. _webGLTexture: Nullable<WebGLTexture>;
  28920. /** @hidden */
  28921. _references: number;
  28922. private _engine;
  28923. /**
  28924. * Gets the Engine the texture belongs to.
  28925. * @returns The babylon engine
  28926. */
  28927. getEngine(): Engine;
  28928. /**
  28929. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28930. */
  28931. readonly dataSource: number;
  28932. /**
  28933. * Creates a new InternalTexture
  28934. * @param engine defines the engine to use
  28935. * @param dataSource defines the type of data that will be used
  28936. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28937. */
  28938. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28939. /**
  28940. * Increments the number of references (ie. the number of Texture that point to it)
  28941. */
  28942. incrementReferences(): void;
  28943. /**
  28944. * Change the size of the texture (not the size of the content)
  28945. * @param width defines the new width
  28946. * @param height defines the new height
  28947. * @param depth defines the new depth (1 by default)
  28948. */
  28949. updateSize(width: int, height: int, depth?: int): void;
  28950. /** @hidden */
  28951. _rebuild(): void;
  28952. /** @hidden */
  28953. _swapAndDie(target: InternalTexture): void;
  28954. /**
  28955. * Dispose the current allocated resources
  28956. */
  28957. dispose(): void;
  28958. }
  28959. }
  28960. declare module "babylonjs/Materials/effect" {
  28961. import { Observable } from "babylonjs/Misc/observable";
  28962. import { Nullable } from "babylonjs/types";
  28963. import { IDisposable } from "babylonjs/scene";
  28964. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28965. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28966. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28967. import { Engine } from "babylonjs/Engines/engine";
  28968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28970. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28971. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28973. /**
  28974. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28975. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28976. */
  28977. export class EffectFallbacks {
  28978. private _defines;
  28979. private _currentRank;
  28980. private _maxRank;
  28981. private _mesh;
  28982. /**
  28983. * Removes the fallback from the bound mesh.
  28984. */
  28985. unBindMesh(): void;
  28986. /**
  28987. * Adds a fallback on the specified property.
  28988. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28989. * @param define The name of the define in the shader
  28990. */
  28991. addFallback(rank: number, define: string): void;
  28992. /**
  28993. * Sets the mesh to use CPU skinning when needing to fallback.
  28994. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28995. * @param mesh The mesh to use the fallbacks.
  28996. */
  28997. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28998. /**
  28999. * Checks to see if more fallbacks are still availible.
  29000. */
  29001. readonly hasMoreFallbacks: boolean;
  29002. /**
  29003. * Removes the defines that should be removed when falling back.
  29004. * @param currentDefines defines the current define statements for the shader.
  29005. * @param effect defines the current effect we try to compile
  29006. * @returns The resulting defines with defines of the current rank removed.
  29007. */
  29008. reduce(currentDefines: string, effect: Effect): string;
  29009. }
  29010. /**
  29011. * Options to be used when creating an effect.
  29012. */
  29013. export class EffectCreationOptions {
  29014. /**
  29015. * Atrributes that will be used in the shader.
  29016. */
  29017. attributes: string[];
  29018. /**
  29019. * Uniform varible names that will be set in the shader.
  29020. */
  29021. uniformsNames: string[];
  29022. /**
  29023. * Uniform buffer varible names that will be set in the shader.
  29024. */
  29025. uniformBuffersNames: string[];
  29026. /**
  29027. * Sampler texture variable names that will be set in the shader.
  29028. */
  29029. samplers: string[];
  29030. /**
  29031. * Define statements that will be set in the shader.
  29032. */
  29033. defines: any;
  29034. /**
  29035. * Possible fallbacks for this effect to improve performance when needed.
  29036. */
  29037. fallbacks: Nullable<EffectFallbacks>;
  29038. /**
  29039. * Callback that will be called when the shader is compiled.
  29040. */
  29041. onCompiled: Nullable<(effect: Effect) => void>;
  29042. /**
  29043. * Callback that will be called if an error occurs during shader compilation.
  29044. */
  29045. onError: Nullable<(effect: Effect, errors: string) => void>;
  29046. /**
  29047. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29048. */
  29049. indexParameters: any;
  29050. /**
  29051. * Max number of lights that can be used in the shader.
  29052. */
  29053. maxSimultaneousLights: number;
  29054. /**
  29055. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29056. */
  29057. transformFeedbackVaryings: Nullable<string[]>;
  29058. }
  29059. /**
  29060. * Effect containing vertex and fragment shader that can be executed on an object.
  29061. */
  29062. export class Effect implements IDisposable {
  29063. /**
  29064. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29065. */
  29066. static ShadersRepository: string;
  29067. /**
  29068. * Name of the effect.
  29069. */
  29070. name: any;
  29071. /**
  29072. * String container all the define statements that should be set on the shader.
  29073. */
  29074. defines: string;
  29075. /**
  29076. * Callback that will be called when the shader is compiled.
  29077. */
  29078. onCompiled: Nullable<(effect: Effect) => void>;
  29079. /**
  29080. * Callback that will be called if an error occurs during shader compilation.
  29081. */
  29082. onError: Nullable<(effect: Effect, errors: string) => void>;
  29083. /**
  29084. * Callback that will be called when effect is bound.
  29085. */
  29086. onBind: Nullable<(effect: Effect) => void>;
  29087. /**
  29088. * Unique ID of the effect.
  29089. */
  29090. uniqueId: number;
  29091. /**
  29092. * Observable that will be called when the shader is compiled.
  29093. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29094. */
  29095. onCompileObservable: Observable<Effect>;
  29096. /**
  29097. * Observable that will be called if an error occurs during shader compilation.
  29098. */
  29099. onErrorObservable: Observable<Effect>;
  29100. /** @hidden */
  29101. _onBindObservable: Nullable<Observable<Effect>>;
  29102. /**
  29103. * Observable that will be called when effect is bound.
  29104. */
  29105. readonly onBindObservable: Observable<Effect>;
  29106. /** @hidden */
  29107. _bonesComputationForcedToCPU: boolean;
  29108. private static _uniqueIdSeed;
  29109. private _engine;
  29110. private _uniformBuffersNames;
  29111. private _uniformsNames;
  29112. private _samplerList;
  29113. private _samplers;
  29114. private _isReady;
  29115. private _compilationError;
  29116. private _attributesNames;
  29117. private _attributes;
  29118. private _uniforms;
  29119. /**
  29120. * Key for the effect.
  29121. * @hidden
  29122. */
  29123. _key: string;
  29124. private _indexParameters;
  29125. private _fallbacks;
  29126. private _vertexSourceCode;
  29127. private _fragmentSourceCode;
  29128. private _vertexSourceCodeOverride;
  29129. private _fragmentSourceCodeOverride;
  29130. private _transformFeedbackVaryings;
  29131. /**
  29132. * Compiled shader to webGL program.
  29133. * @hidden
  29134. */
  29135. _pipelineContext: Nullable<IPipelineContext>;
  29136. private _valueCache;
  29137. private static _baseCache;
  29138. /**
  29139. * Instantiates an effect.
  29140. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29141. * @param baseName Name of the effect.
  29142. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29143. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29144. * @param samplers List of sampler variables that will be passed to the shader.
  29145. * @param engine Engine to be used to render the effect
  29146. * @param defines Define statements to be added to the shader.
  29147. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29148. * @param onCompiled Callback that will be called when the shader is compiled.
  29149. * @param onError Callback that will be called if an error occurs during shader compilation.
  29150. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29151. */
  29152. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29153. private _useFinalCode;
  29154. /**
  29155. * Unique key for this effect
  29156. */
  29157. readonly key: string;
  29158. /**
  29159. * If the effect has been compiled and prepared.
  29160. * @returns if the effect is compiled and prepared.
  29161. */
  29162. isReady(): boolean;
  29163. private _isReadyInternal;
  29164. /**
  29165. * The engine the effect was initialized with.
  29166. * @returns the engine.
  29167. */
  29168. getEngine(): Engine;
  29169. /**
  29170. * The pipeline context for this effect
  29171. * @returns the associated pipeline context
  29172. */
  29173. getPipelineContext(): Nullable<IPipelineContext>;
  29174. /**
  29175. * The set of names of attribute variables for the shader.
  29176. * @returns An array of attribute names.
  29177. */
  29178. getAttributesNames(): string[];
  29179. /**
  29180. * Returns the attribute at the given index.
  29181. * @param index The index of the attribute.
  29182. * @returns The location of the attribute.
  29183. */
  29184. getAttributeLocation(index: number): number;
  29185. /**
  29186. * Returns the attribute based on the name of the variable.
  29187. * @param name of the attribute to look up.
  29188. * @returns the attribute location.
  29189. */
  29190. getAttributeLocationByName(name: string): number;
  29191. /**
  29192. * The number of attributes.
  29193. * @returns the numnber of attributes.
  29194. */
  29195. getAttributesCount(): number;
  29196. /**
  29197. * Gets the index of a uniform variable.
  29198. * @param uniformName of the uniform to look up.
  29199. * @returns the index.
  29200. */
  29201. getUniformIndex(uniformName: string): number;
  29202. /**
  29203. * Returns the attribute based on the name of the variable.
  29204. * @param uniformName of the uniform to look up.
  29205. * @returns the location of the uniform.
  29206. */
  29207. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29208. /**
  29209. * Returns an array of sampler variable names
  29210. * @returns The array of sampler variable neames.
  29211. */
  29212. getSamplers(): string[];
  29213. /**
  29214. * The error from the last compilation.
  29215. * @returns the error string.
  29216. */
  29217. getCompilationError(): string;
  29218. /**
  29219. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29220. * @param func The callback to be used.
  29221. */
  29222. executeWhenCompiled(func: (effect: Effect) => void): void;
  29223. private _checkIsReady;
  29224. /** @hidden */
  29225. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29226. /** @hidden */
  29227. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29228. /** @hidden */
  29229. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29230. /**
  29231. * Recompiles the webGL program
  29232. * @param vertexSourceCode The source code for the vertex shader.
  29233. * @param fragmentSourceCode The source code for the fragment shader.
  29234. * @param onCompiled Callback called when completed.
  29235. * @param onError Callback called on error.
  29236. * @hidden
  29237. */
  29238. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29239. /**
  29240. * Prepares the effect
  29241. * @hidden
  29242. */
  29243. _prepareEffect(): void;
  29244. private _processCompilationErrors;
  29245. /**
  29246. * Checks if the effect is supported. (Must be called after compilation)
  29247. */
  29248. readonly isSupported: boolean;
  29249. /**
  29250. * Binds a texture to the engine to be used as output of the shader.
  29251. * @param channel Name of the output variable.
  29252. * @param texture Texture to bind.
  29253. * @hidden
  29254. */
  29255. _bindTexture(channel: string, texture: InternalTexture): void;
  29256. /**
  29257. * Sets a texture on the engine to be used in the shader.
  29258. * @param channel Name of the sampler variable.
  29259. * @param texture Texture to set.
  29260. */
  29261. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29262. /**
  29263. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29264. * @param channel Name of the sampler variable.
  29265. * @param texture Texture to set.
  29266. */
  29267. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29268. /**
  29269. * Sets an array of textures on the engine to be used in the shader.
  29270. * @param channel Name of the variable.
  29271. * @param textures Textures to set.
  29272. */
  29273. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29274. /**
  29275. * 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)
  29276. * @param channel Name of the sampler variable.
  29277. * @param postProcess Post process to get the input texture from.
  29278. */
  29279. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29280. /**
  29281. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29282. * 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)
  29283. * @param channel Name of the sampler variable.
  29284. * @param postProcess Post process to get the output texture from.
  29285. */
  29286. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29287. /** @hidden */
  29288. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29289. /** @hidden */
  29290. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29291. /** @hidden */
  29292. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29293. /** @hidden */
  29294. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29295. /**
  29296. * Binds a buffer to a uniform.
  29297. * @param buffer Buffer to bind.
  29298. * @param name Name of the uniform variable to bind to.
  29299. */
  29300. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29301. /**
  29302. * Binds block to a uniform.
  29303. * @param blockName Name of the block to bind.
  29304. * @param index Index to bind.
  29305. */
  29306. bindUniformBlock(blockName: string, index: number): void;
  29307. /**
  29308. * Sets an interger value on a uniform variable.
  29309. * @param uniformName Name of the variable.
  29310. * @param value Value to be set.
  29311. * @returns this effect.
  29312. */
  29313. setInt(uniformName: string, value: number): Effect;
  29314. /**
  29315. * Sets an int array on a uniform variable.
  29316. * @param uniformName Name of the variable.
  29317. * @param array array to be set.
  29318. * @returns this effect.
  29319. */
  29320. setIntArray(uniformName: string, array: Int32Array): Effect;
  29321. /**
  29322. * 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)
  29323. * @param uniformName Name of the variable.
  29324. * @param array array to be set.
  29325. * @returns this effect.
  29326. */
  29327. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29328. /**
  29329. * 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)
  29330. * @param uniformName Name of the variable.
  29331. * @param array array to be set.
  29332. * @returns this effect.
  29333. */
  29334. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29335. /**
  29336. * 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)
  29337. * @param uniformName Name of the variable.
  29338. * @param array array to be set.
  29339. * @returns this effect.
  29340. */
  29341. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29342. /**
  29343. * Sets an float array on a uniform variable.
  29344. * @param uniformName Name of the variable.
  29345. * @param array array to be set.
  29346. * @returns this effect.
  29347. */
  29348. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29349. /**
  29350. * 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)
  29351. * @param uniformName Name of the variable.
  29352. * @param array array to be set.
  29353. * @returns this effect.
  29354. */
  29355. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29356. /**
  29357. * 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)
  29358. * @param uniformName Name of the variable.
  29359. * @param array array to be set.
  29360. * @returns this effect.
  29361. */
  29362. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29363. /**
  29364. * 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)
  29365. * @param uniformName Name of the variable.
  29366. * @param array array to be set.
  29367. * @returns this effect.
  29368. */
  29369. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29370. /**
  29371. * Sets an array on a uniform variable.
  29372. * @param uniformName Name of the variable.
  29373. * @param array array to be set.
  29374. * @returns this effect.
  29375. */
  29376. setArray(uniformName: string, array: number[]): Effect;
  29377. /**
  29378. * 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)
  29379. * @param uniformName Name of the variable.
  29380. * @param array array to be set.
  29381. * @returns this effect.
  29382. */
  29383. setArray2(uniformName: string, array: number[]): Effect;
  29384. /**
  29385. * 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)
  29386. * @param uniformName Name of the variable.
  29387. * @param array array to be set.
  29388. * @returns this effect.
  29389. */
  29390. setArray3(uniformName: string, array: number[]): Effect;
  29391. /**
  29392. * 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)
  29393. * @param uniformName Name of the variable.
  29394. * @param array array to be set.
  29395. * @returns this effect.
  29396. */
  29397. setArray4(uniformName: string, array: number[]): Effect;
  29398. /**
  29399. * Sets matrices on a uniform variable.
  29400. * @param uniformName Name of the variable.
  29401. * @param matrices matrices to be set.
  29402. * @returns this effect.
  29403. */
  29404. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29405. /**
  29406. * Sets matrix on a uniform variable.
  29407. * @param uniformName Name of the variable.
  29408. * @param matrix matrix to be set.
  29409. * @returns this effect.
  29410. */
  29411. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29412. /**
  29413. * 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)
  29414. * @param uniformName Name of the variable.
  29415. * @param matrix matrix to be set.
  29416. * @returns this effect.
  29417. */
  29418. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29419. /**
  29420. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29421. * @param uniformName Name of the variable.
  29422. * @param matrix matrix to be set.
  29423. * @returns this effect.
  29424. */
  29425. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29426. /**
  29427. * Sets a float on a uniform variable.
  29428. * @param uniformName Name of the variable.
  29429. * @param value value to be set.
  29430. * @returns this effect.
  29431. */
  29432. setFloat(uniformName: string, value: number): Effect;
  29433. /**
  29434. * Sets a boolean on a uniform variable.
  29435. * @param uniformName Name of the variable.
  29436. * @param bool value to be set.
  29437. * @returns this effect.
  29438. */
  29439. setBool(uniformName: string, bool: boolean): Effect;
  29440. /**
  29441. * Sets a Vector2 on a uniform variable.
  29442. * @param uniformName Name of the variable.
  29443. * @param vector2 vector2 to be set.
  29444. * @returns this effect.
  29445. */
  29446. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29447. /**
  29448. * Sets a float2 on a uniform variable.
  29449. * @param uniformName Name of the variable.
  29450. * @param x First float in float2.
  29451. * @param y Second float in float2.
  29452. * @returns this effect.
  29453. */
  29454. setFloat2(uniformName: string, x: number, y: number): Effect;
  29455. /**
  29456. * Sets a Vector3 on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param vector3 Value to be set.
  29459. * @returns this effect.
  29460. */
  29461. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29462. /**
  29463. * Sets a float3 on a uniform variable.
  29464. * @param uniformName Name of the variable.
  29465. * @param x First float in float3.
  29466. * @param y Second float in float3.
  29467. * @param z Third float in float3.
  29468. * @returns this effect.
  29469. */
  29470. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29471. /**
  29472. * Sets a Vector4 on a uniform variable.
  29473. * @param uniformName Name of the variable.
  29474. * @param vector4 Value to be set.
  29475. * @returns this effect.
  29476. */
  29477. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29478. /**
  29479. * Sets a float4 on a uniform variable.
  29480. * @param uniformName Name of the variable.
  29481. * @param x First float in float4.
  29482. * @param y Second float in float4.
  29483. * @param z Third float in float4.
  29484. * @param w Fourth float in float4.
  29485. * @returns this effect.
  29486. */
  29487. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29488. /**
  29489. * Sets a Color3 on a uniform variable.
  29490. * @param uniformName Name of the variable.
  29491. * @param color3 Value to be set.
  29492. * @returns this effect.
  29493. */
  29494. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29495. /**
  29496. * Sets a Color4 on a uniform variable.
  29497. * @param uniformName Name of the variable.
  29498. * @param color3 Value to be set.
  29499. * @param alpha Alpha value to be set.
  29500. * @returns this effect.
  29501. */
  29502. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29503. /**
  29504. * Sets a Color4 on a uniform variable
  29505. * @param uniformName defines the name of the variable
  29506. * @param color4 defines the value to be set
  29507. * @returns this effect.
  29508. */
  29509. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29510. /** Release all associated resources */
  29511. dispose(): void;
  29512. /**
  29513. * This function will add a new shader to the shader store
  29514. * @param name the name of the shader
  29515. * @param pixelShader optional pixel shader content
  29516. * @param vertexShader optional vertex shader content
  29517. */
  29518. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29519. /**
  29520. * Store of each shader (The can be looked up using effect.key)
  29521. */
  29522. static ShadersStore: {
  29523. [key: string]: string;
  29524. };
  29525. /**
  29526. * Store of each included file for a shader (The can be looked up using effect.key)
  29527. */
  29528. static IncludesShadersStore: {
  29529. [key: string]: string;
  29530. };
  29531. /**
  29532. * Resets the cache of effects.
  29533. */
  29534. static ResetCache(): void;
  29535. }
  29536. }
  29537. declare module "babylonjs/Materials/uniformBuffer" {
  29538. import { Nullable, FloatArray } from "babylonjs/types";
  29539. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29540. import { Engine } from "babylonjs/Engines/engine";
  29541. import { Effect } from "babylonjs/Materials/effect";
  29542. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29543. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29544. import { Color3 } from "babylonjs/Maths/math.color";
  29545. /**
  29546. * Uniform buffer objects.
  29547. *
  29548. * Handles blocks of uniform on the GPU.
  29549. *
  29550. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29551. *
  29552. * For more information, please refer to :
  29553. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29554. */
  29555. export class UniformBuffer {
  29556. private _engine;
  29557. private _buffer;
  29558. private _data;
  29559. private _bufferData;
  29560. private _dynamic?;
  29561. private _uniformLocations;
  29562. private _uniformSizes;
  29563. private _uniformLocationPointer;
  29564. private _needSync;
  29565. private _noUBO;
  29566. private _currentEffect;
  29567. private static _MAX_UNIFORM_SIZE;
  29568. private static _tempBuffer;
  29569. /**
  29570. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29571. * This is dynamic to allow compat with webgl 1 and 2.
  29572. * You will need to pass the name of the uniform as well as the value.
  29573. */
  29574. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29575. /**
  29576. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29577. * This is dynamic to allow compat with webgl 1 and 2.
  29578. * You will need to pass the name of the uniform as well as the value.
  29579. */
  29580. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29581. /**
  29582. * Lambda to Update a single float in a uniform buffer.
  29583. * This is dynamic to allow compat with webgl 1 and 2.
  29584. * You will need to pass the name of the uniform as well as the value.
  29585. */
  29586. updateFloat: (name: string, x: number) => void;
  29587. /**
  29588. * Lambda to Update a vec2 of float in a uniform buffer.
  29589. * This is dynamic to allow compat with webgl 1 and 2.
  29590. * You will need to pass the name of the uniform as well as the value.
  29591. */
  29592. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29593. /**
  29594. * Lambda to Update a vec3 of float in a uniform buffer.
  29595. * This is dynamic to allow compat with webgl 1 and 2.
  29596. * You will need to pass the name of the uniform as well as the value.
  29597. */
  29598. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29599. /**
  29600. * Lambda to Update a vec4 of float in a uniform buffer.
  29601. * This is dynamic to allow compat with webgl 1 and 2.
  29602. * You will need to pass the name of the uniform as well as the value.
  29603. */
  29604. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29605. /**
  29606. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29607. * This is dynamic to allow compat with webgl 1 and 2.
  29608. * You will need to pass the name of the uniform as well as the value.
  29609. */
  29610. updateMatrix: (name: string, mat: Matrix) => void;
  29611. /**
  29612. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29613. * This is dynamic to allow compat with webgl 1 and 2.
  29614. * You will need to pass the name of the uniform as well as the value.
  29615. */
  29616. updateVector3: (name: string, vector: Vector3) => void;
  29617. /**
  29618. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29619. * This is dynamic to allow compat with webgl 1 and 2.
  29620. * You will need to pass the name of the uniform as well as the value.
  29621. */
  29622. updateVector4: (name: string, vector: Vector4) => void;
  29623. /**
  29624. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29625. * This is dynamic to allow compat with webgl 1 and 2.
  29626. * You will need to pass the name of the uniform as well as the value.
  29627. */
  29628. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29629. /**
  29630. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29631. * This is dynamic to allow compat with webgl 1 and 2.
  29632. * You will need to pass the name of the uniform as well as the value.
  29633. */
  29634. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29635. /**
  29636. * Instantiates a new Uniform buffer objects.
  29637. *
  29638. * Handles blocks of uniform on the GPU.
  29639. *
  29640. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29641. *
  29642. * For more information, please refer to :
  29643. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29644. * @param engine Define the engine the buffer is associated with
  29645. * @param data Define the data contained in the buffer
  29646. * @param dynamic Define if the buffer is updatable
  29647. */
  29648. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29649. /**
  29650. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29651. * or just falling back on setUniformXXX calls.
  29652. */
  29653. readonly useUbo: boolean;
  29654. /**
  29655. * Indicates if the WebGL underlying uniform buffer is in sync
  29656. * with the javascript cache data.
  29657. */
  29658. readonly isSync: boolean;
  29659. /**
  29660. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29661. * Also, a dynamic UniformBuffer will disable cache verification and always
  29662. * update the underlying WebGL uniform buffer to the GPU.
  29663. * @returns if Dynamic, otherwise false
  29664. */
  29665. isDynamic(): boolean;
  29666. /**
  29667. * The data cache on JS side.
  29668. * @returns the underlying data as a float array
  29669. */
  29670. getData(): Float32Array;
  29671. /**
  29672. * The underlying WebGL Uniform buffer.
  29673. * @returns the webgl buffer
  29674. */
  29675. getBuffer(): Nullable<DataBuffer>;
  29676. /**
  29677. * std140 layout specifies how to align data within an UBO structure.
  29678. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29679. * for specs.
  29680. */
  29681. private _fillAlignment;
  29682. /**
  29683. * Adds an uniform in the buffer.
  29684. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29685. * for the layout to be correct !
  29686. * @param name Name of the uniform, as used in the uniform block in the shader.
  29687. * @param size Data size, or data directly.
  29688. */
  29689. addUniform(name: string, size: number | number[]): void;
  29690. /**
  29691. * Adds a Matrix 4x4 to the uniform buffer.
  29692. * @param name Name of the uniform, as used in the uniform block in the shader.
  29693. * @param mat A 4x4 matrix.
  29694. */
  29695. addMatrix(name: string, mat: Matrix): void;
  29696. /**
  29697. * Adds a vec2 to the uniform buffer.
  29698. * @param name Name of the uniform, as used in the uniform block in the shader.
  29699. * @param x Define the x component value of the vec2
  29700. * @param y Define the y component value of the vec2
  29701. */
  29702. addFloat2(name: string, x: number, y: number): void;
  29703. /**
  29704. * Adds a vec3 to the uniform buffer.
  29705. * @param name Name of the uniform, as used in the uniform block in the shader.
  29706. * @param x Define the x component value of the vec3
  29707. * @param y Define the y component value of the vec3
  29708. * @param z Define the z component value of the vec3
  29709. */
  29710. addFloat3(name: string, x: number, y: number, z: number): void;
  29711. /**
  29712. * Adds a vec3 to the uniform buffer.
  29713. * @param name Name of the uniform, as used in the uniform block in the shader.
  29714. * @param color Define the vec3 from a Color
  29715. */
  29716. addColor3(name: string, color: Color3): void;
  29717. /**
  29718. * Adds a vec4 to the uniform buffer.
  29719. * @param name Name of the uniform, as used in the uniform block in the shader.
  29720. * @param color Define the rgb components from a Color
  29721. * @param alpha Define the a component of the vec4
  29722. */
  29723. addColor4(name: string, color: Color3, alpha: number): void;
  29724. /**
  29725. * Adds a vec3 to the uniform buffer.
  29726. * @param name Name of the uniform, as used in the uniform block in the shader.
  29727. * @param vector Define the vec3 components from a Vector
  29728. */
  29729. addVector3(name: string, vector: Vector3): void;
  29730. /**
  29731. * Adds a Matrix 3x3 to the uniform buffer.
  29732. * @param name Name of the uniform, as used in the uniform block in the shader.
  29733. */
  29734. addMatrix3x3(name: string): void;
  29735. /**
  29736. * Adds a Matrix 2x2 to the uniform buffer.
  29737. * @param name Name of the uniform, as used in the uniform block in the shader.
  29738. */
  29739. addMatrix2x2(name: string): void;
  29740. /**
  29741. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29742. */
  29743. create(): void;
  29744. /** @hidden */
  29745. _rebuild(): void;
  29746. /**
  29747. * Updates the WebGL Uniform Buffer on the GPU.
  29748. * If the `dynamic` flag is set to true, no cache comparison is done.
  29749. * Otherwise, the buffer will be updated only if the cache differs.
  29750. */
  29751. update(): void;
  29752. /**
  29753. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29754. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29755. * @param data Define the flattened data
  29756. * @param size Define the size of the data.
  29757. */
  29758. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29759. private _valueCache;
  29760. private _cacheMatrix;
  29761. private _updateMatrix3x3ForUniform;
  29762. private _updateMatrix3x3ForEffect;
  29763. private _updateMatrix2x2ForEffect;
  29764. private _updateMatrix2x2ForUniform;
  29765. private _updateFloatForEffect;
  29766. private _updateFloatForUniform;
  29767. private _updateFloat2ForEffect;
  29768. private _updateFloat2ForUniform;
  29769. private _updateFloat3ForEffect;
  29770. private _updateFloat3ForUniform;
  29771. private _updateFloat4ForEffect;
  29772. private _updateFloat4ForUniform;
  29773. private _updateMatrixForEffect;
  29774. private _updateMatrixForUniform;
  29775. private _updateVector3ForEffect;
  29776. private _updateVector3ForUniform;
  29777. private _updateVector4ForEffect;
  29778. private _updateVector4ForUniform;
  29779. private _updateColor3ForEffect;
  29780. private _updateColor3ForUniform;
  29781. private _updateColor4ForEffect;
  29782. private _updateColor4ForUniform;
  29783. /**
  29784. * Sets a sampler uniform on the effect.
  29785. * @param name Define the name of the sampler.
  29786. * @param texture Define the texture to set in the sampler
  29787. */
  29788. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29789. /**
  29790. * Directly updates the value of the uniform in the cache AND on the GPU.
  29791. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29792. * @param data Define the flattened data
  29793. */
  29794. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29795. /**
  29796. * Binds this uniform buffer to an effect.
  29797. * @param effect Define the effect to bind the buffer to
  29798. * @param name Name of the uniform block in the shader.
  29799. */
  29800. bindToEffect(effect: Effect, name: string): void;
  29801. /**
  29802. * Disposes the uniform buffer.
  29803. */
  29804. dispose(): void;
  29805. }
  29806. }
  29807. declare module "babylonjs/Audio/analyser" {
  29808. import { Scene } from "babylonjs/scene";
  29809. /**
  29810. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29812. */
  29813. export class Analyser {
  29814. /**
  29815. * Gets or sets the smoothing
  29816. * @ignorenaming
  29817. */
  29818. SMOOTHING: number;
  29819. /**
  29820. * Gets or sets the FFT table size
  29821. * @ignorenaming
  29822. */
  29823. FFT_SIZE: number;
  29824. /**
  29825. * Gets or sets the bar graph amplitude
  29826. * @ignorenaming
  29827. */
  29828. BARGRAPHAMPLITUDE: number;
  29829. /**
  29830. * Gets or sets the position of the debug canvas
  29831. * @ignorenaming
  29832. */
  29833. DEBUGCANVASPOS: {
  29834. x: number;
  29835. y: number;
  29836. };
  29837. /**
  29838. * Gets or sets the debug canvas size
  29839. * @ignorenaming
  29840. */
  29841. DEBUGCANVASSIZE: {
  29842. width: number;
  29843. height: number;
  29844. };
  29845. private _byteFreqs;
  29846. private _byteTime;
  29847. private _floatFreqs;
  29848. private _webAudioAnalyser;
  29849. private _debugCanvas;
  29850. private _debugCanvasContext;
  29851. private _scene;
  29852. private _registerFunc;
  29853. private _audioEngine;
  29854. /**
  29855. * Creates a new analyser
  29856. * @param scene defines hosting scene
  29857. */
  29858. constructor(scene: Scene);
  29859. /**
  29860. * Get the number of data values you will have to play with for the visualization
  29861. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29862. * @returns a number
  29863. */
  29864. getFrequencyBinCount(): number;
  29865. /**
  29866. * Gets the current frequency data as a byte array
  29867. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29868. * @returns a Uint8Array
  29869. */
  29870. getByteFrequencyData(): Uint8Array;
  29871. /**
  29872. * Gets the current waveform as a byte array
  29873. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29874. * @returns a Uint8Array
  29875. */
  29876. getByteTimeDomainData(): Uint8Array;
  29877. /**
  29878. * Gets the current frequency data as a float array
  29879. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29880. * @returns a Float32Array
  29881. */
  29882. getFloatFrequencyData(): Float32Array;
  29883. /**
  29884. * Renders the debug canvas
  29885. */
  29886. drawDebugCanvas(): void;
  29887. /**
  29888. * Stops rendering the debug canvas and removes it
  29889. */
  29890. stopDebugCanvas(): void;
  29891. /**
  29892. * Connects two audio nodes
  29893. * @param inputAudioNode defines first node to connect
  29894. * @param outputAudioNode defines second node to connect
  29895. */
  29896. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29897. /**
  29898. * Releases all associated resources
  29899. */
  29900. dispose(): void;
  29901. }
  29902. }
  29903. declare module "babylonjs/Audio/audioEngine" {
  29904. import { IDisposable } from "babylonjs/scene";
  29905. import { Analyser } from "babylonjs/Audio/analyser";
  29906. import { Nullable } from "babylonjs/types";
  29907. import { Observable } from "babylonjs/Misc/observable";
  29908. /**
  29909. * This represents an audio engine and it is responsible
  29910. * to play, synchronize and analyse sounds throughout the application.
  29911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29912. */
  29913. export interface IAudioEngine extends IDisposable {
  29914. /**
  29915. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29916. */
  29917. readonly canUseWebAudio: boolean;
  29918. /**
  29919. * Gets the current AudioContext if available.
  29920. */
  29921. readonly audioContext: Nullable<AudioContext>;
  29922. /**
  29923. * The master gain node defines the global audio volume of your audio engine.
  29924. */
  29925. readonly masterGain: GainNode;
  29926. /**
  29927. * Gets whether or not mp3 are supported by your browser.
  29928. */
  29929. readonly isMP3supported: boolean;
  29930. /**
  29931. * Gets whether or not ogg are supported by your browser.
  29932. */
  29933. readonly isOGGsupported: boolean;
  29934. /**
  29935. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29936. * @ignoreNaming
  29937. */
  29938. WarnedWebAudioUnsupported: boolean;
  29939. /**
  29940. * Defines if the audio engine relies on a custom unlocked button.
  29941. * In this case, the embedded button will not be displayed.
  29942. */
  29943. useCustomUnlockedButton: boolean;
  29944. /**
  29945. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29946. */
  29947. readonly unlocked: boolean;
  29948. /**
  29949. * Event raised when audio has been unlocked on the browser.
  29950. */
  29951. onAudioUnlockedObservable: Observable<AudioEngine>;
  29952. /**
  29953. * Event raised when audio has been locked on the browser.
  29954. */
  29955. onAudioLockedObservable: Observable<AudioEngine>;
  29956. /**
  29957. * Flags the audio engine in Locked state.
  29958. * This happens due to new browser policies preventing audio to autoplay.
  29959. */
  29960. lock(): void;
  29961. /**
  29962. * Unlocks the audio engine once a user action has been done on the dom.
  29963. * This is helpful to resume play once browser policies have been satisfied.
  29964. */
  29965. unlock(): void;
  29966. }
  29967. /**
  29968. * This represents the default audio engine used in babylon.
  29969. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29971. */
  29972. export class AudioEngine implements IAudioEngine {
  29973. private _audioContext;
  29974. private _audioContextInitialized;
  29975. private _muteButton;
  29976. private _hostElement;
  29977. /**
  29978. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29979. */
  29980. canUseWebAudio: boolean;
  29981. /**
  29982. * The master gain node defines the global audio volume of your audio engine.
  29983. */
  29984. masterGain: GainNode;
  29985. /**
  29986. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29987. * @ignoreNaming
  29988. */
  29989. WarnedWebAudioUnsupported: boolean;
  29990. /**
  29991. * Gets whether or not mp3 are supported by your browser.
  29992. */
  29993. isMP3supported: boolean;
  29994. /**
  29995. * Gets whether or not ogg are supported by your browser.
  29996. */
  29997. isOGGsupported: boolean;
  29998. /**
  29999. * Gets whether audio has been unlocked on the device.
  30000. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30001. * a user interaction has happened.
  30002. */
  30003. unlocked: boolean;
  30004. /**
  30005. * Defines if the audio engine relies on a custom unlocked button.
  30006. * In this case, the embedded button will not be displayed.
  30007. */
  30008. useCustomUnlockedButton: boolean;
  30009. /**
  30010. * Event raised when audio has been unlocked on the browser.
  30011. */
  30012. onAudioUnlockedObservable: Observable<AudioEngine>;
  30013. /**
  30014. * Event raised when audio has been locked on the browser.
  30015. */
  30016. onAudioLockedObservable: Observable<AudioEngine>;
  30017. /**
  30018. * Gets the current AudioContext if available.
  30019. */
  30020. readonly audioContext: Nullable<AudioContext>;
  30021. private _connectedAnalyser;
  30022. /**
  30023. * Instantiates a new audio engine.
  30024. *
  30025. * There should be only one per page as some browsers restrict the number
  30026. * of audio contexts you can create.
  30027. * @param hostElement defines the host element where to display the mute icon if necessary
  30028. */
  30029. constructor(hostElement?: Nullable<HTMLElement>);
  30030. /**
  30031. * Flags the audio engine in Locked state.
  30032. * This happens due to new browser policies preventing audio to autoplay.
  30033. */
  30034. lock(): void;
  30035. /**
  30036. * Unlocks the audio engine once a user action has been done on the dom.
  30037. * This is helpful to resume play once browser policies have been satisfied.
  30038. */
  30039. unlock(): void;
  30040. private _resumeAudioContext;
  30041. private _initializeAudioContext;
  30042. private _tryToRun;
  30043. private _triggerRunningState;
  30044. private _triggerSuspendedState;
  30045. private _displayMuteButton;
  30046. private _moveButtonToTopLeft;
  30047. private _onResize;
  30048. private _hideMuteButton;
  30049. /**
  30050. * Destroy and release the resources associated with the audio ccontext.
  30051. */
  30052. dispose(): void;
  30053. /**
  30054. * Gets the global volume sets on the master gain.
  30055. * @returns the global volume if set or -1 otherwise
  30056. */
  30057. getGlobalVolume(): number;
  30058. /**
  30059. * Sets the global volume of your experience (sets on the master gain).
  30060. * @param newVolume Defines the new global volume of the application
  30061. */
  30062. setGlobalVolume(newVolume: number): void;
  30063. /**
  30064. * Connect the audio engine to an audio analyser allowing some amazing
  30065. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30067. * @param analyser The analyser to connect to the engine
  30068. */
  30069. connectToAnalyser(analyser: Analyser): void;
  30070. }
  30071. }
  30072. declare module "babylonjs/Loading/loadingScreen" {
  30073. /**
  30074. * Interface used to present a loading screen while loading a scene
  30075. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30076. */
  30077. export interface ILoadingScreen {
  30078. /**
  30079. * Function called to display the loading screen
  30080. */
  30081. displayLoadingUI: () => void;
  30082. /**
  30083. * Function called to hide the loading screen
  30084. */
  30085. hideLoadingUI: () => void;
  30086. /**
  30087. * Gets or sets the color to use for the background
  30088. */
  30089. loadingUIBackgroundColor: string;
  30090. /**
  30091. * Gets or sets the text to display while loading
  30092. */
  30093. loadingUIText: string;
  30094. }
  30095. /**
  30096. * Class used for the default loading screen
  30097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30098. */
  30099. export class DefaultLoadingScreen implements ILoadingScreen {
  30100. private _renderingCanvas;
  30101. private _loadingText;
  30102. private _loadingDivBackgroundColor;
  30103. private _loadingDiv;
  30104. private _loadingTextDiv;
  30105. /** Gets or sets the logo url to use for the default loading screen */
  30106. static DefaultLogoUrl: string;
  30107. /** Gets or sets the spinner url to use for the default loading screen */
  30108. static DefaultSpinnerUrl: string;
  30109. /**
  30110. * Creates a new default loading screen
  30111. * @param _renderingCanvas defines the canvas used to render the scene
  30112. * @param _loadingText defines the default text to display
  30113. * @param _loadingDivBackgroundColor defines the default background color
  30114. */
  30115. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30116. /**
  30117. * Function called to display the loading screen
  30118. */
  30119. displayLoadingUI(): void;
  30120. /**
  30121. * Function called to hide the loading screen
  30122. */
  30123. hideLoadingUI(): void;
  30124. /**
  30125. * Gets or sets the text to display while loading
  30126. */
  30127. loadingUIText: string;
  30128. /**
  30129. * Gets or sets the color to use for the background
  30130. */
  30131. loadingUIBackgroundColor: string;
  30132. private _resizeLoadingUI;
  30133. }
  30134. }
  30135. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30136. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30137. import { Engine } from "babylonjs/Engines/engine";
  30138. import { Nullable } from "babylonjs/types";
  30139. /** @hidden */
  30140. export class WebGLPipelineContext implements IPipelineContext {
  30141. engine: Engine;
  30142. program: Nullable<WebGLProgram>;
  30143. context?: WebGLRenderingContext;
  30144. vertexShader?: WebGLShader;
  30145. fragmentShader?: WebGLShader;
  30146. isParallelCompiled: boolean;
  30147. onCompiled?: () => void;
  30148. transformFeedback?: WebGLTransformFeedback | null;
  30149. readonly isAsync: boolean;
  30150. readonly isReady: boolean;
  30151. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30152. }
  30153. }
  30154. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30155. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30156. /** @hidden */
  30157. export class WebGLDataBuffer extends DataBuffer {
  30158. private _buffer;
  30159. constructor(resource: WebGLBuffer);
  30160. readonly underlyingResource: any;
  30161. }
  30162. }
  30163. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30164. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30165. /** @hidden */
  30166. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30167. attributeProcessor(attribute: string): string;
  30168. varyingProcessor(varying: string, isFragment: boolean): string;
  30169. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30170. }
  30171. }
  30172. declare module "babylonjs/Misc/perfCounter" {
  30173. /**
  30174. * This class is used to track a performance counter which is number based.
  30175. * The user has access to many properties which give statistics of different nature.
  30176. *
  30177. * The implementer can track two kinds of Performance Counter: time and count.
  30178. * 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.
  30179. * 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.
  30180. */
  30181. export class PerfCounter {
  30182. /**
  30183. * Gets or sets a global boolean to turn on and off all the counters
  30184. */
  30185. static Enabled: boolean;
  30186. /**
  30187. * Returns the smallest value ever
  30188. */
  30189. readonly min: number;
  30190. /**
  30191. * Returns the biggest value ever
  30192. */
  30193. readonly max: number;
  30194. /**
  30195. * Returns the average value since the performance counter is running
  30196. */
  30197. readonly average: number;
  30198. /**
  30199. * Returns the average value of the last second the counter was monitored
  30200. */
  30201. readonly lastSecAverage: number;
  30202. /**
  30203. * Returns the current value
  30204. */
  30205. readonly current: number;
  30206. /**
  30207. * Gets the accumulated total
  30208. */
  30209. readonly total: number;
  30210. /**
  30211. * Gets the total value count
  30212. */
  30213. readonly count: number;
  30214. /**
  30215. * Creates a new counter
  30216. */
  30217. constructor();
  30218. /**
  30219. * Call this method to start monitoring a new frame.
  30220. * 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.
  30221. */
  30222. fetchNewFrame(): void;
  30223. /**
  30224. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30225. * @param newCount the count value to add to the monitored count
  30226. * @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.
  30227. */
  30228. addCount(newCount: number, fetchResult: boolean): void;
  30229. /**
  30230. * Start monitoring this performance counter
  30231. */
  30232. beginMonitoring(): void;
  30233. /**
  30234. * Compute the time lapsed since the previous beginMonitoring() call.
  30235. * @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
  30236. */
  30237. endMonitoring(newFrame?: boolean): void;
  30238. private _fetchResult;
  30239. private _startMonitoringTime;
  30240. private _min;
  30241. private _max;
  30242. private _average;
  30243. private _current;
  30244. private _totalValueCount;
  30245. private _totalAccumulated;
  30246. private _lastSecAverage;
  30247. private _lastSecAccumulated;
  30248. private _lastSecTime;
  30249. private _lastSecValueCount;
  30250. }
  30251. }
  30252. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30253. /**
  30254. * Interface for any object that can request an animation frame
  30255. */
  30256. export interface ICustomAnimationFrameRequester {
  30257. /**
  30258. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30259. */
  30260. renderFunction?: Function;
  30261. /**
  30262. * Called to request the next frame to render to
  30263. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30264. */
  30265. requestAnimationFrame: Function;
  30266. /**
  30267. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30268. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30269. */
  30270. requestID?: number;
  30271. }
  30272. }
  30273. declare module "babylonjs/Materials/Textures/videoTexture" {
  30274. import { Observable } from "babylonjs/Misc/observable";
  30275. import { Nullable } from "babylonjs/types";
  30276. import { Scene } from "babylonjs/scene";
  30277. import { Texture } from "babylonjs/Materials/Textures/texture";
  30278. /**
  30279. * Settings for finer control over video usage
  30280. */
  30281. export interface VideoTextureSettings {
  30282. /**
  30283. * Applies `autoplay` to video, if specified
  30284. */
  30285. autoPlay?: boolean;
  30286. /**
  30287. * Applies `loop` to video, if specified
  30288. */
  30289. loop?: boolean;
  30290. /**
  30291. * Automatically updates internal texture from video at every frame in the render loop
  30292. */
  30293. autoUpdateTexture: boolean;
  30294. /**
  30295. * Image src displayed during the video loading or until the user interacts with the video.
  30296. */
  30297. poster?: string;
  30298. }
  30299. /**
  30300. * If you want to display a video in your scene, this is the special texture for that.
  30301. * This special texture works similar to other textures, with the exception of a few parameters.
  30302. * @see https://doc.babylonjs.com/how_to/video_texture
  30303. */
  30304. export class VideoTexture extends Texture {
  30305. /**
  30306. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30307. */
  30308. readonly autoUpdateTexture: boolean;
  30309. /**
  30310. * The video instance used by the texture internally
  30311. */
  30312. readonly video: HTMLVideoElement;
  30313. private _onUserActionRequestedObservable;
  30314. /**
  30315. * Event triggerd when a dom action is required by the user to play the video.
  30316. * This happens due to recent changes in browser policies preventing video to auto start.
  30317. */
  30318. readonly onUserActionRequestedObservable: Observable<Texture>;
  30319. private _generateMipMaps;
  30320. private _engine;
  30321. private _stillImageCaptured;
  30322. private _displayingPosterTexture;
  30323. private _settings;
  30324. private _createInternalTextureOnEvent;
  30325. /**
  30326. * Creates a video texture.
  30327. * If you want to display a video in your scene, this is the special texture for that.
  30328. * This special texture works similar to other textures, with the exception of a few parameters.
  30329. * @see https://doc.babylonjs.com/how_to/video_texture
  30330. * @param name optional name, will detect from video source, if not defined
  30331. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30332. * @param scene is obviously the current scene.
  30333. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30334. * @param invertY is false by default but can be used to invert video on Y axis
  30335. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30336. * @param settings allows finer control over video usage
  30337. */
  30338. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30339. private _getName;
  30340. private _getVideo;
  30341. private _createInternalTexture;
  30342. private reset;
  30343. /**
  30344. * @hidden Internal method to initiate `update`.
  30345. */
  30346. _rebuild(): void;
  30347. /**
  30348. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30349. */
  30350. update(): void;
  30351. /**
  30352. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30353. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30354. */
  30355. updateTexture(isVisible: boolean): void;
  30356. protected _updateInternalTexture: () => void;
  30357. /**
  30358. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30359. * @param url New url.
  30360. */
  30361. updateURL(url: string): void;
  30362. /**
  30363. * Dispose the texture and release its associated resources.
  30364. */
  30365. dispose(): void;
  30366. /**
  30367. * Creates a video texture straight from a stream.
  30368. * @param scene Define the scene the texture should be created in
  30369. * @param stream Define the stream the texture should be created from
  30370. * @returns The created video texture as a promise
  30371. */
  30372. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30373. /**
  30374. * Creates a video texture straight from your WebCam video feed.
  30375. * @param scene Define the scene the texture should be created in
  30376. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30377. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30378. * @returns The created video texture as a promise
  30379. */
  30380. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30381. minWidth: number;
  30382. maxWidth: number;
  30383. minHeight: number;
  30384. maxHeight: number;
  30385. deviceId: string;
  30386. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30387. /**
  30388. * Creates a video texture straight from your WebCam video feed.
  30389. * @param scene Define the scene the texture should be created in
  30390. * @param onReady Define a callback to triggered once the texture will be ready
  30391. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30392. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30393. */
  30394. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30395. minWidth: number;
  30396. maxWidth: number;
  30397. minHeight: number;
  30398. maxHeight: number;
  30399. deviceId: string;
  30400. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30401. }
  30402. }
  30403. declare module "babylonjs/Engines/engine" {
  30404. import { Observable } from "babylonjs/Misc/observable";
  30405. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30406. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30407. import { Scene } from "babylonjs/scene";
  30408. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30409. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30410. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30411. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30412. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30414. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30415. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30416. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30417. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30418. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30419. import { WebRequest } from "babylonjs/Misc/webRequest";
  30420. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30421. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30422. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30423. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30424. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30425. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30426. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30427. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30428. import { Material } from "babylonjs/Materials/material";
  30429. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30431. /**
  30432. * Defines the interface used by objects containing a viewport (like a camera)
  30433. */
  30434. interface IViewportOwnerLike {
  30435. /**
  30436. * Gets or sets the viewport
  30437. */
  30438. viewport: IViewportLike;
  30439. }
  30440. /**
  30441. * Interface for attribute information associated with buffer instanciation
  30442. */
  30443. export class InstancingAttributeInfo {
  30444. /**
  30445. * Index/offset of the attribute in the vertex shader
  30446. */
  30447. index: number;
  30448. /**
  30449. * size of the attribute, 1, 2, 3 or 4
  30450. */
  30451. attributeSize: number;
  30452. /**
  30453. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30454. * default is FLOAT
  30455. */
  30456. attribyteType: number;
  30457. /**
  30458. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30459. */
  30460. normalized: boolean;
  30461. /**
  30462. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30463. */
  30464. offset: number;
  30465. /**
  30466. * Name of the GLSL attribute, for debugging purpose only
  30467. */
  30468. attributeName: string;
  30469. }
  30470. /**
  30471. * Define options used to create a depth texture
  30472. */
  30473. export class DepthTextureCreationOptions {
  30474. /** Specifies whether or not a stencil should be allocated in the texture */
  30475. generateStencil?: boolean;
  30476. /** Specifies whether or not bilinear filtering is enable on the texture */
  30477. bilinearFiltering?: boolean;
  30478. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30479. comparisonFunction?: number;
  30480. /** Specifies if the created texture is a cube texture */
  30481. isCube?: boolean;
  30482. }
  30483. /**
  30484. * Class used to describe the capabilities of the engine relatively to the current browser
  30485. */
  30486. export class EngineCapabilities {
  30487. /** Maximum textures units per fragment shader */
  30488. maxTexturesImageUnits: number;
  30489. /** Maximum texture units per vertex shader */
  30490. maxVertexTextureImageUnits: number;
  30491. /** Maximum textures units in the entire pipeline */
  30492. maxCombinedTexturesImageUnits: number;
  30493. /** Maximum texture size */
  30494. maxTextureSize: number;
  30495. /** Maximum cube texture size */
  30496. maxCubemapTextureSize: number;
  30497. /** Maximum render texture size */
  30498. maxRenderTextureSize: number;
  30499. /** Maximum number of vertex attributes */
  30500. maxVertexAttribs: number;
  30501. /** Maximum number of varyings */
  30502. maxVaryingVectors: number;
  30503. /** Maximum number of uniforms per vertex shader */
  30504. maxVertexUniformVectors: number;
  30505. /** Maximum number of uniforms per fragment shader */
  30506. maxFragmentUniformVectors: number;
  30507. /** Defines if standard derivates (dx/dy) are supported */
  30508. standardDerivatives: boolean;
  30509. /** Defines if s3tc texture compression is supported */
  30510. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30511. /** Defines if pvrtc texture compression is supported */
  30512. pvrtc: any;
  30513. /** Defines if etc1 texture compression is supported */
  30514. etc1: any;
  30515. /** Defines if etc2 texture compression is supported */
  30516. etc2: any;
  30517. /** Defines if astc texture compression is supported */
  30518. astc: any;
  30519. /** Defines if float textures are supported */
  30520. textureFloat: boolean;
  30521. /** Defines if vertex array objects are supported */
  30522. vertexArrayObject: boolean;
  30523. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30524. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30525. /** Gets the maximum level of anisotropy supported */
  30526. maxAnisotropy: number;
  30527. /** Defines if instancing is supported */
  30528. instancedArrays: boolean;
  30529. /** Defines if 32 bits indices are supported */
  30530. uintIndices: boolean;
  30531. /** Defines if high precision shaders are supported */
  30532. highPrecisionShaderSupported: boolean;
  30533. /** Defines if depth reading in the fragment shader is supported */
  30534. fragmentDepthSupported: boolean;
  30535. /** Defines if float texture linear filtering is supported*/
  30536. textureFloatLinearFiltering: boolean;
  30537. /** Defines if rendering to float textures is supported */
  30538. textureFloatRender: boolean;
  30539. /** Defines if half float textures are supported*/
  30540. textureHalfFloat: boolean;
  30541. /** Defines if half float texture linear filtering is supported*/
  30542. textureHalfFloatLinearFiltering: boolean;
  30543. /** Defines if rendering to half float textures is supported */
  30544. textureHalfFloatRender: boolean;
  30545. /** Defines if textureLOD shader command is supported */
  30546. textureLOD: boolean;
  30547. /** Defines if draw buffers extension is supported */
  30548. drawBuffersExtension: boolean;
  30549. /** Defines if depth textures are supported */
  30550. depthTextureExtension: boolean;
  30551. /** Defines if float color buffer are supported */
  30552. colorBufferFloat: boolean;
  30553. /** Gets disjoint timer query extension (null if not supported) */
  30554. timerQuery: EXT_disjoint_timer_query;
  30555. /** Defines if timestamp can be used with timer query */
  30556. canUseTimestampForTimerQuery: boolean;
  30557. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30558. multiview: any;
  30559. /** Function used to let the system compiles shaders in background */
  30560. parallelShaderCompile: {
  30561. COMPLETION_STATUS_KHR: number;
  30562. };
  30563. /** Max number of texture samples for MSAA */
  30564. maxMSAASamples: number;
  30565. }
  30566. /** Interface defining initialization parameters for Engine class */
  30567. export interface EngineOptions extends WebGLContextAttributes {
  30568. /**
  30569. * Defines if the engine should no exceed a specified device ratio
  30570. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30571. */
  30572. limitDeviceRatio?: number;
  30573. /**
  30574. * Defines if webvr should be enabled automatically
  30575. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30576. */
  30577. autoEnableWebVR?: boolean;
  30578. /**
  30579. * Defines if webgl2 should be turned off even if supported
  30580. * @see http://doc.babylonjs.com/features/webgl2
  30581. */
  30582. disableWebGL2Support?: boolean;
  30583. /**
  30584. * Defines if webaudio should be initialized as well
  30585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30586. */
  30587. audioEngine?: boolean;
  30588. /**
  30589. * Defines if animations should run using a deterministic lock step
  30590. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30591. */
  30592. deterministicLockstep?: boolean;
  30593. /** Defines the maximum steps to use with deterministic lock step mode */
  30594. lockstepMaxSteps?: number;
  30595. /**
  30596. * Defines that engine should ignore context lost events
  30597. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30598. */
  30599. doNotHandleContextLost?: boolean;
  30600. /**
  30601. * Defines that engine should ignore modifying touch action attribute and style
  30602. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30603. */
  30604. doNotHandleTouchAction?: boolean;
  30605. /**
  30606. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30607. */
  30608. useHighPrecisionFloats?: boolean;
  30609. }
  30610. /**
  30611. * Defines the interface used by display changed events
  30612. */
  30613. export interface IDisplayChangedEventArgs {
  30614. /** Gets the vrDisplay object (if any) */
  30615. vrDisplay: Nullable<any>;
  30616. /** Gets a boolean indicating if webVR is supported */
  30617. vrSupported: boolean;
  30618. }
  30619. /**
  30620. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30621. */
  30622. export class Engine {
  30623. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30624. static ExceptionList: ({
  30625. key: string;
  30626. capture: string;
  30627. captureConstraint: number;
  30628. targets: string[];
  30629. } | {
  30630. key: string;
  30631. capture: null;
  30632. captureConstraint: null;
  30633. targets: string[];
  30634. })[];
  30635. /** Gets the list of created engines */
  30636. static readonly Instances: Engine[];
  30637. /**
  30638. * Gets the latest created engine
  30639. */
  30640. static readonly LastCreatedEngine: Nullable<Engine>;
  30641. /**
  30642. * Gets the latest created scene
  30643. */
  30644. static readonly LastCreatedScene: Nullable<Scene>;
  30645. /**
  30646. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30647. * @param flag defines which part of the materials must be marked as dirty
  30648. * @param predicate defines a predicate used to filter which materials should be affected
  30649. */
  30650. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30651. /** @hidden */
  30652. static _TextureLoaders: IInternalTextureLoader[];
  30653. /** Defines that alpha blending is disabled */
  30654. static readonly ALPHA_DISABLE: number;
  30655. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30656. static readonly ALPHA_ADD: number;
  30657. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30658. static readonly ALPHA_COMBINE: number;
  30659. /** Defines that alpha blending to DEST - SRC * DEST */
  30660. static readonly ALPHA_SUBTRACT: number;
  30661. /** Defines that alpha blending to SRC * DEST */
  30662. static readonly ALPHA_MULTIPLY: number;
  30663. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30664. static readonly ALPHA_MAXIMIZED: number;
  30665. /** Defines that alpha blending to SRC + DEST */
  30666. static readonly ALPHA_ONEONE: number;
  30667. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30668. static readonly ALPHA_PREMULTIPLIED: number;
  30669. /**
  30670. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30671. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30672. */
  30673. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30674. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30675. static readonly ALPHA_INTERPOLATE: number;
  30676. /**
  30677. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30678. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30679. */
  30680. static readonly ALPHA_SCREENMODE: number;
  30681. /** Defines that the ressource is not delayed*/
  30682. static readonly DELAYLOADSTATE_NONE: number;
  30683. /** Defines that the ressource was successfully delay loaded */
  30684. static readonly DELAYLOADSTATE_LOADED: number;
  30685. /** Defines that the ressource is currently delay loading */
  30686. static readonly DELAYLOADSTATE_LOADING: number;
  30687. /** Defines that the ressource is delayed and has not started loading */
  30688. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30689. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30690. static readonly NEVER: number;
  30691. /** 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 */
  30692. static readonly ALWAYS: number;
  30693. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30694. static readonly LESS: number;
  30695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30696. static readonly EQUAL: number;
  30697. /** 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 */
  30698. static readonly LEQUAL: number;
  30699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30700. static readonly GREATER: number;
  30701. /** 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 */
  30702. static readonly GEQUAL: number;
  30703. /** 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 */
  30704. static readonly NOTEQUAL: number;
  30705. /** Passed to stencilOperation to specify that stencil value must be kept */
  30706. static readonly KEEP: number;
  30707. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30708. static readonly REPLACE: number;
  30709. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30710. static readonly INCR: number;
  30711. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30712. static readonly DECR: number;
  30713. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30714. static readonly INVERT: number;
  30715. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30716. static readonly INCR_WRAP: number;
  30717. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30718. static readonly DECR_WRAP: number;
  30719. /** Texture is not repeating outside of 0..1 UVs */
  30720. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30721. /** Texture is repeating outside of 0..1 UVs */
  30722. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30723. /** Texture is repeating and mirrored */
  30724. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30725. /** ALPHA */
  30726. static readonly TEXTUREFORMAT_ALPHA: number;
  30727. /** LUMINANCE */
  30728. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30729. /** LUMINANCE_ALPHA */
  30730. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30731. /** RGB */
  30732. static readonly TEXTUREFORMAT_RGB: number;
  30733. /** RGBA */
  30734. static readonly TEXTUREFORMAT_RGBA: number;
  30735. /** RED */
  30736. static readonly TEXTUREFORMAT_RED: number;
  30737. /** RED (2nd reference) */
  30738. static readonly TEXTUREFORMAT_R: number;
  30739. /** RG */
  30740. static readonly TEXTUREFORMAT_RG: number;
  30741. /** RED_INTEGER */
  30742. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30743. /** RED_INTEGER (2nd reference) */
  30744. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30745. /** RG_INTEGER */
  30746. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30747. /** RGB_INTEGER */
  30748. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30749. /** RGBA_INTEGER */
  30750. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30751. /** UNSIGNED_BYTE */
  30752. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30753. /** UNSIGNED_BYTE (2nd reference) */
  30754. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30755. /** FLOAT */
  30756. static readonly TEXTURETYPE_FLOAT: number;
  30757. /** HALF_FLOAT */
  30758. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30759. /** BYTE */
  30760. static readonly TEXTURETYPE_BYTE: number;
  30761. /** SHORT */
  30762. static readonly TEXTURETYPE_SHORT: number;
  30763. /** UNSIGNED_SHORT */
  30764. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30765. /** INT */
  30766. static readonly TEXTURETYPE_INT: number;
  30767. /** UNSIGNED_INT */
  30768. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30769. /** UNSIGNED_SHORT_4_4_4_4 */
  30770. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30771. /** UNSIGNED_SHORT_5_5_5_1 */
  30772. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30773. /** UNSIGNED_SHORT_5_6_5 */
  30774. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30775. /** UNSIGNED_INT_2_10_10_10_REV */
  30776. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30777. /** UNSIGNED_INT_24_8 */
  30778. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30779. /** UNSIGNED_INT_10F_11F_11F_REV */
  30780. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30781. /** UNSIGNED_INT_5_9_9_9_REV */
  30782. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30783. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30784. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30785. /** nearest is mag = nearest and min = nearest and mip = linear */
  30786. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30787. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30788. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30789. /** Trilinear is mag = linear and min = linear and mip = linear */
  30790. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30791. /** nearest is mag = nearest and min = nearest and mip = linear */
  30792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30795. /** Trilinear is mag = linear and min = linear and mip = linear */
  30796. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30797. /** mag = nearest and min = nearest and mip = nearest */
  30798. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30799. /** mag = nearest and min = linear and mip = nearest */
  30800. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30801. /** mag = nearest and min = linear and mip = linear */
  30802. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30803. /** mag = nearest and min = linear and mip = none */
  30804. static readonly TEXTURE_NEAREST_LINEAR: number;
  30805. /** mag = nearest and min = nearest and mip = none */
  30806. static readonly TEXTURE_NEAREST_NEAREST: number;
  30807. /** mag = linear and min = nearest and mip = nearest */
  30808. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30809. /** mag = linear and min = nearest and mip = linear */
  30810. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30811. /** mag = linear and min = linear and mip = none */
  30812. static readonly TEXTURE_LINEAR_LINEAR: number;
  30813. /** mag = linear and min = nearest and mip = none */
  30814. static readonly TEXTURE_LINEAR_NEAREST: number;
  30815. /** Explicit coordinates mode */
  30816. static readonly TEXTURE_EXPLICIT_MODE: number;
  30817. /** Spherical coordinates mode */
  30818. static readonly TEXTURE_SPHERICAL_MODE: number;
  30819. /** Planar coordinates mode */
  30820. static readonly TEXTURE_PLANAR_MODE: number;
  30821. /** Cubic coordinates mode */
  30822. static readonly TEXTURE_CUBIC_MODE: number;
  30823. /** Projection coordinates mode */
  30824. static readonly TEXTURE_PROJECTION_MODE: number;
  30825. /** Skybox coordinates mode */
  30826. static readonly TEXTURE_SKYBOX_MODE: number;
  30827. /** Inverse Cubic coordinates mode */
  30828. static readonly TEXTURE_INVCUBIC_MODE: number;
  30829. /** Equirectangular coordinates mode */
  30830. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30831. /** Equirectangular Fixed coordinates mode */
  30832. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30833. /** Equirectangular Fixed Mirrored coordinates mode */
  30834. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30835. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30836. static readonly SCALEMODE_FLOOR: number;
  30837. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30838. static readonly SCALEMODE_NEAREST: number;
  30839. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30840. static readonly SCALEMODE_CEILING: number;
  30841. /**
  30842. * Returns the current npm package of the sdk
  30843. */
  30844. static readonly NpmPackage: string;
  30845. /**
  30846. * Returns the current version of the framework
  30847. */
  30848. static readonly Version: string;
  30849. /**
  30850. * Returns a string describing the current engine
  30851. */
  30852. readonly description: string;
  30853. /**
  30854. * Gets or sets the epsilon value used by collision engine
  30855. */
  30856. static CollisionsEpsilon: number;
  30857. /**
  30858. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30859. */
  30860. static ShadersRepository: string;
  30861. /**
  30862. * Method called to create the default loading screen.
  30863. * This can be overriden in your own app.
  30864. * @param canvas The rendering canvas element
  30865. * @returns The loading screen
  30866. */
  30867. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30868. /**
  30869. * Method called to create the default rescale post process on each engine.
  30870. */
  30871. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30872. /** @hidden */
  30873. _shaderProcessor: IShaderProcessor;
  30874. /**
  30875. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30876. */
  30877. forcePOTTextures: boolean;
  30878. /**
  30879. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30880. */
  30881. isFullscreen: boolean;
  30882. /**
  30883. * Gets a boolean indicating if the pointer is currently locked
  30884. */
  30885. isPointerLock: boolean;
  30886. /**
  30887. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30888. */
  30889. cullBackFaces: boolean;
  30890. /**
  30891. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30892. */
  30893. renderEvenInBackground: boolean;
  30894. /**
  30895. * Gets or sets a boolean indicating that cache can be kept between frames
  30896. */
  30897. preventCacheWipeBetweenFrames: boolean;
  30898. /**
  30899. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30900. **/
  30901. enableOfflineSupport: boolean;
  30902. /**
  30903. * 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)
  30904. **/
  30905. disableManifestCheck: boolean;
  30906. /**
  30907. * Gets the list of created scenes
  30908. */
  30909. scenes: Scene[];
  30910. /**
  30911. * Event raised when a new scene is created
  30912. */
  30913. onNewSceneAddedObservable: Observable<Scene>;
  30914. /**
  30915. * Gets the list of created postprocesses
  30916. */
  30917. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30918. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30919. validateShaderPrograms: boolean;
  30920. /**
  30921. * Observable event triggered each time the rendering canvas is resized
  30922. */
  30923. onResizeObservable: Observable<Engine>;
  30924. /**
  30925. * Observable event triggered each time the canvas loses focus
  30926. */
  30927. onCanvasBlurObservable: Observable<Engine>;
  30928. /**
  30929. * Observable event triggered each time the canvas gains focus
  30930. */
  30931. onCanvasFocusObservable: Observable<Engine>;
  30932. /**
  30933. * Observable event triggered each time the canvas receives pointerout event
  30934. */
  30935. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30936. /**
  30937. * Observable event triggered before each texture is initialized
  30938. */
  30939. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30940. /**
  30941. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30942. */
  30943. disableUniformBuffers: boolean;
  30944. /** @hidden */
  30945. _uniformBuffers: UniformBuffer[];
  30946. /**
  30947. * Gets a boolean indicating that the engine supports uniform buffers
  30948. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30949. */
  30950. readonly supportsUniformBuffers: boolean;
  30951. /**
  30952. * Observable raised when the engine begins a new frame
  30953. */
  30954. onBeginFrameObservable: Observable<Engine>;
  30955. /**
  30956. * If set, will be used to request the next animation frame for the render loop
  30957. */
  30958. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30959. /**
  30960. * Observable raised when the engine ends the current frame
  30961. */
  30962. onEndFrameObservable: Observable<Engine>;
  30963. /**
  30964. * Observable raised when the engine is about to compile a shader
  30965. */
  30966. onBeforeShaderCompilationObservable: Observable<Engine>;
  30967. /**
  30968. * Observable raised when the engine has jsut compiled a shader
  30969. */
  30970. onAfterShaderCompilationObservable: Observable<Engine>;
  30971. /** @hidden */
  30972. _gl: WebGLRenderingContext;
  30973. private _renderingCanvas;
  30974. private _windowIsBackground;
  30975. private _webGLVersion;
  30976. protected _highPrecisionShadersAllowed: boolean;
  30977. /** @hidden */
  30978. readonly _shouldUseHighPrecisionShader: boolean;
  30979. /**
  30980. * Gets a boolean indicating that only power of 2 textures are supported
  30981. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30982. */
  30983. readonly needPOTTextures: boolean;
  30984. /** @hidden */
  30985. _badOS: boolean;
  30986. /** @hidden */
  30987. _badDesktopOS: boolean;
  30988. /**
  30989. * Gets the audio engine
  30990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30991. * @ignorenaming
  30992. */
  30993. static audioEngine: IAudioEngine;
  30994. /**
  30995. * Default AudioEngine factory responsible of creating the Audio Engine.
  30996. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30997. */
  30998. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30999. /**
  31000. * Default offline support factory responsible of creating a tool used to store data locally.
  31001. * By default, this will create a Database object if the workload has been embedded.
  31002. */
  31003. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31004. private _onFocus;
  31005. private _onBlur;
  31006. private _onCanvasPointerOut;
  31007. private _onCanvasBlur;
  31008. private _onCanvasFocus;
  31009. private _onFullscreenChange;
  31010. private _onPointerLockChange;
  31011. private _hardwareScalingLevel;
  31012. /** @hidden */
  31013. _caps: EngineCapabilities;
  31014. private _pointerLockRequested;
  31015. private _isStencilEnable;
  31016. private _colorWrite;
  31017. private _loadingScreen;
  31018. /** @hidden */
  31019. _drawCalls: PerfCounter;
  31020. private _glVersion;
  31021. private _glRenderer;
  31022. private _glVendor;
  31023. private _videoTextureSupported;
  31024. private _renderingQueueLaunched;
  31025. private _activeRenderLoops;
  31026. private _deterministicLockstep;
  31027. private _lockstepMaxSteps;
  31028. /**
  31029. * Observable signaled when a context lost event is raised
  31030. */
  31031. onContextLostObservable: Observable<Engine>;
  31032. /**
  31033. * Observable signaled when a context restored event is raised
  31034. */
  31035. onContextRestoredObservable: Observable<Engine>;
  31036. private _onContextLost;
  31037. private _onContextRestored;
  31038. private _contextWasLost;
  31039. /** @hidden */
  31040. _doNotHandleContextLost: boolean;
  31041. /**
  31042. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31043. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31044. */
  31045. doNotHandleContextLost: boolean;
  31046. private _performanceMonitor;
  31047. private _fps;
  31048. private _deltaTime;
  31049. /**
  31050. * Turn this value on if you want to pause FPS computation when in background
  31051. */
  31052. disablePerformanceMonitorInBackground: boolean;
  31053. /**
  31054. * Gets the performance monitor attached to this engine
  31055. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31056. */
  31057. readonly performanceMonitor: PerformanceMonitor;
  31058. /**
  31059. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31060. */
  31061. disableVertexArrayObjects: boolean;
  31062. /** @hidden */
  31063. protected _depthCullingState: _DepthCullingState;
  31064. /** @hidden */
  31065. protected _stencilState: _StencilState;
  31066. /** @hidden */
  31067. protected _alphaState: _AlphaState;
  31068. /** @hidden */
  31069. protected _alphaMode: number;
  31070. /** @hidden */
  31071. _internalTexturesCache: InternalTexture[];
  31072. /** @hidden */
  31073. protected _activeChannel: number;
  31074. private _currentTextureChannel;
  31075. /** @hidden */
  31076. protected _boundTexturesCache: {
  31077. [key: string]: Nullable<InternalTexture>;
  31078. };
  31079. /** @hidden */
  31080. protected _currentEffect: Nullable<Effect>;
  31081. /** @hidden */
  31082. protected _currentProgram: Nullable<WebGLProgram>;
  31083. private _compiledEffects;
  31084. private _vertexAttribArraysEnabled;
  31085. /** @hidden */
  31086. protected _cachedViewport: Nullable<IViewportLike>;
  31087. private _cachedVertexArrayObject;
  31088. /** @hidden */
  31089. protected _cachedVertexBuffers: any;
  31090. /** @hidden */
  31091. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31092. /** @hidden */
  31093. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31094. /** @hidden */
  31095. _currentRenderTarget: Nullable<InternalTexture>;
  31096. private _uintIndicesCurrentlySet;
  31097. private _currentBoundBuffer;
  31098. /** @hidden */
  31099. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31100. private _currentBufferPointers;
  31101. private _currentInstanceLocations;
  31102. private _currentInstanceBuffers;
  31103. private _textureUnits;
  31104. /** @hidden */
  31105. _workingCanvas: Nullable<HTMLCanvasElement>;
  31106. /** @hidden */
  31107. _workingContext: Nullable<CanvasRenderingContext2D>;
  31108. private _rescalePostProcess;
  31109. private _dummyFramebuffer;
  31110. private _externalData;
  31111. /** @hidden */
  31112. _bindedRenderFunction: any;
  31113. private _vaoRecordInProgress;
  31114. private _mustWipeVertexAttributes;
  31115. private _emptyTexture;
  31116. private _emptyCubeTexture;
  31117. private _emptyTexture3D;
  31118. /** @hidden */
  31119. _frameHandler: number;
  31120. private _nextFreeTextureSlots;
  31121. private _maxSimultaneousTextures;
  31122. private _activeRequests;
  31123. private _texturesSupported;
  31124. /** @hidden */
  31125. _textureFormatInUse: Nullable<string>;
  31126. /**
  31127. * Gets the list of texture formats supported
  31128. */
  31129. readonly texturesSupported: Array<string>;
  31130. /**
  31131. * Gets the list of texture formats in use
  31132. */
  31133. readonly textureFormatInUse: Nullable<string>;
  31134. /**
  31135. * Gets the current viewport
  31136. */
  31137. readonly currentViewport: Nullable<IViewportLike>;
  31138. /**
  31139. * Gets the default empty texture
  31140. */
  31141. readonly emptyTexture: InternalTexture;
  31142. /**
  31143. * Gets the default empty 3D texture
  31144. */
  31145. readonly emptyTexture3D: InternalTexture;
  31146. /**
  31147. * Gets the default empty cube texture
  31148. */
  31149. readonly emptyCubeTexture: InternalTexture;
  31150. /**
  31151. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31152. */
  31153. readonly premultipliedAlpha: boolean;
  31154. /**
  31155. * Creates a new engine
  31156. * @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
  31157. * @param antialias defines enable antialiasing (default: false)
  31158. * @param options defines further options to be sent to the getContext() function
  31159. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31160. */
  31161. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31162. /**
  31163. * Initializes a webVR display and starts listening to display change events
  31164. * The onVRDisplayChangedObservable will be notified upon these changes
  31165. * @returns The onVRDisplayChangedObservable
  31166. */
  31167. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31168. /** @hidden */
  31169. _prepareVRComponent(): void;
  31170. /** @hidden */
  31171. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31172. /** @hidden */
  31173. _submitVRFrame(): void;
  31174. /**
  31175. * Call this function to leave webVR mode
  31176. * Will do nothing if webVR is not supported or if there is no webVR device
  31177. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31178. */
  31179. disableVR(): void;
  31180. /**
  31181. * Gets a boolean indicating that the system is in VR mode and is presenting
  31182. * @returns true if VR mode is engaged
  31183. */
  31184. isVRPresenting(): boolean;
  31185. /** @hidden */
  31186. _requestVRFrame(): void;
  31187. private _disableTouchAction;
  31188. private _rebuildInternalTextures;
  31189. private _rebuildEffects;
  31190. /**
  31191. * Gets a boolean indicating if all created effects are ready
  31192. * @returns true if all effects are ready
  31193. */
  31194. areAllEffectsReady(): boolean;
  31195. private _rebuildBuffers;
  31196. private _initGLContext;
  31197. /**
  31198. * Gets version of the current webGL context
  31199. */
  31200. readonly webGLVersion: number;
  31201. /**
  31202. * Gets a string idenfifying the name of the class
  31203. * @returns "Engine" string
  31204. */
  31205. getClassName(): string;
  31206. /**
  31207. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31208. */
  31209. readonly isStencilEnable: boolean;
  31210. /** @hidden */
  31211. _prepareWorkingCanvas(): void;
  31212. /**
  31213. * Reset the texture cache to empty state
  31214. */
  31215. resetTextureCache(): void;
  31216. /**
  31217. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31218. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31219. * @returns true if engine is in deterministic lock step mode
  31220. */
  31221. isDeterministicLockStep(): boolean;
  31222. /**
  31223. * Gets the max steps when engine is running in deterministic lock step
  31224. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31225. * @returns the max steps
  31226. */
  31227. getLockstepMaxSteps(): number;
  31228. /**
  31229. * Gets an object containing information about the current webGL context
  31230. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31231. */
  31232. getGlInfo(): {
  31233. vendor: string;
  31234. renderer: string;
  31235. version: string;
  31236. };
  31237. /**
  31238. * Gets current aspect ratio
  31239. * @param viewportOwner defines the camera to use to get the aspect ratio
  31240. * @param useScreen defines if screen size must be used (or the current render target if any)
  31241. * @returns a number defining the aspect ratio
  31242. */
  31243. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31244. /**
  31245. * Gets current screen aspect ratio
  31246. * @returns a number defining the aspect ratio
  31247. */
  31248. getScreenAspectRatio(): number;
  31249. /**
  31250. * Gets the current render width
  31251. * @param useScreen defines if screen size must be used (or the current render target if any)
  31252. * @returns a number defining the current render width
  31253. */
  31254. getRenderWidth(useScreen?: boolean): number;
  31255. /**
  31256. * Gets the current render height
  31257. * @param useScreen defines if screen size must be used (or the current render target if any)
  31258. * @returns a number defining the current render height
  31259. */
  31260. getRenderHeight(useScreen?: boolean): number;
  31261. /**
  31262. * Gets the HTML canvas attached with the current webGL context
  31263. * @returns a HTML canvas
  31264. */
  31265. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31266. /**
  31267. * Gets host window
  31268. * @returns the host window object
  31269. */
  31270. getHostWindow(): Window;
  31271. /**
  31272. * Gets host document
  31273. * @returns the host document object
  31274. */
  31275. getHostDocument(): Document;
  31276. /**
  31277. * Gets the client rect of the HTML canvas attached with the current webGL context
  31278. * @returns a client rectanglee
  31279. */
  31280. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31281. /**
  31282. * Defines the hardware scaling level.
  31283. * By default the hardware scaling level is computed from the window device ratio.
  31284. * 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.
  31285. * @param level defines the level to use
  31286. */
  31287. setHardwareScalingLevel(level: number): void;
  31288. /**
  31289. * Gets the current hardware scaling level.
  31290. * By default the hardware scaling level is computed from the window device ratio.
  31291. * 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.
  31292. * @returns a number indicating the current hardware scaling level
  31293. */
  31294. getHardwareScalingLevel(): number;
  31295. /**
  31296. * Gets the list of loaded textures
  31297. * @returns an array containing all loaded textures
  31298. */
  31299. getLoadedTexturesCache(): InternalTexture[];
  31300. /**
  31301. * Gets the object containing all engine capabilities
  31302. * @returns the EngineCapabilities object
  31303. */
  31304. getCaps(): EngineCapabilities;
  31305. /**
  31306. * Gets the current depth function
  31307. * @returns a number defining the depth function
  31308. */
  31309. getDepthFunction(): Nullable<number>;
  31310. /**
  31311. * Sets the current depth function
  31312. * @param depthFunc defines the function to use
  31313. */
  31314. setDepthFunction(depthFunc: number): void;
  31315. /**
  31316. * Sets the current depth function to GREATER
  31317. */
  31318. setDepthFunctionToGreater(): void;
  31319. /**
  31320. * Sets the current depth function to GEQUAL
  31321. */
  31322. setDepthFunctionToGreaterOrEqual(): void;
  31323. /**
  31324. * Sets the current depth function to LESS
  31325. */
  31326. setDepthFunctionToLess(): void;
  31327. private _cachedStencilBuffer;
  31328. private _cachedStencilFunction;
  31329. private _cachedStencilMask;
  31330. private _cachedStencilOperationPass;
  31331. private _cachedStencilOperationFail;
  31332. private _cachedStencilOperationDepthFail;
  31333. private _cachedStencilReference;
  31334. /**
  31335. * Caches the the state of the stencil buffer
  31336. */
  31337. cacheStencilState(): void;
  31338. /**
  31339. * Restores the state of the stencil buffer
  31340. */
  31341. restoreStencilState(): void;
  31342. /**
  31343. * Sets the current depth function to LEQUAL
  31344. */
  31345. setDepthFunctionToLessOrEqual(): void;
  31346. /**
  31347. * Gets a boolean indicating if stencil buffer is enabled
  31348. * @returns the current stencil buffer state
  31349. */
  31350. getStencilBuffer(): boolean;
  31351. /**
  31352. * Enable or disable the stencil buffer
  31353. * @param enable defines if the stencil buffer must be enabled or disabled
  31354. */
  31355. setStencilBuffer(enable: boolean): void;
  31356. /**
  31357. * Gets the current stencil mask
  31358. * @returns a number defining the new stencil mask to use
  31359. */
  31360. getStencilMask(): number;
  31361. /**
  31362. * Sets the current stencil mask
  31363. * @param mask defines the new stencil mask to use
  31364. */
  31365. setStencilMask(mask: number): void;
  31366. /**
  31367. * Gets the current stencil function
  31368. * @returns a number defining the stencil function to use
  31369. */
  31370. getStencilFunction(): number;
  31371. /**
  31372. * Gets the current stencil reference value
  31373. * @returns a number defining the stencil reference value to use
  31374. */
  31375. getStencilFunctionReference(): number;
  31376. /**
  31377. * Gets the current stencil mask
  31378. * @returns a number defining the stencil mask to use
  31379. */
  31380. getStencilFunctionMask(): number;
  31381. /**
  31382. * Sets the current stencil function
  31383. * @param stencilFunc defines the new stencil function to use
  31384. */
  31385. setStencilFunction(stencilFunc: number): void;
  31386. /**
  31387. * Sets the current stencil reference
  31388. * @param reference defines the new stencil reference to use
  31389. */
  31390. setStencilFunctionReference(reference: number): void;
  31391. /**
  31392. * Sets the current stencil mask
  31393. * @param mask defines the new stencil mask to use
  31394. */
  31395. setStencilFunctionMask(mask: number): void;
  31396. /**
  31397. * Gets the current stencil operation when stencil fails
  31398. * @returns a number defining stencil operation to use when stencil fails
  31399. */
  31400. getStencilOperationFail(): number;
  31401. /**
  31402. * Gets the current stencil operation when depth fails
  31403. * @returns a number defining stencil operation to use when depth fails
  31404. */
  31405. getStencilOperationDepthFail(): number;
  31406. /**
  31407. * Gets the current stencil operation when stencil passes
  31408. * @returns a number defining stencil operation to use when stencil passes
  31409. */
  31410. getStencilOperationPass(): number;
  31411. /**
  31412. * Sets the stencil operation to use when stencil fails
  31413. * @param operation defines the stencil operation to use when stencil fails
  31414. */
  31415. setStencilOperationFail(operation: number): void;
  31416. /**
  31417. * Sets the stencil operation to use when depth fails
  31418. * @param operation defines the stencil operation to use when depth fails
  31419. */
  31420. setStencilOperationDepthFail(operation: number): void;
  31421. /**
  31422. * Sets the stencil operation to use when stencil passes
  31423. * @param operation defines the stencil operation to use when stencil passes
  31424. */
  31425. setStencilOperationPass(operation: number): void;
  31426. /**
  31427. * Sets a boolean indicating if the dithering state is enabled or disabled
  31428. * @param value defines the dithering state
  31429. */
  31430. setDitheringState(value: boolean): void;
  31431. /**
  31432. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31433. * @param value defines the rasterizer state
  31434. */
  31435. setRasterizerState(value: boolean): void;
  31436. /**
  31437. * stop executing a render loop function and remove it from the execution array
  31438. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31439. */
  31440. stopRenderLoop(renderFunction?: () => void): void;
  31441. /** @hidden */
  31442. _renderLoop(): void;
  31443. /**
  31444. * Register and execute a render loop. The engine can have more than one render function
  31445. * @param renderFunction defines the function to continuously execute
  31446. */
  31447. runRenderLoop(renderFunction: () => void): void;
  31448. /**
  31449. * Toggle full screen mode
  31450. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31451. */
  31452. switchFullscreen(requestPointerLock: boolean): void;
  31453. /**
  31454. * Enters full screen mode
  31455. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31456. */
  31457. enterFullscreen(requestPointerLock: boolean): void;
  31458. /**
  31459. * Exits full screen mode
  31460. */
  31461. exitFullscreen(): void;
  31462. /**
  31463. * Enters Pointerlock mode
  31464. */
  31465. enterPointerlock(): void;
  31466. /**
  31467. * Exits Pointerlock mode
  31468. */
  31469. exitPointerlock(): void;
  31470. /**
  31471. * Clear the current render buffer or the current render target (if any is set up)
  31472. * @param color defines the color to use
  31473. * @param backBuffer defines if the back buffer must be cleared
  31474. * @param depth defines if the depth buffer must be cleared
  31475. * @param stencil defines if the stencil buffer must be cleared
  31476. */
  31477. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31478. /**
  31479. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31480. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31481. * @param y defines the y-coordinate of the corner of the clear rectangle
  31482. * @param width defines the width of the clear rectangle
  31483. * @param height defines the height of the clear rectangle
  31484. * @param clearColor defines the clear color
  31485. */
  31486. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31487. /**
  31488. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31489. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31490. * @param y defines the y-coordinate of the corner of the clear rectangle
  31491. * @param width defines the width of the clear rectangle
  31492. * @param height defines the height of the clear rectangle
  31493. */
  31494. enableScissor(x: number, y: number, width: number, height: number): void;
  31495. /**
  31496. * Disable previously set scissor test rectangle
  31497. */
  31498. disableScissor(): void;
  31499. private _viewportCached;
  31500. /** @hidden */
  31501. _viewport(x: number, y: number, width: number, height: number): void;
  31502. /**
  31503. * Set the WebGL's viewport
  31504. * @param viewport defines the viewport element to be used
  31505. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31506. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31507. */
  31508. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31509. /**
  31510. * Directly set the WebGL Viewport
  31511. * @param x defines the x coordinate of the viewport (in screen space)
  31512. * @param y defines the y coordinate of the viewport (in screen space)
  31513. * @param width defines the width of the viewport (in screen space)
  31514. * @param height defines the height of the viewport (in screen space)
  31515. * @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
  31516. */
  31517. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31518. /**
  31519. * Begin a new frame
  31520. */
  31521. beginFrame(): void;
  31522. /**
  31523. * Enf the current frame
  31524. */
  31525. endFrame(): void;
  31526. /**
  31527. * Resize the view according to the canvas' size
  31528. */
  31529. resize(): void;
  31530. /**
  31531. * Force a specific size of the canvas
  31532. * @param width defines the new canvas' width
  31533. * @param height defines the new canvas' height
  31534. */
  31535. setSize(width: number, height: number): void;
  31536. /**
  31537. * Binds the frame buffer to the specified texture.
  31538. * @param texture The texture to render to or null for the default canvas
  31539. * @param faceIndex The face of the texture to render to in case of cube texture
  31540. * @param requiredWidth The width of the target to render to
  31541. * @param requiredHeight The height of the target to render to
  31542. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31543. * @param depthStencilTexture The depth stencil texture to use to render
  31544. * @param lodLevel defines le lod level to bind to the frame buffer
  31545. */
  31546. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31547. /** @hidden */
  31548. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31549. /**
  31550. * Unbind the current render target texture from the webGL context
  31551. * @param texture defines the render target texture to unbind
  31552. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31553. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31554. */
  31555. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31556. /**
  31557. * Force the mipmap generation for the given render target texture
  31558. * @param texture defines the render target texture to use
  31559. */
  31560. generateMipMapsForCubemap(texture: InternalTexture): void;
  31561. /**
  31562. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31563. */
  31564. flushFramebuffer(): void;
  31565. /**
  31566. * Unbind the current render target and bind the default framebuffer
  31567. */
  31568. restoreDefaultFramebuffer(): void;
  31569. /**
  31570. * Create an uniform buffer
  31571. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31572. * @param elements defines the content of the uniform buffer
  31573. * @returns the webGL uniform buffer
  31574. */
  31575. createUniformBuffer(elements: FloatArray): DataBuffer;
  31576. /**
  31577. * Create a dynamic uniform buffer
  31578. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31579. * @param elements defines the content of the uniform buffer
  31580. * @returns the webGL uniform buffer
  31581. */
  31582. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31583. /**
  31584. * Update an existing uniform buffer
  31585. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31586. * @param uniformBuffer defines the target uniform buffer
  31587. * @param elements defines the content to update
  31588. * @param offset defines the offset in the uniform buffer where update should start
  31589. * @param count defines the size of the data to update
  31590. */
  31591. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31592. private _resetVertexBufferBinding;
  31593. /**
  31594. * Creates a vertex buffer
  31595. * @param data the data for the vertex buffer
  31596. * @returns the new WebGL static buffer
  31597. */
  31598. createVertexBuffer(data: DataArray): DataBuffer;
  31599. /**
  31600. * Creates a dynamic vertex buffer
  31601. * @param data the data for the dynamic vertex buffer
  31602. * @returns the new WebGL dynamic buffer
  31603. */
  31604. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31605. /**
  31606. * Update a dynamic index buffer
  31607. * @param indexBuffer defines the target index buffer
  31608. * @param indices defines the data to update
  31609. * @param offset defines the offset in the target index buffer where update should start
  31610. */
  31611. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31612. /**
  31613. * Updates a dynamic vertex buffer.
  31614. * @param vertexBuffer the vertex buffer to update
  31615. * @param data the data used to update the vertex buffer
  31616. * @param byteOffset the byte offset of the data
  31617. * @param byteLength the byte length of the data
  31618. */
  31619. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31620. private _resetIndexBufferBinding;
  31621. /**
  31622. * Creates a new index buffer
  31623. * @param indices defines the content of the index buffer
  31624. * @param updatable defines if the index buffer must be updatable
  31625. * @returns a new webGL buffer
  31626. */
  31627. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31628. /**
  31629. * Bind a webGL buffer to the webGL context
  31630. * @param buffer defines the buffer to bind
  31631. */
  31632. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31633. /**
  31634. * Bind an uniform buffer to the current webGL context
  31635. * @param buffer defines the buffer to bind
  31636. */
  31637. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31638. /**
  31639. * Bind a buffer to the current webGL context at a given location
  31640. * @param buffer defines the buffer to bind
  31641. * @param location defines the index where to bind the buffer
  31642. */
  31643. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31644. /**
  31645. * Bind a specific block at a given index in a specific shader program
  31646. * @param pipelineContext defines the pipeline context to use
  31647. * @param blockName defines the block name
  31648. * @param index defines the index where to bind the block
  31649. */
  31650. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31651. private bindIndexBuffer;
  31652. private bindBuffer;
  31653. /**
  31654. * update the bound buffer with the given data
  31655. * @param data defines the data to update
  31656. */
  31657. updateArrayBuffer(data: Float32Array): void;
  31658. private _vertexAttribPointer;
  31659. private _bindIndexBufferWithCache;
  31660. private _bindVertexBuffersAttributes;
  31661. /**
  31662. * Records a vertex array object
  31663. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31664. * @param vertexBuffers defines the list of vertex buffers to store
  31665. * @param indexBuffer defines the index buffer to store
  31666. * @param effect defines the effect to store
  31667. * @returns the new vertex array object
  31668. */
  31669. recordVertexArrayObject(vertexBuffers: {
  31670. [key: string]: VertexBuffer;
  31671. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31672. /**
  31673. * Bind a specific vertex array object
  31674. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31675. * @param vertexArrayObject defines the vertex array object to bind
  31676. * @param indexBuffer defines the index buffer to bind
  31677. */
  31678. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31679. /**
  31680. * Bind webGl buffers directly to the webGL context
  31681. * @param vertexBuffer defines the vertex buffer to bind
  31682. * @param indexBuffer defines the index buffer to bind
  31683. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31684. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31685. * @param effect defines the effect associated with the vertex buffer
  31686. */
  31687. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31688. private _unbindVertexArrayObject;
  31689. /**
  31690. * Bind a list of vertex buffers to the webGL context
  31691. * @param vertexBuffers defines the list of vertex buffers to bind
  31692. * @param indexBuffer defines the index buffer to bind
  31693. * @param effect defines the effect associated with the vertex buffers
  31694. */
  31695. bindBuffers(vertexBuffers: {
  31696. [key: string]: Nullable<VertexBuffer>;
  31697. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31698. /**
  31699. * Unbind all instance attributes
  31700. */
  31701. unbindInstanceAttributes(): void;
  31702. /**
  31703. * Release and free the memory of a vertex array object
  31704. * @param vao defines the vertex array object to delete
  31705. */
  31706. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31707. /** @hidden */
  31708. _releaseBuffer(buffer: DataBuffer): boolean;
  31709. /**
  31710. * Creates a webGL buffer to use with instanciation
  31711. * @param capacity defines the size of the buffer
  31712. * @returns the webGL buffer
  31713. */
  31714. createInstancesBuffer(capacity: number): DataBuffer;
  31715. /**
  31716. * Delete a webGL buffer used with instanciation
  31717. * @param buffer defines the webGL buffer to delete
  31718. */
  31719. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31720. /**
  31721. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31722. * @param instancesBuffer defines the webGL buffer to update and bind
  31723. * @param data defines the data to store in the buffer
  31724. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31725. */
  31726. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31727. /**
  31728. * Apply all cached states (depth, culling, stencil and alpha)
  31729. */
  31730. applyStates(): void;
  31731. /**
  31732. * Send a draw order
  31733. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31734. * @param indexStart defines the starting index
  31735. * @param indexCount defines the number of index to draw
  31736. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31737. */
  31738. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31739. /**
  31740. * Draw a list of points
  31741. * @param verticesStart defines the index of first vertex to draw
  31742. * @param verticesCount defines the count of vertices to draw
  31743. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31744. */
  31745. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31746. /**
  31747. * Draw a list of unindexed primitives
  31748. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31749. * @param verticesStart defines the index of first vertex to draw
  31750. * @param verticesCount defines the count of vertices to draw
  31751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31752. */
  31753. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31754. /**
  31755. * Draw a list of indexed primitives
  31756. * @param fillMode defines the primitive to use
  31757. * @param indexStart defines the starting index
  31758. * @param indexCount defines the number of index to draw
  31759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31760. */
  31761. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31762. /**
  31763. * Draw a list of unindexed primitives
  31764. * @param fillMode defines the primitive to use
  31765. * @param verticesStart defines the index of first vertex to draw
  31766. * @param verticesCount defines the count of vertices to draw
  31767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31768. */
  31769. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31770. private _drawMode;
  31771. /** @hidden */
  31772. _releaseEffect(effect: Effect): void;
  31773. /** @hidden */
  31774. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31775. /**
  31776. * Create a new effect (used to store vertex/fragment shaders)
  31777. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31778. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31779. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31780. * @param samplers defines an array of string used to represent textures
  31781. * @param defines defines the string containing the defines to use to compile the shaders
  31782. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31783. * @param onCompiled defines a function to call when the effect creation is successful
  31784. * @param onError defines a function to call when the effect creation has failed
  31785. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31786. * @returns the new Effect
  31787. */
  31788. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31789. private _compileShader;
  31790. private _compileRawShader;
  31791. /**
  31792. * Directly creates a webGL program
  31793. * @param pipelineContext defines the pipeline context to attach to
  31794. * @param vertexCode defines the vertex shader code to use
  31795. * @param fragmentCode defines the fragment shader code to use
  31796. * @param context defines the webGL context to use (if not set, the current one will be used)
  31797. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31798. * @returns the new webGL program
  31799. */
  31800. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31801. /**
  31802. * Creates a webGL program
  31803. * @param pipelineContext defines the pipeline context to attach to
  31804. * @param vertexCode defines the vertex shader code to use
  31805. * @param fragmentCode defines the fragment shader code to use
  31806. * @param defines defines the string containing the defines to use to compile the shaders
  31807. * @param context defines the webGL context to use (if not set, the current one will be used)
  31808. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31809. * @returns the new webGL program
  31810. */
  31811. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31812. /**
  31813. * Creates a new pipeline context
  31814. * @returns the new pipeline
  31815. */
  31816. createPipelineContext(): WebGLPipelineContext;
  31817. private _createShaderProgram;
  31818. private _finalizePipelineContext;
  31819. /** @hidden */
  31820. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31821. /** @hidden */
  31822. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31823. /** @hidden */
  31824. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31825. /**
  31826. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31827. * @param pipelineContext defines the pipeline context to use
  31828. * @param uniformsNames defines the list of uniform names
  31829. * @returns an array of webGL uniform locations
  31830. */
  31831. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31832. /**
  31833. * Gets the lsit of active attributes for a given webGL program
  31834. * @param pipelineContext defines the pipeline context to use
  31835. * @param attributesNames defines the list of attribute names to get
  31836. * @returns an array of indices indicating the offset of each attribute
  31837. */
  31838. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31839. /**
  31840. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31841. * @param effect defines the effect to activate
  31842. */
  31843. enableEffect(effect: Nullable<Effect>): void;
  31844. /**
  31845. * Set the value of an uniform to an array of int32
  31846. * @param uniform defines the webGL uniform location where to store the value
  31847. * @param array defines the array of int32 to store
  31848. */
  31849. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31850. /**
  31851. * Set the value of an uniform to an array of int32 (stored as vec2)
  31852. * @param uniform defines the webGL uniform location where to store the value
  31853. * @param array defines the array of int32 to store
  31854. */
  31855. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31856. /**
  31857. * Set the value of an uniform to an array of int32 (stored as vec3)
  31858. * @param uniform defines the webGL uniform location where to store the value
  31859. * @param array defines the array of int32 to store
  31860. */
  31861. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31862. /**
  31863. * Set the value of an uniform to an array of int32 (stored as vec4)
  31864. * @param uniform defines the webGL uniform location where to store the value
  31865. * @param array defines the array of int32 to store
  31866. */
  31867. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31868. /**
  31869. * Set the value of an uniform to an array of float32
  31870. * @param uniform defines the webGL uniform location where to store the value
  31871. * @param array defines the array of float32 to store
  31872. */
  31873. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31874. /**
  31875. * Set the value of an uniform to an array of float32 (stored as vec2)
  31876. * @param uniform defines the webGL uniform location where to store the value
  31877. * @param array defines the array of float32 to store
  31878. */
  31879. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31880. /**
  31881. * Set the value of an uniform to an array of float32 (stored as vec3)
  31882. * @param uniform defines the webGL uniform location where to store the value
  31883. * @param array defines the array of float32 to store
  31884. */
  31885. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31886. /**
  31887. * Set the value of an uniform to an array of float32 (stored as vec4)
  31888. * @param uniform defines the webGL uniform location where to store the value
  31889. * @param array defines the array of float32 to store
  31890. */
  31891. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31892. /**
  31893. * Set the value of an uniform to an array of number
  31894. * @param uniform defines the webGL uniform location where to store the value
  31895. * @param array defines the array of number to store
  31896. */
  31897. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31898. /**
  31899. * Set the value of an uniform to an array of number (stored as vec2)
  31900. * @param uniform defines the webGL uniform location where to store the value
  31901. * @param array defines the array of number to store
  31902. */
  31903. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31904. /**
  31905. * Set the value of an uniform to an array of number (stored as vec3)
  31906. * @param uniform defines the webGL uniform location where to store the value
  31907. * @param array defines the array of number to store
  31908. */
  31909. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31910. /**
  31911. * Set the value of an uniform to an array of number (stored as vec4)
  31912. * @param uniform defines the webGL uniform location where to store the value
  31913. * @param array defines the array of number to store
  31914. */
  31915. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31916. /**
  31917. * Set the value of an uniform to an array of float32 (stored as matrices)
  31918. * @param uniform defines the webGL uniform location where to store the value
  31919. * @param matrices defines the array of float32 to store
  31920. */
  31921. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31922. /**
  31923. * Set the value of an uniform to a matrix (3x3)
  31924. * @param uniform defines the webGL uniform location where to store the value
  31925. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31926. */
  31927. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31928. /**
  31929. * Set the value of an uniform to a matrix (2x2)
  31930. * @param uniform defines the webGL uniform location where to store the value
  31931. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31932. */
  31933. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31934. /**
  31935. * Set the value of an uniform to a number (int)
  31936. * @param uniform defines the webGL uniform location where to store the value
  31937. * @param value defines the int number to store
  31938. */
  31939. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31940. /**
  31941. * Set the value of an uniform to a number (float)
  31942. * @param uniform defines the webGL uniform location where to store the value
  31943. * @param value defines the float number to store
  31944. */
  31945. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31946. /**
  31947. * Set the value of an uniform to a vec2
  31948. * @param uniform defines the webGL uniform location where to store the value
  31949. * @param x defines the 1st component of the value
  31950. * @param y defines the 2nd component of the value
  31951. */
  31952. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31953. /**
  31954. * Set the value of an uniform to a vec3
  31955. * @param uniform defines the webGL uniform location where to store the value
  31956. * @param x defines the 1st component of the value
  31957. * @param y defines the 2nd component of the value
  31958. * @param z defines the 3rd component of the value
  31959. */
  31960. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31961. /**
  31962. * Set the value of an uniform to a boolean
  31963. * @param uniform defines the webGL uniform location where to store the value
  31964. * @param bool defines the boolean to store
  31965. */
  31966. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31967. /**
  31968. * Set the value of an uniform to a vec4
  31969. * @param uniform defines the webGL uniform location where to store the value
  31970. * @param x defines the 1st component of the value
  31971. * @param y defines the 2nd component of the value
  31972. * @param z defines the 3rd component of the value
  31973. * @param w defines the 4th component of the value
  31974. */
  31975. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31976. /**
  31977. * Sets a Color4 on a uniform variable
  31978. * @param uniform defines the uniform location
  31979. * @param color4 defines the value to be set
  31980. */
  31981. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31982. /**
  31983. * Set various states to the webGL context
  31984. * @param culling defines backface culling state
  31985. * @param zOffset defines the value to apply to zOffset (0 by default)
  31986. * @param force defines if states must be applied even if cache is up to date
  31987. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31988. */
  31989. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31990. /**
  31991. * Set the z offset to apply to current rendering
  31992. * @param value defines the offset to apply
  31993. */
  31994. setZOffset(value: number): void;
  31995. /**
  31996. * Gets the current value of the zOffset
  31997. * @returns the current zOffset state
  31998. */
  31999. getZOffset(): number;
  32000. /**
  32001. * Enable or disable depth buffering
  32002. * @param enable defines the state to set
  32003. */
  32004. setDepthBuffer(enable: boolean): void;
  32005. /**
  32006. * Gets a boolean indicating if depth writing is enabled
  32007. * @returns the current depth writing state
  32008. */
  32009. getDepthWrite(): boolean;
  32010. /**
  32011. * Enable or disable depth writing
  32012. * @param enable defines the state to set
  32013. */
  32014. setDepthWrite(enable: boolean): void;
  32015. /**
  32016. * Enable or disable color writing
  32017. * @param enable defines the state to set
  32018. */
  32019. setColorWrite(enable: boolean): void;
  32020. /**
  32021. * Gets a boolean indicating if color writing is enabled
  32022. * @returns the current color writing state
  32023. */
  32024. getColorWrite(): boolean;
  32025. /**
  32026. * Sets alpha constants used by some alpha blending modes
  32027. * @param r defines the red component
  32028. * @param g defines the green component
  32029. * @param b defines the blue component
  32030. * @param a defines the alpha component
  32031. */
  32032. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32033. /**
  32034. * Sets the current alpha mode
  32035. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32036. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32037. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32038. */
  32039. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32040. /**
  32041. * Gets the current alpha mode
  32042. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32043. * @returns the current alpha mode
  32044. */
  32045. getAlphaMode(): number;
  32046. /**
  32047. * Clears the list of texture accessible through engine.
  32048. * This can help preventing texture load conflict due to name collision.
  32049. */
  32050. clearInternalTexturesCache(): void;
  32051. /**
  32052. * Force the entire cache to be cleared
  32053. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32054. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32055. */
  32056. wipeCaches(bruteForce?: boolean): void;
  32057. /**
  32058. * Set the compressed texture format to use, based on the formats you have, and the formats
  32059. * supported by the hardware / browser.
  32060. *
  32061. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32062. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32063. * to API arguments needed to compressed textures. This puts the burden on the container
  32064. * generator to house the arcane code for determining these for current & future formats.
  32065. *
  32066. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32067. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32068. *
  32069. * Note: The result of this call is not taken into account when a texture is base64.
  32070. *
  32071. * @param formatsAvailable defines the list of those format families you have created
  32072. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32073. *
  32074. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32075. * @returns The extension selected.
  32076. */
  32077. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32078. /** @hidden */
  32079. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32080. min: number;
  32081. mag: number;
  32082. };
  32083. /** @hidden */
  32084. _createTexture(): WebGLTexture;
  32085. /**
  32086. * Usually called from Texture.ts.
  32087. * Passed information to create a WebGLTexture
  32088. * @param urlArg defines a value which contains one of the following:
  32089. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32090. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32091. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32092. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32093. * @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)
  32094. * @param scene needed for loading to the correct scene
  32095. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32096. * @param onLoad optional callback to be called upon successful completion
  32097. * @param onError optional callback to be called upon failure
  32098. * @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
  32099. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32100. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32101. * @param forcedExtension defines the extension to use to pick the right loader
  32102. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32103. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32104. */
  32105. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32106. /**
  32107. * @hidden
  32108. * Rescales a texture
  32109. * @param source input texutre
  32110. * @param destination destination texture
  32111. * @param scene scene to use to render the resize
  32112. * @param internalFormat format to use when resizing
  32113. * @param onComplete callback to be called when resize has completed
  32114. */
  32115. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32116. private _unpackFlipYCached;
  32117. /**
  32118. * In case you are sharing the context with other applications, it might
  32119. * be interested to not cache the unpack flip y state to ensure a consistent
  32120. * value would be set.
  32121. */
  32122. enableUnpackFlipYCached: boolean;
  32123. /** @hidden */
  32124. _unpackFlipY(value: boolean): void;
  32125. /** @hidden */
  32126. _getUnpackAlignement(): number;
  32127. /**
  32128. * Creates a dynamic texture
  32129. * @param width defines the width of the texture
  32130. * @param height defines the height of the texture
  32131. * @param generateMipMaps defines if the engine should generate the mip levels
  32132. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32133. * @returns the dynamic texture inside an InternalTexture
  32134. */
  32135. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32136. /**
  32137. * Update the sampling mode of a given texture
  32138. * @param samplingMode defines the required sampling mode
  32139. * @param texture defines the texture to update
  32140. */
  32141. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32142. /**
  32143. * Update the content of a dynamic texture
  32144. * @param texture defines the texture to update
  32145. * @param canvas defines the canvas containing the source
  32146. * @param invertY defines if data must be stored with Y axis inverted
  32147. * @param premulAlpha defines if alpha is stored as premultiplied
  32148. * @param format defines the format of the data
  32149. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32150. */
  32151. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32152. /**
  32153. * Update a video texture
  32154. * @param texture defines the texture to update
  32155. * @param video defines the video element to use
  32156. * @param invertY defines if data must be stored with Y axis inverted
  32157. */
  32158. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32159. /**
  32160. * Updates a depth texture Comparison Mode and Function.
  32161. * If the comparison Function is equal to 0, the mode will be set to none.
  32162. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32163. * @param texture The texture to set the comparison function for
  32164. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32165. */
  32166. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32167. /** @hidden */
  32168. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32169. width: number;
  32170. height: number;
  32171. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32172. /**
  32173. * Creates a depth stencil texture.
  32174. * This is only available in WebGL 2 or with the depth texture extension available.
  32175. * @param size The size of face edge in the texture.
  32176. * @param options The options defining the texture.
  32177. * @returns The texture
  32178. */
  32179. createDepthStencilTexture(size: number | {
  32180. width: number;
  32181. height: number;
  32182. }, options: DepthTextureCreationOptions): InternalTexture;
  32183. /**
  32184. * Creates a depth stencil texture.
  32185. * This is only available in WebGL 2 or with the depth texture extension available.
  32186. * @param size The size of face edge in the texture.
  32187. * @param options The options defining the texture.
  32188. * @returns The texture
  32189. */
  32190. private _createDepthStencilTexture;
  32191. /**
  32192. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32193. * @param renderTarget The render target to set the frame buffer for
  32194. */
  32195. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32196. /**
  32197. * Creates a new render target texture
  32198. * @param size defines the size of the texture
  32199. * @param options defines the options used to create the texture
  32200. * @returns a new render target texture stored in an InternalTexture
  32201. */
  32202. createRenderTargetTexture(size: number | {
  32203. width: number;
  32204. height: number;
  32205. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32206. /** @hidden */
  32207. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32208. /**
  32209. * Updates the sample count of a render target texture
  32210. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32211. * @param texture defines the texture to update
  32212. * @param samples defines the sample count to set
  32213. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32214. */
  32215. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32216. /** @hidden */
  32217. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32218. /** @hidden */
  32219. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32220. /** @hidden */
  32221. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32222. /** @hidden */
  32223. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32224. /**
  32225. * @hidden
  32226. */
  32227. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32228. private _prepareWebGLTextureContinuation;
  32229. private _prepareWebGLTexture;
  32230. /** @hidden */
  32231. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32232. /** @hidden */
  32233. _releaseFramebufferObjects(texture: InternalTexture): void;
  32234. /** @hidden */
  32235. _releaseTexture(texture: InternalTexture): void;
  32236. private setProgram;
  32237. private _boundUniforms;
  32238. /**
  32239. * Binds an effect to the webGL context
  32240. * @param effect defines the effect to bind
  32241. */
  32242. bindSamplers(effect: Effect): void;
  32243. private _activateCurrentTexture;
  32244. /** @hidden */
  32245. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32246. /** @hidden */
  32247. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32248. /**
  32249. * Sets a texture to the webGL context from a postprocess
  32250. * @param channel defines the channel to use
  32251. * @param postProcess defines the source postprocess
  32252. */
  32253. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32254. /**
  32255. * Binds the output of the passed in post process to the texture channel specified
  32256. * @param channel The channel the texture should be bound to
  32257. * @param postProcess The post process which's output should be bound
  32258. */
  32259. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32260. /**
  32261. * Unbind all textures from the webGL context
  32262. */
  32263. unbindAllTextures(): void;
  32264. /**
  32265. * Sets a texture to the according uniform.
  32266. * @param channel The texture channel
  32267. * @param uniform The uniform to set
  32268. * @param texture The texture to apply
  32269. */
  32270. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32271. /**
  32272. * Sets a depth stencil texture from a render target to the according uniform.
  32273. * @param channel The texture channel
  32274. * @param uniform The uniform to set
  32275. * @param texture The render target texture containing the depth stencil texture to apply
  32276. */
  32277. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32278. private _bindSamplerUniformToChannel;
  32279. private _getTextureWrapMode;
  32280. private _setTexture;
  32281. /**
  32282. * Sets an array of texture to the webGL context
  32283. * @param channel defines the channel where the texture array must be set
  32284. * @param uniform defines the associated uniform location
  32285. * @param textures defines the array of textures to bind
  32286. */
  32287. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32288. /** @hidden */
  32289. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32290. private _setTextureParameterFloat;
  32291. private _setTextureParameterInteger;
  32292. /**
  32293. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32294. * @param x defines the x coordinate of the rectangle where pixels must be read
  32295. * @param y defines the y coordinate of the rectangle where pixels must be read
  32296. * @param width defines the width of the rectangle where pixels must be read
  32297. * @param height defines the height of the rectangle where pixels must be read
  32298. * @returns a Uint8Array containing RGBA colors
  32299. */
  32300. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32301. /**
  32302. * Add an externaly attached data from its key.
  32303. * This method call will fail and return false, if such key already exists.
  32304. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32305. * @param key the unique key that identifies the data
  32306. * @param data the data object to associate to the key for this Engine instance
  32307. * @return true if no such key were already present and the data was added successfully, false otherwise
  32308. */
  32309. addExternalData<T>(key: string, data: T): boolean;
  32310. /**
  32311. * Get an externaly attached data from its key
  32312. * @param key the unique key that identifies the data
  32313. * @return the associated data, if present (can be null), or undefined if not present
  32314. */
  32315. getExternalData<T>(key: string): T;
  32316. /**
  32317. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32318. * @param key the unique key that identifies the data
  32319. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32320. * @return the associated data, can be null if the factory returned null.
  32321. */
  32322. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32323. /**
  32324. * Remove an externaly attached data from the Engine instance
  32325. * @param key the unique key that identifies the data
  32326. * @return true if the data was successfully removed, false if it doesn't exist
  32327. */
  32328. removeExternalData(key: string): boolean;
  32329. /**
  32330. * Unbind all vertex attributes from the webGL context
  32331. */
  32332. unbindAllAttributes(): void;
  32333. /**
  32334. * 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
  32335. */
  32336. releaseEffects(): void;
  32337. /**
  32338. * Dispose and release all associated resources
  32339. */
  32340. dispose(): void;
  32341. /**
  32342. * Display the loading screen
  32343. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32344. */
  32345. displayLoadingUI(): void;
  32346. /**
  32347. * Hide the loading screen
  32348. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32349. */
  32350. hideLoadingUI(): void;
  32351. /**
  32352. * Gets the current loading screen object
  32353. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32354. */
  32355. /**
  32356. * Sets the current loading screen object
  32357. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32358. */
  32359. loadingScreen: ILoadingScreen;
  32360. /**
  32361. * Sets the current loading screen text
  32362. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32363. */
  32364. loadingUIText: string;
  32365. /**
  32366. * Sets the current loading screen background color
  32367. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32368. */
  32369. loadingUIBackgroundColor: string;
  32370. /**
  32371. * Attach a new callback raised when context lost event is fired
  32372. * @param callback defines the callback to call
  32373. */
  32374. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32375. /**
  32376. * Attach a new callback raised when context restored event is fired
  32377. * @param callback defines the callback to call
  32378. */
  32379. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32380. /**
  32381. * Gets the source code of the vertex shader associated with a specific webGL program
  32382. * @param program defines the program to use
  32383. * @returns a string containing the source code of the vertex shader associated with the program
  32384. */
  32385. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32386. /**
  32387. * Gets the source code of the fragment shader associated with a specific webGL program
  32388. * @param program defines the program to use
  32389. * @returns a string containing the source code of the fragment shader associated with the program
  32390. */
  32391. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32392. /**
  32393. * Get the current error code of the webGL context
  32394. * @returns the error code
  32395. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32396. */
  32397. getError(): number;
  32398. /**
  32399. * Gets the current framerate
  32400. * @returns a number representing the framerate
  32401. */
  32402. getFps(): number;
  32403. /**
  32404. * Gets the time spent between current and previous frame
  32405. * @returns a number representing the delta time in ms
  32406. */
  32407. getDeltaTime(): number;
  32408. private _measureFps;
  32409. /** @hidden */
  32410. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32411. private _canRenderToFloatFramebuffer;
  32412. private _canRenderToHalfFloatFramebuffer;
  32413. private _canRenderToFramebuffer;
  32414. /** @hidden */
  32415. _getWebGLTextureType(type: number): number;
  32416. /** @hidden */
  32417. _getInternalFormat(format: number): number;
  32418. /** @hidden */
  32419. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32420. /** @hidden */
  32421. _getRGBAMultiSampleBufferFormat(type: number): number;
  32422. /** @hidden */
  32423. _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;
  32424. /** @hidden */
  32425. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32426. /**
  32427. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32428. * @returns true if the engine can be created
  32429. * @ignorenaming
  32430. */
  32431. static isSupported(): boolean;
  32432. /**
  32433. * Find the next highest power of two.
  32434. * @param x Number to start search from.
  32435. * @return Next highest power of two.
  32436. */
  32437. static CeilingPOT(x: number): number;
  32438. /**
  32439. * Find the next lowest power of two.
  32440. * @param x Number to start search from.
  32441. * @return Next lowest power of two.
  32442. */
  32443. static FloorPOT(x: number): number;
  32444. /**
  32445. * Find the nearest power of two.
  32446. * @param x Number to start search from.
  32447. * @return Next nearest power of two.
  32448. */
  32449. static NearestPOT(x: number): number;
  32450. /**
  32451. * Get the closest exponent of two
  32452. * @param value defines the value to approximate
  32453. * @param max defines the maximum value to return
  32454. * @param mode defines how to define the closest value
  32455. * @returns closest exponent of two of the given value
  32456. */
  32457. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32458. /**
  32459. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32460. * @param func - the function to be called
  32461. * @param requester - the object that will request the next frame. Falls back to window.
  32462. * @returns frame number
  32463. */
  32464. static QueueNewFrame(func: () => void, requester?: any): number;
  32465. /**
  32466. * Ask the browser to promote the current element to pointerlock mode
  32467. * @param element defines the DOM element to promote
  32468. */
  32469. static _RequestPointerlock(element: HTMLElement): void;
  32470. /**
  32471. * Asks the browser to exit pointerlock mode
  32472. */
  32473. static _ExitPointerlock(): void;
  32474. /**
  32475. * Ask the browser to promote the current element to fullscreen rendering mode
  32476. * @param element defines the DOM element to promote
  32477. */
  32478. static _RequestFullscreen(element: HTMLElement): void;
  32479. /**
  32480. * Asks the browser to exit fullscreen mode
  32481. */
  32482. static _ExitFullscreen(): void;
  32483. }
  32484. }
  32485. declare module "babylonjs/Engines/engineStore" {
  32486. import { Nullable } from "babylonjs/types";
  32487. import { Engine } from "babylonjs/Engines/engine";
  32488. import { Scene } from "babylonjs/scene";
  32489. /**
  32490. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32491. * during the life time of the application.
  32492. */
  32493. export class EngineStore {
  32494. /** Gets the list of created engines */
  32495. static Instances: import("babylonjs/Engines/engine").Engine[];
  32496. /** @hidden */
  32497. static _LastCreatedScene: Nullable<Scene>;
  32498. /**
  32499. * Gets the latest created engine
  32500. */
  32501. static readonly LastCreatedEngine: Nullable<Engine>;
  32502. /**
  32503. * Gets the latest created scene
  32504. */
  32505. static readonly LastCreatedScene: Nullable<Scene>;
  32506. /**
  32507. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32508. * @ignorenaming
  32509. */
  32510. static UseFallbackTexture: boolean;
  32511. /**
  32512. * Texture content used if a texture cannot loaded
  32513. * @ignorenaming
  32514. */
  32515. static FallbackTexture: string;
  32516. }
  32517. }
  32518. declare module "babylonjs/Misc/promise" {
  32519. /**
  32520. * Helper class that provides a small promise polyfill
  32521. */
  32522. export class PromisePolyfill {
  32523. /**
  32524. * Static function used to check if the polyfill is required
  32525. * If this is the case then the function will inject the polyfill to window.Promise
  32526. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32527. */
  32528. static Apply(force?: boolean): void;
  32529. }
  32530. }
  32531. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32532. /**
  32533. * Interface for screenshot methods with describe argument called `size` as object with options
  32534. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32535. */
  32536. export interface IScreenshotSize {
  32537. /**
  32538. * number in pixels for canvas height
  32539. */
  32540. height?: number;
  32541. /**
  32542. * multiplier allowing render at a higher or lower resolution
  32543. * If value is defined then height and width will be ignored and taken from camera
  32544. */
  32545. precision?: number;
  32546. /**
  32547. * number in pixels for canvas width
  32548. */
  32549. width?: number;
  32550. }
  32551. }
  32552. declare module "babylonjs/Misc/tools" {
  32553. import { Nullable, float } from "babylonjs/types";
  32554. import { DomManagement } from "babylonjs/Misc/domManagement";
  32555. import { WebRequest } from "babylonjs/Misc/webRequest";
  32556. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32557. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32558. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32559. import { Camera } from "babylonjs/Cameras/camera";
  32560. import { Engine } from "babylonjs/Engines/engine";
  32561. interface IColor4Like {
  32562. r: float;
  32563. g: float;
  32564. b: float;
  32565. a: float;
  32566. }
  32567. /**
  32568. * Class containing a set of static utilities functions
  32569. */
  32570. export class Tools {
  32571. /**
  32572. * Gets or sets the base URL to use to load assets
  32573. */
  32574. static BaseUrl: string;
  32575. /**
  32576. * Enable/Disable Custom HTTP Request Headers globally.
  32577. * default = false
  32578. * @see CustomRequestHeaders
  32579. */
  32580. static UseCustomRequestHeaders: boolean;
  32581. /**
  32582. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32583. * i.e. when loading files, where the server/service expects an Authorization header
  32584. */
  32585. static CustomRequestHeaders: {
  32586. [key: string]: string;
  32587. };
  32588. /**
  32589. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32590. */
  32591. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32592. /**
  32593. * Default behaviour for cors in the application.
  32594. * It can be a string if the expected behavior is identical in the entire app.
  32595. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32596. */
  32597. static CorsBehavior: string | ((url: string | string[]) => string);
  32598. /**
  32599. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32600. * @ignorenaming
  32601. */
  32602. static UseFallbackTexture: boolean;
  32603. /**
  32604. * Use this object to register external classes like custom textures or material
  32605. * to allow the laoders to instantiate them
  32606. */
  32607. static RegisteredExternalClasses: {
  32608. [key: string]: Object;
  32609. };
  32610. /**
  32611. * Texture content used if a texture cannot loaded
  32612. * @ignorenaming
  32613. */
  32614. static fallbackTexture: string;
  32615. /**
  32616. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32617. * @param u defines the coordinate on X axis
  32618. * @param v defines the coordinate on Y axis
  32619. * @param width defines the width of the source data
  32620. * @param height defines the height of the source data
  32621. * @param pixels defines the source byte array
  32622. * @param color defines the output color
  32623. */
  32624. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32625. /**
  32626. * Interpolates between a and b via alpha
  32627. * @param a The lower value (returned when alpha = 0)
  32628. * @param b The upper value (returned when alpha = 1)
  32629. * @param alpha The interpolation-factor
  32630. * @return The mixed value
  32631. */
  32632. static Mix(a: number, b: number, alpha: number): number;
  32633. /**
  32634. * Tries to instantiate a new object from a given class name
  32635. * @param className defines the class name to instantiate
  32636. * @returns the new object or null if the system was not able to do the instantiation
  32637. */
  32638. static Instantiate(className: string): any;
  32639. /**
  32640. * Provides a slice function that will work even on IE
  32641. * @param data defines the array to slice
  32642. * @param start defines the start of the data (optional)
  32643. * @param end defines the end of the data (optional)
  32644. * @returns the new sliced array
  32645. */
  32646. static Slice<T>(data: T, start?: number, end?: number): T;
  32647. /**
  32648. * Polyfill for setImmediate
  32649. * @param action defines the action to execute after the current execution block
  32650. */
  32651. static SetImmediate(action: () => void): void;
  32652. /**
  32653. * Function indicating if a number is an exponent of 2
  32654. * @param value defines the value to test
  32655. * @returns true if the value is an exponent of 2
  32656. */
  32657. static IsExponentOfTwo(value: number): boolean;
  32658. private static _tmpFloatArray;
  32659. /**
  32660. * Returns the nearest 32-bit single precision float representation of a Number
  32661. * @param value A Number. If the parameter is of a different type, it will get converted
  32662. * to a number or to NaN if it cannot be converted
  32663. * @returns number
  32664. */
  32665. static FloatRound(value: number): number;
  32666. /**
  32667. * Extracts the filename from a path
  32668. * @param path defines the path to use
  32669. * @returns the filename
  32670. */
  32671. static GetFilename(path: string): string;
  32672. /**
  32673. * Extracts the "folder" part of a path (everything before the filename).
  32674. * @param uri The URI to extract the info from
  32675. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32676. * @returns The "folder" part of the path
  32677. */
  32678. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32679. /**
  32680. * Extracts text content from a DOM element hierarchy
  32681. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32682. */
  32683. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32684. /**
  32685. * Convert an angle in radians to degrees
  32686. * @param angle defines the angle to convert
  32687. * @returns the angle in degrees
  32688. */
  32689. static ToDegrees(angle: number): number;
  32690. /**
  32691. * Convert an angle in degrees to radians
  32692. * @param angle defines the angle to convert
  32693. * @returns the angle in radians
  32694. */
  32695. static ToRadians(angle: number): number;
  32696. /**
  32697. * Encode a buffer to a base64 string
  32698. * @param buffer defines the buffer to encode
  32699. * @returns the encoded string
  32700. */
  32701. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32702. /**
  32703. * Returns an array if obj is not an array
  32704. * @param obj defines the object to evaluate as an array
  32705. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32706. * @returns either obj directly if obj is an array or a new array containing obj
  32707. */
  32708. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32709. /**
  32710. * Gets the pointer prefix to use
  32711. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32712. */
  32713. static GetPointerPrefix(): string;
  32714. /**
  32715. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32716. * @param url define the url we are trying
  32717. * @param element define the dom element where to configure the cors policy
  32718. */
  32719. static SetCorsBehavior(url: string | string[], element: {
  32720. crossOrigin: string | null;
  32721. }): void;
  32722. /**
  32723. * Removes unwanted characters from an url
  32724. * @param url defines the url to clean
  32725. * @returns the cleaned url
  32726. */
  32727. static CleanUrl(url: string): string;
  32728. /**
  32729. * Gets or sets a function used to pre-process url before using them to load assets
  32730. */
  32731. static PreprocessUrl: (url: string) => string;
  32732. /**
  32733. * Loads an image as an HTMLImageElement.
  32734. * @param input url string, ArrayBuffer, or Blob to load
  32735. * @param onLoad callback called when the image successfully loads
  32736. * @param onError callback called when the image fails to load
  32737. * @param offlineProvider offline provider for caching
  32738. * @returns the HTMLImageElement of the loaded image
  32739. */
  32740. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32741. /**
  32742. * Loads a file
  32743. * @param url url string, ArrayBuffer, or Blob to load
  32744. * @param onSuccess callback called when the file successfully loads
  32745. * @param onProgress callback called while file is loading (if the server supports this mode)
  32746. * @param offlineProvider defines the offline provider for caching
  32747. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32748. * @param onError callback called when the file fails to load
  32749. * @returns a file request object
  32750. */
  32751. 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;
  32752. /**
  32753. * Loads a file from a url
  32754. * @param url the file url to load
  32755. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32756. */
  32757. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32758. /**
  32759. * Load a script (identified by an url). When the url returns, the
  32760. * content of this file is added into a new script element, attached to the DOM (body element)
  32761. * @param scriptUrl defines the url of the script to laod
  32762. * @param onSuccess defines the callback called when the script is loaded
  32763. * @param onError defines the callback to call if an error occurs
  32764. * @param scriptId defines the id of the script element
  32765. */
  32766. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32767. /**
  32768. * Load an asynchronous script (identified by an url). When the url returns, the
  32769. * content of this file is added into a new script element, attached to the DOM (body element)
  32770. * @param scriptUrl defines the url of the script to laod
  32771. * @param scriptId defines the id of the script element
  32772. * @returns a promise request object
  32773. */
  32774. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32775. /**
  32776. * Loads a file from a blob
  32777. * @param fileToLoad defines the blob to use
  32778. * @param callback defines the callback to call when data is loaded
  32779. * @param progressCallback defines the callback to call during loading process
  32780. * @returns a file request object
  32781. */
  32782. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32783. /**
  32784. * Loads a file
  32785. * @param fileToLoad defines the file to load
  32786. * @param callback defines the callback to call when data is loaded
  32787. * @param progressCallBack defines the callback to call during loading process
  32788. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32789. * @returns a file request object
  32790. */
  32791. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32792. /**
  32793. * Creates a data url from a given string content
  32794. * @param content defines the content to convert
  32795. * @returns the new data url link
  32796. */
  32797. static FileAsURL(content: string): string;
  32798. /**
  32799. * Format the given number to a specific decimal format
  32800. * @param value defines the number to format
  32801. * @param decimals defines the number of decimals to use
  32802. * @returns the formatted string
  32803. */
  32804. static Format(value: number, decimals?: number): string;
  32805. /**
  32806. * Tries to copy an object by duplicating every property
  32807. * @param source defines the source object
  32808. * @param destination defines the target object
  32809. * @param doNotCopyList defines a list of properties to avoid
  32810. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32811. */
  32812. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32813. /**
  32814. * Gets a boolean indicating if the given object has no own property
  32815. * @param obj defines the object to test
  32816. * @returns true if object has no own property
  32817. */
  32818. static IsEmpty(obj: any): boolean;
  32819. /**
  32820. * Function used to register events at window level
  32821. * @param windowElement defines the Window object to use
  32822. * @param events defines the events to register
  32823. */
  32824. static RegisterTopRootEvents(windowElement: Window, events: {
  32825. name: string;
  32826. handler: Nullable<(e: FocusEvent) => any>;
  32827. }[]): void;
  32828. /**
  32829. * Function used to unregister events from window level
  32830. * @param windowElement defines the Window object to use
  32831. * @param events defines the events to unregister
  32832. */
  32833. static UnregisterTopRootEvents(windowElement: Window, events: {
  32834. name: string;
  32835. handler: Nullable<(e: FocusEvent) => any>;
  32836. }[]): void;
  32837. /**
  32838. * @ignore
  32839. */
  32840. static _ScreenshotCanvas: HTMLCanvasElement;
  32841. /**
  32842. * Dumps the current bound framebuffer
  32843. * @param width defines the rendering width
  32844. * @param height defines the rendering height
  32845. * @param engine defines the hosting engine
  32846. * @param successCallback defines the callback triggered once the data are available
  32847. * @param mimeType defines the mime type of the result
  32848. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32849. */
  32850. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32851. /**
  32852. * Converts the canvas data to blob.
  32853. * This acts as a polyfill for browsers not supporting the to blob function.
  32854. * @param canvas Defines the canvas to extract the data from
  32855. * @param successCallback Defines the callback triggered once the data are available
  32856. * @param mimeType Defines the mime type of the result
  32857. */
  32858. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32859. /**
  32860. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32861. * @param successCallback defines the callback triggered once the data are available
  32862. * @param mimeType defines the mime type of the result
  32863. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32864. */
  32865. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32866. /**
  32867. * Downloads a blob in the browser
  32868. * @param blob defines the blob to download
  32869. * @param fileName defines the name of the downloaded file
  32870. */
  32871. static Download(blob: Blob, fileName: string): void;
  32872. /**
  32873. * Captures a screenshot of the current rendering
  32874. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32875. * @param engine defines the rendering engine
  32876. * @param camera defines the source camera
  32877. * @param size This parameter can be set to a single number or to an object with the
  32878. * following (optional) properties: precision, width, height. If a single number is passed,
  32879. * it will be used for both width and height. If an object is passed, the screenshot size
  32880. * will be derived from the parameters. The precision property is a multiplier allowing
  32881. * rendering at a higher or lower resolution
  32882. * @param successCallback defines the callback receives a single parameter which contains the
  32883. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32884. * src parameter of an <img> to display it
  32885. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32886. * Check your browser for supported MIME types
  32887. */
  32888. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32889. /**
  32890. * Captures a screenshot of the current rendering
  32891. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32892. * @param engine defines the rendering engine
  32893. * @param camera defines the source camera
  32894. * @param size This parameter can be set to a single number or to an object with the
  32895. * following (optional) properties: precision, width, height. If a single number is passed,
  32896. * it will be used for both width and height. If an object is passed, the screenshot size
  32897. * will be derived from the parameters. The precision property is a multiplier allowing
  32898. * rendering at a higher or lower resolution
  32899. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32900. * Check your browser for supported MIME types
  32901. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32902. * to the src parameter of an <img> to display it
  32903. */
  32904. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32905. /**
  32906. * Generates an image screenshot from the specified camera.
  32907. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32908. * @param engine The engine to use for rendering
  32909. * @param camera The camera to use for rendering
  32910. * @param size This parameter can be set to a single number or to an object with the
  32911. * following (optional) properties: precision, width, height. If a single number is passed,
  32912. * it will be used for both width and height. If an object is passed, the screenshot size
  32913. * will be derived from the parameters. The precision property is a multiplier allowing
  32914. * rendering at a higher or lower resolution
  32915. * @param successCallback The callback receives a single parameter which contains the
  32916. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32917. * src parameter of an <img> to display it
  32918. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32919. * Check your browser for supported MIME types
  32920. * @param samples Texture samples (default: 1)
  32921. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32922. * @param fileName A name for for the downloaded file.
  32923. */
  32924. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32925. /**
  32926. * Generates an image screenshot from the specified camera.
  32927. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32928. * @param engine The engine to use for rendering
  32929. * @param camera The camera to use for rendering
  32930. * @param size This parameter can be set to a single number or to an object with the
  32931. * following (optional) properties: precision, width, height. If a single number is passed,
  32932. * it will be used for both width and height. If an object is passed, the screenshot size
  32933. * will be derived from the parameters. The precision property is a multiplier allowing
  32934. * rendering at a higher or lower resolution
  32935. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32936. * Check your browser for supported MIME types
  32937. * @param samples Texture samples (default: 1)
  32938. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32939. * @param fileName A name for for the downloaded file.
  32940. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32941. * to the src parameter of an <img> to display it
  32942. */
  32943. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32944. /**
  32945. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32946. * Be aware Math.random() could cause collisions, but:
  32947. * "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"
  32948. * @returns a pseudo random id
  32949. */
  32950. static RandomId(): string;
  32951. /**
  32952. * Test if the given uri is a base64 string
  32953. * @param uri The uri to test
  32954. * @return True if the uri is a base64 string or false otherwise
  32955. */
  32956. static IsBase64(uri: string): boolean;
  32957. /**
  32958. * Decode the given base64 uri.
  32959. * @param uri The uri to decode
  32960. * @return The decoded base64 data.
  32961. */
  32962. static DecodeBase64(uri: string): ArrayBuffer;
  32963. /**
  32964. * Gets the absolute url.
  32965. * @param url the input url
  32966. * @return the absolute url
  32967. */
  32968. static GetAbsoluteUrl(url: string): string;
  32969. /**
  32970. * No log
  32971. */
  32972. static readonly NoneLogLevel: number;
  32973. /**
  32974. * Only message logs
  32975. */
  32976. static readonly MessageLogLevel: number;
  32977. /**
  32978. * Only warning logs
  32979. */
  32980. static readonly WarningLogLevel: number;
  32981. /**
  32982. * Only error logs
  32983. */
  32984. static readonly ErrorLogLevel: number;
  32985. /**
  32986. * All logs
  32987. */
  32988. static readonly AllLogLevel: number;
  32989. /**
  32990. * Gets a value indicating the number of loading errors
  32991. * @ignorenaming
  32992. */
  32993. static readonly errorsCount: number;
  32994. /**
  32995. * Callback called when a new log is added
  32996. */
  32997. static OnNewCacheEntry: (entry: string) => void;
  32998. /**
  32999. * Log a message to the console
  33000. * @param message defines the message to log
  33001. */
  33002. static Log(message: string): void;
  33003. /**
  33004. * Write a warning message to the console
  33005. * @param message defines the message to log
  33006. */
  33007. static Warn(message: string): void;
  33008. /**
  33009. * Write an error message to the console
  33010. * @param message defines the message to log
  33011. */
  33012. static Error(message: string): void;
  33013. /**
  33014. * Gets current log cache (list of logs)
  33015. */
  33016. static readonly LogCache: string;
  33017. /**
  33018. * Clears the log cache
  33019. */
  33020. static ClearLogCache(): void;
  33021. /**
  33022. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33023. */
  33024. static LogLevels: number;
  33025. /**
  33026. * Checks if the window object exists
  33027. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33028. */
  33029. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33030. /**
  33031. * No performance log
  33032. */
  33033. static readonly PerformanceNoneLogLevel: number;
  33034. /**
  33035. * Use user marks to log performance
  33036. */
  33037. static readonly PerformanceUserMarkLogLevel: number;
  33038. /**
  33039. * Log performance to the console
  33040. */
  33041. static readonly PerformanceConsoleLogLevel: number;
  33042. private static _performance;
  33043. /**
  33044. * Sets the current performance log level
  33045. */
  33046. static PerformanceLogLevel: number;
  33047. private static _StartPerformanceCounterDisabled;
  33048. private static _EndPerformanceCounterDisabled;
  33049. private static _StartUserMark;
  33050. private static _EndUserMark;
  33051. private static _StartPerformanceConsole;
  33052. private static _EndPerformanceConsole;
  33053. /**
  33054. * Starts a performance counter
  33055. */
  33056. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33057. /**
  33058. * Ends a specific performance coutner
  33059. */
  33060. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33061. /**
  33062. * Gets either window.performance.now() if supported or Date.now() else
  33063. */
  33064. static readonly Now: number;
  33065. /**
  33066. * This method will return the name of the class used to create the instance of the given object.
  33067. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33068. * @param object the object to get the class name from
  33069. * @param isType defines if the object is actually a type
  33070. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33071. */
  33072. static GetClassName(object: any, isType?: boolean): string;
  33073. /**
  33074. * Gets the first element of an array satisfying a given predicate
  33075. * @param array defines the array to browse
  33076. * @param predicate defines the predicate to use
  33077. * @returns null if not found or the element
  33078. */
  33079. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33080. /**
  33081. * This method will return the name of the full name of the class, including its owning module (if any).
  33082. * 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).
  33083. * @param object the object to get the class name from
  33084. * @param isType defines if the object is actually a type
  33085. * @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.
  33086. * @ignorenaming
  33087. */
  33088. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33089. /**
  33090. * Returns a promise that resolves after the given amount of time.
  33091. * @param delay Number of milliseconds to delay
  33092. * @returns Promise that resolves after the given amount of time
  33093. */
  33094. static DelayAsync(delay: number): Promise<void>;
  33095. }
  33096. /**
  33097. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33098. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33099. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33100. * @param name The name of the class, case should be preserved
  33101. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33102. */
  33103. export function className(name: string, module?: string): (target: Object) => void;
  33104. /**
  33105. * An implementation of a loop for asynchronous functions.
  33106. */
  33107. export class AsyncLoop {
  33108. /**
  33109. * Defines the number of iterations for the loop
  33110. */
  33111. iterations: number;
  33112. /**
  33113. * Defines the current index of the loop.
  33114. */
  33115. index: number;
  33116. private _done;
  33117. private _fn;
  33118. private _successCallback;
  33119. /**
  33120. * Constructor.
  33121. * @param iterations the number of iterations.
  33122. * @param func the function to run each iteration
  33123. * @param successCallback the callback that will be called upon succesful execution
  33124. * @param offset starting offset.
  33125. */
  33126. constructor(
  33127. /**
  33128. * Defines the number of iterations for the loop
  33129. */
  33130. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33131. /**
  33132. * Execute the next iteration. Must be called after the last iteration was finished.
  33133. */
  33134. executeNext(): void;
  33135. /**
  33136. * Break the loop and run the success callback.
  33137. */
  33138. breakLoop(): void;
  33139. /**
  33140. * Create and run an async loop.
  33141. * @param iterations the number of iterations.
  33142. * @param fn the function to run each iteration
  33143. * @param successCallback the callback that will be called upon succesful execution
  33144. * @param offset starting offset.
  33145. * @returns the created async loop object
  33146. */
  33147. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33148. /**
  33149. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33150. * @param iterations total number of iterations
  33151. * @param syncedIterations number of synchronous iterations in each async iteration.
  33152. * @param fn the function to call each iteration.
  33153. * @param callback a success call back that will be called when iterating stops.
  33154. * @param breakFunction a break condition (optional)
  33155. * @param timeout timeout settings for the setTimeout function. default - 0.
  33156. * @returns the created async loop object
  33157. */
  33158. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33159. }
  33160. }
  33161. declare module "babylonjs/Collisions/collisionCoordinator" {
  33162. import { Nullable } from "babylonjs/types";
  33163. import { Scene } from "babylonjs/scene";
  33164. import { Vector3 } from "babylonjs/Maths/math.vector";
  33165. import { Collider } from "babylonjs/Collisions/collider";
  33166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33167. /** @hidden */
  33168. export interface ICollisionCoordinator {
  33169. createCollider(): Collider;
  33170. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33171. init(scene: Scene): void;
  33172. }
  33173. /** @hidden */
  33174. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33175. private _scene;
  33176. private _scaledPosition;
  33177. private _scaledVelocity;
  33178. private _finalPosition;
  33179. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33180. createCollider(): Collider;
  33181. init(scene: Scene): void;
  33182. private _collideWithWorld;
  33183. }
  33184. }
  33185. declare module "babylonjs/Inputs/scene.inputManager" {
  33186. import { Nullable } from "babylonjs/types";
  33187. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33188. import { Vector2 } from "babylonjs/Maths/math.vector";
  33189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33190. import { Scene } from "babylonjs/scene";
  33191. /**
  33192. * Class used to manage all inputs for the scene.
  33193. */
  33194. export class InputManager {
  33195. /** The distance in pixel that you have to move to prevent some events */
  33196. static DragMovementThreshold: number;
  33197. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33198. static LongPressDelay: number;
  33199. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33200. static DoubleClickDelay: number;
  33201. /** If you need to check double click without raising a single click at first click, enable this flag */
  33202. static ExclusiveDoubleClickMode: boolean;
  33203. private _wheelEventName;
  33204. private _onPointerMove;
  33205. private _onPointerDown;
  33206. private _onPointerUp;
  33207. private _initClickEvent;
  33208. private _initActionManager;
  33209. private _delayedSimpleClick;
  33210. private _delayedSimpleClickTimeout;
  33211. private _previousDelayedSimpleClickTimeout;
  33212. private _meshPickProceed;
  33213. private _previousButtonPressed;
  33214. private _currentPickResult;
  33215. private _previousPickResult;
  33216. private _totalPointersPressed;
  33217. private _doubleClickOccured;
  33218. private _pointerOverMesh;
  33219. private _pickedDownMesh;
  33220. private _pickedUpMesh;
  33221. private _pointerX;
  33222. private _pointerY;
  33223. private _unTranslatedPointerX;
  33224. private _unTranslatedPointerY;
  33225. private _startingPointerPosition;
  33226. private _previousStartingPointerPosition;
  33227. private _startingPointerTime;
  33228. private _previousStartingPointerTime;
  33229. private _pointerCaptures;
  33230. private _onKeyDown;
  33231. private _onKeyUp;
  33232. private _onCanvasFocusObserver;
  33233. private _onCanvasBlurObserver;
  33234. private _scene;
  33235. /**
  33236. * Creates a new InputManager
  33237. * @param scene defines the hosting scene
  33238. */
  33239. constructor(scene: Scene);
  33240. /**
  33241. * Gets the mesh that is currently under the pointer
  33242. */
  33243. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33244. /**
  33245. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33246. */
  33247. readonly unTranslatedPointer: Vector2;
  33248. /**
  33249. * Gets or sets the current on-screen X position of the pointer
  33250. */
  33251. pointerX: number;
  33252. /**
  33253. * Gets or sets the current on-screen Y position of the pointer
  33254. */
  33255. pointerY: number;
  33256. private _updatePointerPosition;
  33257. private _processPointerMove;
  33258. private _setRayOnPointerInfo;
  33259. private _checkPrePointerObservable;
  33260. /**
  33261. * Use this method to simulate a pointer move on a mesh
  33262. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33263. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33264. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33265. */
  33266. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33267. /**
  33268. * Use this method to simulate a pointer down on a mesh
  33269. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33270. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33271. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33272. */
  33273. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33274. private _processPointerDown;
  33275. /** @hidden */
  33276. _isPointerSwiping(): boolean;
  33277. /**
  33278. * Use this method to simulate a pointer up on a mesh
  33279. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33280. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33281. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33282. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33283. */
  33284. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33285. private _processPointerUp;
  33286. /**
  33287. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33288. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33289. * @returns true if the pointer was captured
  33290. */
  33291. isPointerCaptured(pointerId?: number): boolean;
  33292. /**
  33293. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33294. * @param attachUp defines if you want to attach events to pointerup
  33295. * @param attachDown defines if you want to attach events to pointerdown
  33296. * @param attachMove defines if you want to attach events to pointermove
  33297. */
  33298. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33299. /**
  33300. * Detaches all event handlers
  33301. */
  33302. detachControl(): void;
  33303. /**
  33304. * Force the value of meshUnderPointer
  33305. * @param mesh defines the mesh to use
  33306. */
  33307. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33308. /**
  33309. * Gets the mesh under the pointer
  33310. * @returns a Mesh or null if no mesh is under the pointer
  33311. */
  33312. getPointerOverMesh(): Nullable<AbstractMesh>;
  33313. }
  33314. }
  33315. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33316. /**
  33317. * Helper class used to generate session unique ID
  33318. */
  33319. export class UniqueIdGenerator {
  33320. private static _UniqueIdCounter;
  33321. /**
  33322. * Gets an unique (relatively to the current scene) Id
  33323. */
  33324. static readonly UniqueId: number;
  33325. }
  33326. }
  33327. declare module "babylonjs/Animations/animationGroup" {
  33328. import { Animatable } from "babylonjs/Animations/animatable";
  33329. import { Animation } from "babylonjs/Animations/animation";
  33330. import { Scene, IDisposable } from "babylonjs/scene";
  33331. import { Observable } from "babylonjs/Misc/observable";
  33332. import { Nullable } from "babylonjs/types";
  33333. import "babylonjs/Animations/animatable";
  33334. /**
  33335. * This class defines the direct association between an animation and a target
  33336. */
  33337. export class TargetedAnimation {
  33338. /**
  33339. * Animation to perform
  33340. */
  33341. animation: Animation;
  33342. /**
  33343. * Target to animate
  33344. */
  33345. target: any;
  33346. /**
  33347. * Serialize the object
  33348. * @returns the JSON object representing the current entity
  33349. */
  33350. serialize(): any;
  33351. }
  33352. /**
  33353. * Use this class to create coordinated animations on multiple targets
  33354. */
  33355. export class AnimationGroup implements IDisposable {
  33356. /** The name of the animation group */
  33357. name: string;
  33358. private _scene;
  33359. private _targetedAnimations;
  33360. private _animatables;
  33361. private _from;
  33362. private _to;
  33363. private _isStarted;
  33364. private _isPaused;
  33365. private _speedRatio;
  33366. private _loopAnimation;
  33367. /**
  33368. * Gets or sets the unique id of the node
  33369. */
  33370. uniqueId: number;
  33371. /**
  33372. * This observable will notify when one animation have ended
  33373. */
  33374. onAnimationEndObservable: Observable<TargetedAnimation>;
  33375. /**
  33376. * Observer raised when one animation loops
  33377. */
  33378. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33379. /**
  33380. * This observable will notify when all animations have ended.
  33381. */
  33382. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33383. /**
  33384. * This observable will notify when all animations have paused.
  33385. */
  33386. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33387. /**
  33388. * This observable will notify when all animations are playing.
  33389. */
  33390. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33391. /**
  33392. * Gets the first frame
  33393. */
  33394. readonly from: number;
  33395. /**
  33396. * Gets the last frame
  33397. */
  33398. readonly to: number;
  33399. /**
  33400. * Define if the animations are started
  33401. */
  33402. readonly isStarted: boolean;
  33403. /**
  33404. * Gets a value indicating that the current group is playing
  33405. */
  33406. readonly isPlaying: boolean;
  33407. /**
  33408. * Gets or sets the speed ratio to use for all animations
  33409. */
  33410. /**
  33411. * Gets or sets the speed ratio to use for all animations
  33412. */
  33413. speedRatio: number;
  33414. /**
  33415. * Gets or sets if all animations should loop or not
  33416. */
  33417. loopAnimation: boolean;
  33418. /**
  33419. * Gets the targeted animations for this animation group
  33420. */
  33421. readonly targetedAnimations: Array<TargetedAnimation>;
  33422. /**
  33423. * returning the list of animatables controlled by this animation group.
  33424. */
  33425. readonly animatables: Array<Animatable>;
  33426. /**
  33427. * Instantiates a new Animation Group.
  33428. * This helps managing several animations at once.
  33429. * @see http://doc.babylonjs.com/how_to/group
  33430. * @param name Defines the name of the group
  33431. * @param scene Defines the scene the group belongs to
  33432. */
  33433. constructor(
  33434. /** The name of the animation group */
  33435. name: string, scene?: Nullable<Scene>);
  33436. /**
  33437. * Add an animation (with its target) in the group
  33438. * @param animation defines the animation we want to add
  33439. * @param target defines the target of the animation
  33440. * @returns the TargetedAnimation object
  33441. */
  33442. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33443. /**
  33444. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33445. * It can add constant keys at begin or end
  33446. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33447. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33448. * @returns the animation group
  33449. */
  33450. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33451. /**
  33452. * Start all animations on given targets
  33453. * @param loop defines if animations must loop
  33454. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33455. * @param from defines the from key (optional)
  33456. * @param to defines the to key (optional)
  33457. * @returns the current animation group
  33458. */
  33459. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33460. /**
  33461. * Pause all animations
  33462. * @returns the animation group
  33463. */
  33464. pause(): AnimationGroup;
  33465. /**
  33466. * Play all animations to initial state
  33467. * This function will start() the animations if they were not started or will restart() them if they were paused
  33468. * @param loop defines if animations must loop
  33469. * @returns the animation group
  33470. */
  33471. play(loop?: boolean): AnimationGroup;
  33472. /**
  33473. * Reset all animations to initial state
  33474. * @returns the animation group
  33475. */
  33476. reset(): AnimationGroup;
  33477. /**
  33478. * Restart animations from key 0
  33479. * @returns the animation group
  33480. */
  33481. restart(): AnimationGroup;
  33482. /**
  33483. * Stop all animations
  33484. * @returns the animation group
  33485. */
  33486. stop(): AnimationGroup;
  33487. /**
  33488. * Set animation weight for all animatables
  33489. * @param weight defines the weight to use
  33490. * @return the animationGroup
  33491. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33492. */
  33493. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33494. /**
  33495. * Synchronize and normalize all animatables with a source animatable
  33496. * @param root defines the root animatable to synchronize with
  33497. * @return the animationGroup
  33498. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33499. */
  33500. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33501. /**
  33502. * Goes to a specific frame in this animation group
  33503. * @param frame the frame number to go to
  33504. * @return the animationGroup
  33505. */
  33506. goToFrame(frame: number): AnimationGroup;
  33507. /**
  33508. * Dispose all associated resources
  33509. */
  33510. dispose(): void;
  33511. private _checkAnimationGroupEnded;
  33512. /**
  33513. * Clone the current animation group and returns a copy
  33514. * @param newName defines the name of the new group
  33515. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33516. * @returns the new aniamtion group
  33517. */
  33518. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33519. /**
  33520. * Serializes the animationGroup to an object
  33521. * @returns Serialized object
  33522. */
  33523. serialize(): any;
  33524. /**
  33525. * Returns a new AnimationGroup object parsed from the source provided.
  33526. * @param parsedAnimationGroup defines the source
  33527. * @param scene defines the scene that will receive the animationGroup
  33528. * @returns a new AnimationGroup
  33529. */
  33530. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33531. /**
  33532. * Returns the string "AnimationGroup"
  33533. * @returns "AnimationGroup"
  33534. */
  33535. getClassName(): string;
  33536. /**
  33537. * Creates a detailled string about the object
  33538. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33539. * @returns a string representing the object
  33540. */
  33541. toString(fullDetails?: boolean): string;
  33542. }
  33543. }
  33544. declare module "babylonjs/scene" {
  33545. import { Nullable } from "babylonjs/types";
  33546. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33547. import { Observable } from "babylonjs/Misc/observable";
  33548. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33549. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33550. import { Geometry } from "babylonjs/Meshes/geometry";
  33551. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33552. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33554. import { Mesh } from "babylonjs/Meshes/mesh";
  33555. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33556. import { Bone } from "babylonjs/Bones/bone";
  33557. import { Skeleton } from "babylonjs/Bones/skeleton";
  33558. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33559. import { Camera } from "babylonjs/Cameras/camera";
  33560. import { AbstractScene } from "babylonjs/abstractScene";
  33561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33562. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33563. import { Material } from "babylonjs/Materials/material";
  33564. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33565. import { Effect } from "babylonjs/Materials/effect";
  33566. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33567. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33568. import { Light } from "babylonjs/Lights/light";
  33569. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33570. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33571. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33572. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33573. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33574. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33575. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33576. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33577. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33578. import { Engine } from "babylonjs/Engines/engine";
  33579. import { Node } from "babylonjs/node";
  33580. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33581. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33582. import { WebRequest } from "babylonjs/Misc/webRequest";
  33583. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33584. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33585. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33586. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33587. import { Plane } from "babylonjs/Maths/math.plane";
  33588. import { Ray } from "babylonjs/Culling/ray";
  33589. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33590. import { Animation } from "babylonjs/Animations/animation";
  33591. import { Animatable } from "babylonjs/Animations/animatable";
  33592. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33593. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33594. import { Collider } from "babylonjs/Collisions/collider";
  33595. /**
  33596. * Define an interface for all classes that will hold resources
  33597. */
  33598. export interface IDisposable {
  33599. /**
  33600. * Releases all held resources
  33601. */
  33602. dispose(): void;
  33603. }
  33604. /** Interface defining initialization parameters for Scene class */
  33605. export interface SceneOptions {
  33606. /**
  33607. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33608. * It will improve performance when the number of geometries becomes important.
  33609. */
  33610. useGeometryUniqueIdsMap?: boolean;
  33611. /**
  33612. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33613. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33614. */
  33615. useMaterialMeshMap?: boolean;
  33616. /**
  33617. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33618. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33619. */
  33620. useClonedMeshhMap?: boolean;
  33621. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33622. virtual?: boolean;
  33623. }
  33624. /**
  33625. * Represents a scene to be rendered by the engine.
  33626. * @see http://doc.babylonjs.com/features/scene
  33627. */
  33628. export class Scene extends AbstractScene implements IAnimatable {
  33629. /** The fog is deactivated */
  33630. static readonly FOGMODE_NONE: number;
  33631. /** The fog density is following an exponential function */
  33632. static readonly FOGMODE_EXP: number;
  33633. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33634. static readonly FOGMODE_EXP2: number;
  33635. /** The fog density is following a linear function. */
  33636. static readonly FOGMODE_LINEAR: number;
  33637. /**
  33638. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33640. */
  33641. static MinDeltaTime: number;
  33642. /**
  33643. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33644. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33645. */
  33646. static MaxDeltaTime: number;
  33647. /**
  33648. * Factory used to create the default material.
  33649. * @param name The name of the material to create
  33650. * @param scene The scene to create the material for
  33651. * @returns The default material
  33652. */
  33653. static DefaultMaterialFactory(scene: Scene): Material;
  33654. /**
  33655. * Factory used to create the a collision coordinator.
  33656. * @returns The collision coordinator
  33657. */
  33658. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33659. /** @hidden */
  33660. _inputManager: InputManager;
  33661. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33662. cameraToUseForPointers: Nullable<Camera>;
  33663. /** @hidden */
  33664. readonly _isScene: boolean;
  33665. /**
  33666. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33667. */
  33668. autoClear: boolean;
  33669. /**
  33670. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33671. */
  33672. autoClearDepthAndStencil: boolean;
  33673. /**
  33674. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33675. */
  33676. clearColor: Color4;
  33677. /**
  33678. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33679. */
  33680. ambientColor: Color3;
  33681. /**
  33682. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33683. * It should only be one of the following (if not the default embedded one):
  33684. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33685. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33686. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33687. * The material properties need to be setup according to the type of texture in use.
  33688. */
  33689. environmentBRDFTexture: BaseTexture;
  33690. /** @hidden */
  33691. protected _environmentTexture: Nullable<BaseTexture>;
  33692. /**
  33693. * Texture used in all pbr material as the reflection texture.
  33694. * As in the majority of the scene they are the same (exception for multi room and so on),
  33695. * this is easier to reference from here than from all the materials.
  33696. */
  33697. /**
  33698. * Texture used in all pbr material as the reflection texture.
  33699. * As in the majority of the scene they are the same (exception for multi room and so on),
  33700. * this is easier to set here than in all the materials.
  33701. */
  33702. environmentTexture: Nullable<BaseTexture>;
  33703. /** @hidden */
  33704. protected _environmentIntensity: number;
  33705. /**
  33706. * Intensity of the environment in all pbr material.
  33707. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33708. * As in the majority of the scene they are the same (exception for multi room and so on),
  33709. * this is easier to reference from here than from all the materials.
  33710. */
  33711. /**
  33712. * Intensity of the environment in all pbr material.
  33713. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33714. * As in the majority of the scene they are the same (exception for multi room and so on),
  33715. * this is easier to set here than in all the materials.
  33716. */
  33717. environmentIntensity: number;
  33718. /** @hidden */
  33719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33720. /**
  33721. * Default image processing configuration used either in the rendering
  33722. * Forward main pass or through the imageProcessingPostProcess if present.
  33723. * As in the majority of the scene they are the same (exception for multi camera),
  33724. * this is easier to reference from here than from all the materials and post process.
  33725. *
  33726. * No setter as we it is a shared configuration, you can set the values instead.
  33727. */
  33728. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33729. private _forceWireframe;
  33730. /**
  33731. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33732. */
  33733. forceWireframe: boolean;
  33734. private _forcePointsCloud;
  33735. /**
  33736. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33737. */
  33738. forcePointsCloud: boolean;
  33739. /**
  33740. * Gets or sets the active clipplane 1
  33741. */
  33742. clipPlane: Nullable<Plane>;
  33743. /**
  33744. * Gets or sets the active clipplane 2
  33745. */
  33746. clipPlane2: Nullable<Plane>;
  33747. /**
  33748. * Gets or sets the active clipplane 3
  33749. */
  33750. clipPlane3: Nullable<Plane>;
  33751. /**
  33752. * Gets or sets the active clipplane 4
  33753. */
  33754. clipPlane4: Nullable<Plane>;
  33755. /**
  33756. * Gets or sets a boolean indicating if animations are enabled
  33757. */
  33758. animationsEnabled: boolean;
  33759. private _animationPropertiesOverride;
  33760. /**
  33761. * Gets or sets the animation properties override
  33762. */
  33763. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33764. /**
  33765. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33766. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33767. */
  33768. useConstantAnimationDeltaTime: boolean;
  33769. /**
  33770. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33771. * Please note that it requires to run a ray cast through the scene on every frame
  33772. */
  33773. constantlyUpdateMeshUnderPointer: boolean;
  33774. /**
  33775. * Defines the HTML cursor to use when hovering over interactive elements
  33776. */
  33777. hoverCursor: string;
  33778. /**
  33779. * Defines the HTML default cursor to use (empty by default)
  33780. */
  33781. defaultCursor: string;
  33782. /**
  33783. * This is used to call preventDefault() on pointer down
  33784. * in order to block unwanted artifacts like system double clicks
  33785. */
  33786. preventDefaultOnPointerDown: boolean;
  33787. /**
  33788. * This is used to call preventDefault() on pointer up
  33789. * in order to block unwanted artifacts like system double clicks
  33790. */
  33791. preventDefaultOnPointerUp: boolean;
  33792. /**
  33793. * Gets or sets user defined metadata
  33794. */
  33795. metadata: any;
  33796. /**
  33797. * For internal use only. Please do not use.
  33798. */
  33799. reservedDataStore: any;
  33800. /**
  33801. * Gets the name of the plugin used to load this scene (null by default)
  33802. */
  33803. loadingPluginName: string;
  33804. /**
  33805. * Use this array to add regular expressions used to disable offline support for specific urls
  33806. */
  33807. disableOfflineSupportExceptionRules: RegExp[];
  33808. /**
  33809. * An event triggered when the scene is disposed.
  33810. */
  33811. onDisposeObservable: Observable<Scene>;
  33812. private _onDisposeObserver;
  33813. /** Sets a function to be executed when this scene is disposed. */
  33814. onDispose: () => void;
  33815. /**
  33816. * An event triggered before rendering the scene (right after animations and physics)
  33817. */
  33818. onBeforeRenderObservable: Observable<Scene>;
  33819. private _onBeforeRenderObserver;
  33820. /** Sets a function to be executed before rendering this scene */
  33821. beforeRender: Nullable<() => void>;
  33822. /**
  33823. * An event triggered after rendering the scene
  33824. */
  33825. onAfterRenderObservable: Observable<Scene>;
  33826. /**
  33827. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33828. */
  33829. onAfterRenderCameraObservable: Observable<Camera>;
  33830. private _onAfterRenderObserver;
  33831. /** Sets a function to be executed after rendering this scene */
  33832. afterRender: Nullable<() => void>;
  33833. /**
  33834. * An event triggered before animating the scene
  33835. */
  33836. onBeforeAnimationsObservable: Observable<Scene>;
  33837. /**
  33838. * An event triggered after animations processing
  33839. */
  33840. onAfterAnimationsObservable: Observable<Scene>;
  33841. /**
  33842. * An event triggered before draw calls are ready to be sent
  33843. */
  33844. onBeforeDrawPhaseObservable: Observable<Scene>;
  33845. /**
  33846. * An event triggered after draw calls have been sent
  33847. */
  33848. onAfterDrawPhaseObservable: Observable<Scene>;
  33849. /**
  33850. * An event triggered when the scene is ready
  33851. */
  33852. onReadyObservable: Observable<Scene>;
  33853. /**
  33854. * An event triggered before rendering a camera
  33855. */
  33856. onBeforeCameraRenderObservable: Observable<Camera>;
  33857. private _onBeforeCameraRenderObserver;
  33858. /** Sets a function to be executed before rendering a camera*/
  33859. beforeCameraRender: () => void;
  33860. /**
  33861. * An event triggered after rendering a camera
  33862. */
  33863. onAfterCameraRenderObservable: Observable<Camera>;
  33864. private _onAfterCameraRenderObserver;
  33865. /** Sets a function to be executed after rendering a camera*/
  33866. afterCameraRender: () => void;
  33867. /**
  33868. * An event triggered when active meshes evaluation is about to start
  33869. */
  33870. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33871. /**
  33872. * An event triggered when active meshes evaluation is done
  33873. */
  33874. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33875. /**
  33876. * An event triggered when particles rendering is about to start
  33877. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33878. */
  33879. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33880. /**
  33881. * An event triggered when particles rendering is done
  33882. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33883. */
  33884. onAfterParticlesRenderingObservable: Observable<Scene>;
  33885. /**
  33886. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33887. */
  33888. onDataLoadedObservable: Observable<Scene>;
  33889. /**
  33890. * An event triggered when a camera is created
  33891. */
  33892. onNewCameraAddedObservable: Observable<Camera>;
  33893. /**
  33894. * An event triggered when a camera is removed
  33895. */
  33896. onCameraRemovedObservable: Observable<Camera>;
  33897. /**
  33898. * An event triggered when a light is created
  33899. */
  33900. onNewLightAddedObservable: Observable<Light>;
  33901. /**
  33902. * An event triggered when a light is removed
  33903. */
  33904. onLightRemovedObservable: Observable<Light>;
  33905. /**
  33906. * An event triggered when a geometry is created
  33907. */
  33908. onNewGeometryAddedObservable: Observable<Geometry>;
  33909. /**
  33910. * An event triggered when a geometry is removed
  33911. */
  33912. onGeometryRemovedObservable: Observable<Geometry>;
  33913. /**
  33914. * An event triggered when a transform node is created
  33915. */
  33916. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33917. /**
  33918. * An event triggered when a transform node is removed
  33919. */
  33920. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33921. /**
  33922. * An event triggered when a mesh is created
  33923. */
  33924. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33925. /**
  33926. * An event triggered when a mesh is removed
  33927. */
  33928. onMeshRemovedObservable: Observable<AbstractMesh>;
  33929. /**
  33930. * An event triggered when a skeleton is created
  33931. */
  33932. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33933. /**
  33934. * An event triggered when a skeleton is removed
  33935. */
  33936. onSkeletonRemovedObservable: Observable<Skeleton>;
  33937. /**
  33938. * An event triggered when a material is created
  33939. */
  33940. onNewMaterialAddedObservable: Observable<Material>;
  33941. /**
  33942. * An event triggered when a material is removed
  33943. */
  33944. onMaterialRemovedObservable: Observable<Material>;
  33945. /**
  33946. * An event triggered when a texture is created
  33947. */
  33948. onNewTextureAddedObservable: Observable<BaseTexture>;
  33949. /**
  33950. * An event triggered when a texture is removed
  33951. */
  33952. onTextureRemovedObservable: Observable<BaseTexture>;
  33953. /**
  33954. * An event triggered when render targets are about to be rendered
  33955. * Can happen multiple times per frame.
  33956. */
  33957. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33958. /**
  33959. * An event triggered when render targets were rendered.
  33960. * Can happen multiple times per frame.
  33961. */
  33962. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33963. /**
  33964. * An event triggered before calculating deterministic simulation step
  33965. */
  33966. onBeforeStepObservable: Observable<Scene>;
  33967. /**
  33968. * An event triggered after calculating deterministic simulation step
  33969. */
  33970. onAfterStepObservable: Observable<Scene>;
  33971. /**
  33972. * An event triggered when the activeCamera property is updated
  33973. */
  33974. onActiveCameraChanged: Observable<Scene>;
  33975. /**
  33976. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33977. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33978. * 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)
  33979. */
  33980. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33981. /**
  33982. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33983. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33984. * 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)
  33985. */
  33986. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33987. /**
  33988. * This Observable will when a mesh has been imported into the scene.
  33989. */
  33990. onMeshImportedObservable: Observable<AbstractMesh>;
  33991. /**
  33992. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33993. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33994. */
  33995. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33996. /** @hidden */
  33997. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33998. /**
  33999. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34000. */
  34001. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34002. /**
  34003. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34004. */
  34005. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34006. /**
  34007. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34008. */
  34009. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34010. /** Callback called when a pointer move is detected */
  34011. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34012. /** Callback called when a pointer down is detected */
  34013. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34014. /** Callback called when a pointer up is detected */
  34015. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34016. /** Callback called when a pointer pick is detected */
  34017. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34018. /**
  34019. * 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).
  34020. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34021. */
  34022. onPrePointerObservable: Observable<PointerInfoPre>;
  34023. /**
  34024. * Observable event triggered each time an input event is received from the rendering canvas
  34025. */
  34026. onPointerObservable: Observable<PointerInfo>;
  34027. /**
  34028. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34029. */
  34030. readonly unTranslatedPointer: Vector2;
  34031. /**
  34032. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34033. */
  34034. static DragMovementThreshold: number;
  34035. /**
  34036. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34037. */
  34038. static LongPressDelay: number;
  34039. /**
  34040. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34041. */
  34042. static DoubleClickDelay: number;
  34043. /** If you need to check double click without raising a single click at first click, enable this flag */
  34044. static ExclusiveDoubleClickMode: boolean;
  34045. /** @hidden */
  34046. _mirroredCameraPosition: Nullable<Vector3>;
  34047. /**
  34048. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34049. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34050. */
  34051. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34052. /**
  34053. * Observable event triggered each time an keyboard event is received from the hosting window
  34054. */
  34055. onKeyboardObservable: Observable<KeyboardInfo>;
  34056. private _useRightHandedSystem;
  34057. /**
  34058. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34059. */
  34060. useRightHandedSystem: boolean;
  34061. private _timeAccumulator;
  34062. private _currentStepId;
  34063. private _currentInternalStep;
  34064. /**
  34065. * Sets the step Id used by deterministic lock step
  34066. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34067. * @param newStepId defines the step Id
  34068. */
  34069. setStepId(newStepId: number): void;
  34070. /**
  34071. * Gets the step Id used by deterministic lock step
  34072. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34073. * @returns the step Id
  34074. */
  34075. getStepId(): number;
  34076. /**
  34077. * Gets the internal step used by deterministic lock step
  34078. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34079. * @returns the internal step
  34080. */
  34081. getInternalStep(): number;
  34082. private _fogEnabled;
  34083. /**
  34084. * Gets or sets a boolean indicating if fog is enabled on this scene
  34085. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34086. * (Default is true)
  34087. */
  34088. fogEnabled: boolean;
  34089. private _fogMode;
  34090. /**
  34091. * Gets or sets the fog mode to use
  34092. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34093. * | mode | value |
  34094. * | --- | --- |
  34095. * | FOGMODE_NONE | 0 |
  34096. * | FOGMODE_EXP | 1 |
  34097. * | FOGMODE_EXP2 | 2 |
  34098. * | FOGMODE_LINEAR | 3 |
  34099. */
  34100. fogMode: number;
  34101. /**
  34102. * Gets or sets the fog color to use
  34103. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34104. * (Default is Color3(0.2, 0.2, 0.3))
  34105. */
  34106. fogColor: Color3;
  34107. /**
  34108. * Gets or sets the fog density to use
  34109. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34110. * (Default is 0.1)
  34111. */
  34112. fogDensity: number;
  34113. /**
  34114. * Gets or sets the fog start distance to use
  34115. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34116. * (Default is 0)
  34117. */
  34118. fogStart: number;
  34119. /**
  34120. * Gets or sets the fog end distance to use
  34121. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34122. * (Default is 1000)
  34123. */
  34124. fogEnd: number;
  34125. private _shadowsEnabled;
  34126. /**
  34127. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34128. */
  34129. shadowsEnabled: boolean;
  34130. private _lightsEnabled;
  34131. /**
  34132. * Gets or sets a boolean indicating if lights are enabled on this scene
  34133. */
  34134. lightsEnabled: boolean;
  34135. /** All of the active cameras added to this scene. */
  34136. activeCameras: Camera[];
  34137. /** @hidden */
  34138. _activeCamera: Nullable<Camera>;
  34139. /** Gets or sets the current active camera */
  34140. activeCamera: Nullable<Camera>;
  34141. private _defaultMaterial;
  34142. /** The default material used on meshes when no material is affected */
  34143. /** The default material used on meshes when no material is affected */
  34144. defaultMaterial: Material;
  34145. private _texturesEnabled;
  34146. /**
  34147. * Gets or sets a boolean indicating if textures are enabled on this scene
  34148. */
  34149. texturesEnabled: boolean;
  34150. /**
  34151. * Gets or sets a boolean indicating if particles are enabled on this scene
  34152. */
  34153. particlesEnabled: boolean;
  34154. /**
  34155. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34156. */
  34157. spritesEnabled: boolean;
  34158. private _skeletonsEnabled;
  34159. /**
  34160. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34161. */
  34162. skeletonsEnabled: boolean;
  34163. /**
  34164. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34165. */
  34166. lensFlaresEnabled: boolean;
  34167. /**
  34168. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34169. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34170. */
  34171. collisionsEnabled: boolean;
  34172. private _collisionCoordinator;
  34173. /** @hidden */
  34174. readonly collisionCoordinator: ICollisionCoordinator;
  34175. /**
  34176. * Defines the gravity applied to this scene (used only for collisions)
  34177. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34178. */
  34179. gravity: Vector3;
  34180. /**
  34181. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34182. */
  34183. postProcessesEnabled: boolean;
  34184. /**
  34185. * The list of postprocesses added to the scene
  34186. */
  34187. postProcesses: PostProcess[];
  34188. /**
  34189. * Gets the current postprocess manager
  34190. */
  34191. postProcessManager: PostProcessManager;
  34192. /**
  34193. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34194. */
  34195. renderTargetsEnabled: boolean;
  34196. /**
  34197. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34198. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34199. */
  34200. dumpNextRenderTargets: boolean;
  34201. /**
  34202. * The list of user defined render targets added to the scene
  34203. */
  34204. customRenderTargets: RenderTargetTexture[];
  34205. /**
  34206. * Defines if texture loading must be delayed
  34207. * If true, textures will only be loaded when they need to be rendered
  34208. */
  34209. useDelayedTextureLoading: boolean;
  34210. /**
  34211. * Gets the list of meshes imported to the scene through SceneLoader
  34212. */
  34213. importedMeshesFiles: String[];
  34214. /**
  34215. * Gets or sets a boolean indicating if probes are enabled on this scene
  34216. */
  34217. probesEnabled: boolean;
  34218. /**
  34219. * Gets or sets the current offline provider to use to store scene data
  34220. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34221. */
  34222. offlineProvider: IOfflineProvider;
  34223. /**
  34224. * Gets or sets the action manager associated with the scene
  34225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34226. */
  34227. actionManager: AbstractActionManager;
  34228. private _meshesForIntersections;
  34229. /**
  34230. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34231. */
  34232. proceduralTexturesEnabled: boolean;
  34233. private _engine;
  34234. private _totalVertices;
  34235. /** @hidden */
  34236. _activeIndices: PerfCounter;
  34237. /** @hidden */
  34238. _activeParticles: PerfCounter;
  34239. /** @hidden */
  34240. _activeBones: PerfCounter;
  34241. private _animationRatio;
  34242. /** @hidden */
  34243. _animationTimeLast: number;
  34244. /** @hidden */
  34245. _animationTime: number;
  34246. /**
  34247. * Gets or sets a general scale for animation speed
  34248. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34249. */
  34250. animationTimeScale: number;
  34251. /** @hidden */
  34252. _cachedMaterial: Nullable<Material>;
  34253. /** @hidden */
  34254. _cachedEffect: Nullable<Effect>;
  34255. /** @hidden */
  34256. _cachedVisibility: Nullable<number>;
  34257. private _renderId;
  34258. private _frameId;
  34259. private _executeWhenReadyTimeoutId;
  34260. private _intermediateRendering;
  34261. private _viewUpdateFlag;
  34262. private _projectionUpdateFlag;
  34263. /** @hidden */
  34264. _toBeDisposed: Nullable<IDisposable>[];
  34265. private _activeRequests;
  34266. /** @hidden */
  34267. _pendingData: any[];
  34268. private _isDisposed;
  34269. /**
  34270. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34271. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34272. */
  34273. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34274. private _activeMeshes;
  34275. private _processedMaterials;
  34276. private _renderTargets;
  34277. /** @hidden */
  34278. _activeParticleSystems: SmartArray<IParticleSystem>;
  34279. private _activeSkeletons;
  34280. private _softwareSkinnedMeshes;
  34281. private _renderingManager;
  34282. /** @hidden */
  34283. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34284. private _transformMatrix;
  34285. private _sceneUbo;
  34286. /** @hidden */
  34287. _viewMatrix: Matrix;
  34288. private _projectionMatrix;
  34289. /** @hidden */
  34290. _forcedViewPosition: Nullable<Vector3>;
  34291. /** @hidden */
  34292. _frustumPlanes: Plane[];
  34293. /**
  34294. * Gets the list of frustum planes (built from the active camera)
  34295. */
  34296. readonly frustumPlanes: Plane[];
  34297. /**
  34298. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34299. * This is useful if there are more lights that the maximum simulteanous authorized
  34300. */
  34301. requireLightSorting: boolean;
  34302. /** @hidden */
  34303. readonly useMaterialMeshMap: boolean;
  34304. /** @hidden */
  34305. readonly useClonedMeshhMap: boolean;
  34306. private _externalData;
  34307. private _uid;
  34308. /**
  34309. * @hidden
  34310. * Backing store of defined scene components.
  34311. */
  34312. _components: ISceneComponent[];
  34313. /**
  34314. * @hidden
  34315. * Backing store of defined scene components.
  34316. */
  34317. _serializableComponents: ISceneSerializableComponent[];
  34318. /**
  34319. * List of components to register on the next registration step.
  34320. */
  34321. private _transientComponents;
  34322. /**
  34323. * Registers the transient components if needed.
  34324. */
  34325. private _registerTransientComponents;
  34326. /**
  34327. * @hidden
  34328. * Add a component to the scene.
  34329. * Note that the ccomponent could be registered on th next frame if this is called after
  34330. * the register component stage.
  34331. * @param component Defines the component to add to the scene
  34332. */
  34333. _addComponent(component: ISceneComponent): void;
  34334. /**
  34335. * @hidden
  34336. * Gets a component from the scene.
  34337. * @param name defines the name of the component to retrieve
  34338. * @returns the component or null if not present
  34339. */
  34340. _getComponent(name: string): Nullable<ISceneComponent>;
  34341. /**
  34342. * @hidden
  34343. * Defines the actions happening before camera updates.
  34344. */
  34345. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34346. /**
  34347. * @hidden
  34348. * Defines the actions happening before clear the canvas.
  34349. */
  34350. _beforeClearStage: Stage<SimpleStageAction>;
  34351. /**
  34352. * @hidden
  34353. * Defines the actions when collecting render targets for the frame.
  34354. */
  34355. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34356. /**
  34357. * @hidden
  34358. * Defines the actions happening for one camera in the frame.
  34359. */
  34360. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34361. /**
  34362. * @hidden
  34363. * Defines the actions happening during the per mesh ready checks.
  34364. */
  34365. _isReadyForMeshStage: Stage<MeshStageAction>;
  34366. /**
  34367. * @hidden
  34368. * Defines the actions happening before evaluate active mesh checks.
  34369. */
  34370. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34371. /**
  34372. * @hidden
  34373. * Defines the actions happening during the evaluate sub mesh checks.
  34374. */
  34375. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34376. /**
  34377. * @hidden
  34378. * Defines the actions happening during the active mesh stage.
  34379. */
  34380. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34381. /**
  34382. * @hidden
  34383. * Defines the actions happening during the per camera render target step.
  34384. */
  34385. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34386. /**
  34387. * @hidden
  34388. * Defines the actions happening just before the active camera is drawing.
  34389. */
  34390. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34391. /**
  34392. * @hidden
  34393. * Defines the actions happening just before a render target is drawing.
  34394. */
  34395. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34396. /**
  34397. * @hidden
  34398. * Defines the actions happening just before a rendering group is drawing.
  34399. */
  34400. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34401. /**
  34402. * @hidden
  34403. * Defines the actions happening just before a mesh is drawing.
  34404. */
  34405. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34406. /**
  34407. * @hidden
  34408. * Defines the actions happening just after a mesh has been drawn.
  34409. */
  34410. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34411. /**
  34412. * @hidden
  34413. * Defines the actions happening just after a rendering group has been drawn.
  34414. */
  34415. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34416. /**
  34417. * @hidden
  34418. * Defines the actions happening just after the active camera has been drawn.
  34419. */
  34420. _afterCameraDrawStage: Stage<CameraStageAction>;
  34421. /**
  34422. * @hidden
  34423. * Defines the actions happening just after a render target has been drawn.
  34424. */
  34425. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34426. /**
  34427. * @hidden
  34428. * Defines the actions happening just after rendering all cameras and computing intersections.
  34429. */
  34430. _afterRenderStage: Stage<SimpleStageAction>;
  34431. /**
  34432. * @hidden
  34433. * Defines the actions happening when a pointer move event happens.
  34434. */
  34435. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34436. /**
  34437. * @hidden
  34438. * Defines the actions happening when a pointer down event happens.
  34439. */
  34440. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34441. /**
  34442. * @hidden
  34443. * Defines the actions happening when a pointer up event happens.
  34444. */
  34445. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34446. /**
  34447. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34448. */
  34449. private geometriesByUniqueId;
  34450. /**
  34451. * Creates a new Scene
  34452. * @param engine defines the engine to use to render this scene
  34453. * @param options defines the scene options
  34454. */
  34455. constructor(engine: Engine, options?: SceneOptions);
  34456. /**
  34457. * Gets a string idenfifying the name of the class
  34458. * @returns "Scene" string
  34459. */
  34460. getClassName(): string;
  34461. private _defaultMeshCandidates;
  34462. /**
  34463. * @hidden
  34464. */
  34465. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34466. private _defaultSubMeshCandidates;
  34467. /**
  34468. * @hidden
  34469. */
  34470. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34471. /**
  34472. * Sets the default candidate providers for the scene.
  34473. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34474. * and getCollidingSubMeshCandidates to their default function
  34475. */
  34476. setDefaultCandidateProviders(): void;
  34477. /**
  34478. * Gets the mesh that is currently under the pointer
  34479. */
  34480. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34481. /**
  34482. * Gets or sets the current on-screen X position of the pointer
  34483. */
  34484. pointerX: number;
  34485. /**
  34486. * Gets or sets the current on-screen Y position of the pointer
  34487. */
  34488. pointerY: number;
  34489. /**
  34490. * Gets the cached material (ie. the latest rendered one)
  34491. * @returns the cached material
  34492. */
  34493. getCachedMaterial(): Nullable<Material>;
  34494. /**
  34495. * Gets the cached effect (ie. the latest rendered one)
  34496. * @returns the cached effect
  34497. */
  34498. getCachedEffect(): Nullable<Effect>;
  34499. /**
  34500. * Gets the cached visibility state (ie. the latest rendered one)
  34501. * @returns the cached visibility state
  34502. */
  34503. getCachedVisibility(): Nullable<number>;
  34504. /**
  34505. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34506. * @param material defines the current material
  34507. * @param effect defines the current effect
  34508. * @param visibility defines the current visibility state
  34509. * @returns true if one parameter is not cached
  34510. */
  34511. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34512. /**
  34513. * Gets the engine associated with the scene
  34514. * @returns an Engine
  34515. */
  34516. getEngine(): Engine;
  34517. /**
  34518. * Gets the total number of vertices rendered per frame
  34519. * @returns the total number of vertices rendered per frame
  34520. */
  34521. getTotalVertices(): number;
  34522. /**
  34523. * Gets the performance counter for total vertices
  34524. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34525. */
  34526. readonly totalVerticesPerfCounter: PerfCounter;
  34527. /**
  34528. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34529. * @returns the total number of active indices rendered per frame
  34530. */
  34531. getActiveIndices(): number;
  34532. /**
  34533. * Gets the performance counter for active indices
  34534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34535. */
  34536. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34537. /**
  34538. * Gets the total number of active particles rendered per frame
  34539. * @returns the total number of active particles rendered per frame
  34540. */
  34541. getActiveParticles(): number;
  34542. /**
  34543. * Gets the performance counter for active particles
  34544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34545. */
  34546. readonly activeParticlesPerfCounter: PerfCounter;
  34547. /**
  34548. * Gets the total number of active bones rendered per frame
  34549. * @returns the total number of active bones rendered per frame
  34550. */
  34551. getActiveBones(): number;
  34552. /**
  34553. * Gets the performance counter for active bones
  34554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34555. */
  34556. readonly activeBonesPerfCounter: PerfCounter;
  34557. /**
  34558. * Gets the array of active meshes
  34559. * @returns an array of AbstractMesh
  34560. */
  34561. getActiveMeshes(): SmartArray<AbstractMesh>;
  34562. /**
  34563. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34564. * @returns a number
  34565. */
  34566. getAnimationRatio(): number;
  34567. /**
  34568. * Gets an unique Id for the current render phase
  34569. * @returns a number
  34570. */
  34571. getRenderId(): number;
  34572. /**
  34573. * Gets an unique Id for the current frame
  34574. * @returns a number
  34575. */
  34576. getFrameId(): number;
  34577. /** Call this function if you want to manually increment the render Id*/
  34578. incrementRenderId(): void;
  34579. private _createUbo;
  34580. /**
  34581. * Use this method to simulate a pointer move on a mesh
  34582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34585. * @returns the current scene
  34586. */
  34587. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34588. /**
  34589. * Use this method to simulate a pointer down on a mesh
  34590. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34591. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34592. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34593. * @returns the current scene
  34594. */
  34595. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34596. /**
  34597. * Use this method to simulate a pointer up on a mesh
  34598. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34599. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34600. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34601. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34602. * @returns the current scene
  34603. */
  34604. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34605. /**
  34606. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34607. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34608. * @returns true if the pointer was captured
  34609. */
  34610. isPointerCaptured(pointerId?: number): boolean;
  34611. /**
  34612. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34613. * @param attachUp defines if you want to attach events to pointerup
  34614. * @param attachDown defines if you want to attach events to pointerdown
  34615. * @param attachMove defines if you want to attach events to pointermove
  34616. */
  34617. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34618. /** Detaches all event handlers*/
  34619. detachControl(): void;
  34620. /**
  34621. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34622. * Delay loaded resources are not taking in account
  34623. * @return true if all required resources are ready
  34624. */
  34625. isReady(): boolean;
  34626. /** Resets all cached information relative to material (including effect and visibility) */
  34627. resetCachedMaterial(): void;
  34628. /**
  34629. * Registers a function to be called before every frame render
  34630. * @param func defines the function to register
  34631. */
  34632. registerBeforeRender(func: () => void): void;
  34633. /**
  34634. * Unregisters a function called before every frame render
  34635. * @param func defines the function to unregister
  34636. */
  34637. unregisterBeforeRender(func: () => void): void;
  34638. /**
  34639. * Registers a function to be called after every frame render
  34640. * @param func defines the function to register
  34641. */
  34642. registerAfterRender(func: () => void): void;
  34643. /**
  34644. * Unregisters a function called after every frame render
  34645. * @param func defines the function to unregister
  34646. */
  34647. unregisterAfterRender(func: () => void): void;
  34648. private _executeOnceBeforeRender;
  34649. /**
  34650. * The provided function will run before render once and will be disposed afterwards.
  34651. * A timeout delay can be provided so that the function will be executed in N ms.
  34652. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34653. * @param func The function to be executed.
  34654. * @param timeout optional delay in ms
  34655. */
  34656. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34657. /** @hidden */
  34658. _addPendingData(data: any): void;
  34659. /** @hidden */
  34660. _removePendingData(data: any): void;
  34661. /**
  34662. * Returns the number of items waiting to be loaded
  34663. * @returns the number of items waiting to be loaded
  34664. */
  34665. getWaitingItemsCount(): number;
  34666. /**
  34667. * Returns a boolean indicating if the scene is still loading data
  34668. */
  34669. readonly isLoading: boolean;
  34670. /**
  34671. * Registers a function to be executed when the scene is ready
  34672. * @param {Function} func - the function to be executed
  34673. */
  34674. executeWhenReady(func: () => void): void;
  34675. /**
  34676. * Returns a promise that resolves when the scene is ready
  34677. * @returns A promise that resolves when the scene is ready
  34678. */
  34679. whenReadyAsync(): Promise<void>;
  34680. /** @hidden */
  34681. _checkIsReady(): void;
  34682. /**
  34683. * Gets all animatable attached to the scene
  34684. */
  34685. readonly animatables: Animatable[];
  34686. /**
  34687. * Resets the last animation time frame.
  34688. * Useful to override when animations start running when loading a scene for the first time.
  34689. */
  34690. resetLastAnimationTimeFrame(): void;
  34691. /**
  34692. * Gets the current view matrix
  34693. * @returns a Matrix
  34694. */
  34695. getViewMatrix(): Matrix;
  34696. /**
  34697. * Gets the current projection matrix
  34698. * @returns a Matrix
  34699. */
  34700. getProjectionMatrix(): Matrix;
  34701. /**
  34702. * Gets the current transform matrix
  34703. * @returns a Matrix made of View * Projection
  34704. */
  34705. getTransformMatrix(): Matrix;
  34706. /**
  34707. * Sets the current transform matrix
  34708. * @param viewL defines the View matrix to use
  34709. * @param projectionL defines the Projection matrix to use
  34710. * @param viewR defines the right View matrix to use (if provided)
  34711. * @param projectionR defines the right Projection matrix to use (if provided)
  34712. */
  34713. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34714. /**
  34715. * Gets the uniform buffer used to store scene data
  34716. * @returns a UniformBuffer
  34717. */
  34718. getSceneUniformBuffer(): UniformBuffer;
  34719. /**
  34720. * Gets an unique (relatively to the current scene) Id
  34721. * @returns an unique number for the scene
  34722. */
  34723. getUniqueId(): number;
  34724. /**
  34725. * Add a mesh to the list of scene's meshes
  34726. * @param newMesh defines the mesh to add
  34727. * @param recursive if all child meshes should also be added to the scene
  34728. */
  34729. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34730. /**
  34731. * Remove a mesh for the list of scene's meshes
  34732. * @param toRemove defines the mesh to remove
  34733. * @param recursive if all child meshes should also be removed from the scene
  34734. * @returns the index where the mesh was in the mesh list
  34735. */
  34736. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34737. /**
  34738. * Add a transform node to the list of scene's transform nodes
  34739. * @param newTransformNode defines the transform node to add
  34740. */
  34741. addTransformNode(newTransformNode: TransformNode): void;
  34742. /**
  34743. * Remove a transform node for the list of scene's transform nodes
  34744. * @param toRemove defines the transform node to remove
  34745. * @returns the index where the transform node was in the transform node list
  34746. */
  34747. removeTransformNode(toRemove: TransformNode): number;
  34748. /**
  34749. * Remove a skeleton for the list of scene's skeletons
  34750. * @param toRemove defines the skeleton to remove
  34751. * @returns the index where the skeleton was in the skeleton list
  34752. */
  34753. removeSkeleton(toRemove: Skeleton): number;
  34754. /**
  34755. * Remove a morph target for the list of scene's morph targets
  34756. * @param toRemove defines the morph target to remove
  34757. * @returns the index where the morph target was in the morph target list
  34758. */
  34759. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34760. /**
  34761. * Remove a light for the list of scene's lights
  34762. * @param toRemove defines the light to remove
  34763. * @returns the index where the light was in the light list
  34764. */
  34765. removeLight(toRemove: Light): number;
  34766. /**
  34767. * Remove a camera for the list of scene's cameras
  34768. * @param toRemove defines the camera to remove
  34769. * @returns the index where the camera was in the camera list
  34770. */
  34771. removeCamera(toRemove: Camera): number;
  34772. /**
  34773. * Remove a particle system for the list of scene's particle systems
  34774. * @param toRemove defines the particle system to remove
  34775. * @returns the index where the particle system was in the particle system list
  34776. */
  34777. removeParticleSystem(toRemove: IParticleSystem): number;
  34778. /**
  34779. * Remove a animation for the list of scene's animations
  34780. * @param toRemove defines the animation to remove
  34781. * @returns the index where the animation was in the animation list
  34782. */
  34783. removeAnimation(toRemove: Animation): number;
  34784. /**
  34785. * Will stop the animation of the given target
  34786. * @param target - the target
  34787. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34788. * @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)
  34789. */
  34790. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34791. /**
  34792. * Removes the given animation group from this scene.
  34793. * @param toRemove The animation group to remove
  34794. * @returns The index of the removed animation group
  34795. */
  34796. removeAnimationGroup(toRemove: AnimationGroup): number;
  34797. /**
  34798. * Removes the given multi-material from this scene.
  34799. * @param toRemove The multi-material to remove
  34800. * @returns The index of the removed multi-material
  34801. */
  34802. removeMultiMaterial(toRemove: MultiMaterial): number;
  34803. /**
  34804. * Removes the given material from this scene.
  34805. * @param toRemove The material to remove
  34806. * @returns The index of the removed material
  34807. */
  34808. removeMaterial(toRemove: Material): number;
  34809. /**
  34810. * Removes the given action manager from this scene.
  34811. * @param toRemove The action manager to remove
  34812. * @returns The index of the removed action manager
  34813. */
  34814. removeActionManager(toRemove: AbstractActionManager): number;
  34815. /**
  34816. * Removes the given texture from this scene.
  34817. * @param toRemove The texture to remove
  34818. * @returns The index of the removed texture
  34819. */
  34820. removeTexture(toRemove: BaseTexture): number;
  34821. /**
  34822. * Adds the given light to this scene
  34823. * @param newLight The light to add
  34824. */
  34825. addLight(newLight: Light): void;
  34826. /**
  34827. * Sorts the list list based on light priorities
  34828. */
  34829. sortLightsByPriority(): void;
  34830. /**
  34831. * Adds the given camera to this scene
  34832. * @param newCamera The camera to add
  34833. */
  34834. addCamera(newCamera: Camera): void;
  34835. /**
  34836. * Adds the given skeleton to this scene
  34837. * @param newSkeleton The skeleton to add
  34838. */
  34839. addSkeleton(newSkeleton: Skeleton): void;
  34840. /**
  34841. * Adds the given particle system to this scene
  34842. * @param newParticleSystem The particle system to add
  34843. */
  34844. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34845. /**
  34846. * Adds the given animation to this scene
  34847. * @param newAnimation The animation to add
  34848. */
  34849. addAnimation(newAnimation: Animation): void;
  34850. /**
  34851. * Adds the given animation group to this scene.
  34852. * @param newAnimationGroup The animation group to add
  34853. */
  34854. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34855. /**
  34856. * Adds the given multi-material to this scene
  34857. * @param newMultiMaterial The multi-material to add
  34858. */
  34859. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34860. /**
  34861. * Adds the given material to this scene
  34862. * @param newMaterial The material to add
  34863. */
  34864. addMaterial(newMaterial: Material): void;
  34865. /**
  34866. * Adds the given morph target to this scene
  34867. * @param newMorphTargetManager The morph target to add
  34868. */
  34869. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34870. /**
  34871. * Adds the given geometry to this scene
  34872. * @param newGeometry The geometry to add
  34873. */
  34874. addGeometry(newGeometry: Geometry): void;
  34875. /**
  34876. * Adds the given action manager to this scene
  34877. * @param newActionManager The action manager to add
  34878. */
  34879. addActionManager(newActionManager: AbstractActionManager): void;
  34880. /**
  34881. * Adds the given texture to this scene.
  34882. * @param newTexture The texture to add
  34883. */
  34884. addTexture(newTexture: BaseTexture): void;
  34885. /**
  34886. * Switch active camera
  34887. * @param newCamera defines the new active camera
  34888. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34889. */
  34890. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34891. /**
  34892. * sets the active camera of the scene using its ID
  34893. * @param id defines the camera's ID
  34894. * @return the new active camera or null if none found.
  34895. */
  34896. setActiveCameraByID(id: string): Nullable<Camera>;
  34897. /**
  34898. * sets the active camera of the scene using its name
  34899. * @param name defines the camera's name
  34900. * @returns the new active camera or null if none found.
  34901. */
  34902. setActiveCameraByName(name: string): Nullable<Camera>;
  34903. /**
  34904. * get an animation group using its name
  34905. * @param name defines the material's name
  34906. * @return the animation group or null if none found.
  34907. */
  34908. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34909. /**
  34910. * Get a material using its unique id
  34911. * @param uniqueId defines the material's unique id
  34912. * @return the material or null if none found.
  34913. */
  34914. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34915. /**
  34916. * get a material using its id
  34917. * @param id defines the material's ID
  34918. * @return the material or null if none found.
  34919. */
  34920. getMaterialByID(id: string): Nullable<Material>;
  34921. /**
  34922. * Gets a the last added material using a given id
  34923. * @param id defines the material's ID
  34924. * @return the last material with the given id or null if none found.
  34925. */
  34926. getLastMaterialByID(id: string): Nullable<Material>;
  34927. /**
  34928. * Gets a material using its name
  34929. * @param name defines the material's name
  34930. * @return the material or null if none found.
  34931. */
  34932. getMaterialByName(name: string): Nullable<Material>;
  34933. /**
  34934. * Get a texture using its unique id
  34935. * @param uniqueId defines the texture's unique id
  34936. * @return the texture or null if none found.
  34937. */
  34938. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34939. /**
  34940. * Gets a camera using its id
  34941. * @param id defines the id to look for
  34942. * @returns the camera or null if not found
  34943. */
  34944. getCameraByID(id: string): Nullable<Camera>;
  34945. /**
  34946. * Gets a camera using its unique id
  34947. * @param uniqueId defines the unique id to look for
  34948. * @returns the camera or null if not found
  34949. */
  34950. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34951. /**
  34952. * Gets a camera using its name
  34953. * @param name defines the camera's name
  34954. * @return the camera or null if none found.
  34955. */
  34956. getCameraByName(name: string): Nullable<Camera>;
  34957. /**
  34958. * Gets a bone using its id
  34959. * @param id defines the bone's id
  34960. * @return the bone or null if not found
  34961. */
  34962. getBoneByID(id: string): Nullable<Bone>;
  34963. /**
  34964. * Gets a bone using its id
  34965. * @param name defines the bone's name
  34966. * @return the bone or null if not found
  34967. */
  34968. getBoneByName(name: string): Nullable<Bone>;
  34969. /**
  34970. * Gets a light node using its name
  34971. * @param name defines the the light's name
  34972. * @return the light or null if none found.
  34973. */
  34974. getLightByName(name: string): Nullable<Light>;
  34975. /**
  34976. * Gets a light node using its id
  34977. * @param id defines the light's id
  34978. * @return the light or null if none found.
  34979. */
  34980. getLightByID(id: string): Nullable<Light>;
  34981. /**
  34982. * Gets a light node using its scene-generated unique ID
  34983. * @param uniqueId defines the light's unique id
  34984. * @return the light or null if none found.
  34985. */
  34986. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34987. /**
  34988. * Gets a particle system by id
  34989. * @param id defines the particle system id
  34990. * @return the corresponding system or null if none found
  34991. */
  34992. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34993. /**
  34994. * Gets a geometry using its ID
  34995. * @param id defines the geometry's id
  34996. * @return the geometry or null if none found.
  34997. */
  34998. getGeometryByID(id: string): Nullable<Geometry>;
  34999. private _getGeometryByUniqueID;
  35000. /**
  35001. * Add a new geometry to this scene
  35002. * @param geometry defines the geometry to be added to the scene.
  35003. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35004. * @return a boolean defining if the geometry was added or not
  35005. */
  35006. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35007. /**
  35008. * Removes an existing geometry
  35009. * @param geometry defines the geometry to be removed from the scene
  35010. * @return a boolean defining if the geometry was removed or not
  35011. */
  35012. removeGeometry(geometry: Geometry): boolean;
  35013. /**
  35014. * Gets the list of geometries attached to the scene
  35015. * @returns an array of Geometry
  35016. */
  35017. getGeometries(): Geometry[];
  35018. /**
  35019. * Gets the first added mesh found of a given ID
  35020. * @param id defines the id to search for
  35021. * @return the mesh found or null if not found at all
  35022. */
  35023. getMeshByID(id: string): Nullable<AbstractMesh>;
  35024. /**
  35025. * Gets a list of meshes using their id
  35026. * @param id defines the id to search for
  35027. * @returns a list of meshes
  35028. */
  35029. getMeshesByID(id: string): Array<AbstractMesh>;
  35030. /**
  35031. * Gets the first added transform node found of a given ID
  35032. * @param id defines the id to search for
  35033. * @return the found transform node or null if not found at all.
  35034. */
  35035. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35036. /**
  35037. * Gets a transform node with its auto-generated unique id
  35038. * @param uniqueId efines the unique id to search for
  35039. * @return the found transform node or null if not found at all.
  35040. */
  35041. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35042. /**
  35043. * Gets a list of transform nodes using their id
  35044. * @param id defines the id to search for
  35045. * @returns a list of transform nodes
  35046. */
  35047. getTransformNodesByID(id: string): Array<TransformNode>;
  35048. /**
  35049. * Gets a mesh with its auto-generated unique id
  35050. * @param uniqueId defines the unique id to search for
  35051. * @return the found mesh or null if not found at all.
  35052. */
  35053. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35054. /**
  35055. * Gets a the last added mesh using a given id
  35056. * @param id defines the id to search for
  35057. * @return the found mesh or null if not found at all.
  35058. */
  35059. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35060. /**
  35061. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35062. * @param id defines the id to search for
  35063. * @return the found node or null if not found at all
  35064. */
  35065. getLastEntryByID(id: string): Nullable<Node>;
  35066. /**
  35067. * Gets a node (Mesh, Camera, Light) using a given id
  35068. * @param id defines the id to search for
  35069. * @return the found node or null if not found at all
  35070. */
  35071. getNodeByID(id: string): Nullable<Node>;
  35072. /**
  35073. * Gets a node (Mesh, Camera, Light) using a given name
  35074. * @param name defines the name to search for
  35075. * @return the found node or null if not found at all.
  35076. */
  35077. getNodeByName(name: string): Nullable<Node>;
  35078. /**
  35079. * Gets a mesh using a given name
  35080. * @param name defines the name to search for
  35081. * @return the found mesh or null if not found at all.
  35082. */
  35083. getMeshByName(name: string): Nullable<AbstractMesh>;
  35084. /**
  35085. * Gets a transform node using a given name
  35086. * @param name defines the name to search for
  35087. * @return the found transform node or null if not found at all.
  35088. */
  35089. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35090. /**
  35091. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35092. * @param id defines the id to search for
  35093. * @return the found skeleton or null if not found at all.
  35094. */
  35095. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35096. /**
  35097. * Gets a skeleton using a given auto generated unique id
  35098. * @param uniqueId defines the unique id to search for
  35099. * @return the found skeleton or null if not found at all.
  35100. */
  35101. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35102. /**
  35103. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35104. * @param id defines the id to search for
  35105. * @return the found skeleton or null if not found at all.
  35106. */
  35107. getSkeletonById(id: string): Nullable<Skeleton>;
  35108. /**
  35109. * Gets a skeleton using a given name
  35110. * @param name defines the name to search for
  35111. * @return the found skeleton or null if not found at all.
  35112. */
  35113. getSkeletonByName(name: string): Nullable<Skeleton>;
  35114. /**
  35115. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35116. * @param id defines the id to search for
  35117. * @return the found morph target manager or null if not found at all.
  35118. */
  35119. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35120. /**
  35121. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35122. * @param id defines the id to search for
  35123. * @return the found morph target or null if not found at all.
  35124. */
  35125. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35126. /**
  35127. * Gets a boolean indicating if the given mesh is active
  35128. * @param mesh defines the mesh to look for
  35129. * @returns true if the mesh is in the active list
  35130. */
  35131. isActiveMesh(mesh: AbstractMesh): boolean;
  35132. /**
  35133. * Return a unique id as a string which can serve as an identifier for the scene
  35134. */
  35135. readonly uid: string;
  35136. /**
  35137. * Add an externaly attached data from its key.
  35138. * This method call will fail and return false, if such key already exists.
  35139. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35140. * @param key the unique key that identifies the data
  35141. * @param data the data object to associate to the key for this Engine instance
  35142. * @return true if no such key were already present and the data was added successfully, false otherwise
  35143. */
  35144. addExternalData<T>(key: string, data: T): boolean;
  35145. /**
  35146. * Get an externaly attached data from its key
  35147. * @param key the unique key that identifies the data
  35148. * @return the associated data, if present (can be null), or undefined if not present
  35149. */
  35150. getExternalData<T>(key: string): Nullable<T>;
  35151. /**
  35152. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35153. * @param key the unique key that identifies the data
  35154. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35155. * @return the associated data, can be null if the factory returned null.
  35156. */
  35157. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35158. /**
  35159. * Remove an externaly attached data from the Engine instance
  35160. * @param key the unique key that identifies the data
  35161. * @return true if the data was successfully removed, false if it doesn't exist
  35162. */
  35163. removeExternalData(key: string): boolean;
  35164. private _evaluateSubMesh;
  35165. /**
  35166. * Clear the processed materials smart array preventing retention point in material dispose.
  35167. */
  35168. freeProcessedMaterials(): void;
  35169. private _preventFreeActiveMeshesAndRenderingGroups;
  35170. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35171. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35172. * when disposing several meshes in a row or a hierarchy of meshes.
  35173. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35174. */
  35175. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35176. /**
  35177. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35178. */
  35179. freeActiveMeshes(): void;
  35180. /**
  35181. * Clear the info related to rendering groups preventing retention points during dispose.
  35182. */
  35183. freeRenderingGroups(): void;
  35184. /** @hidden */
  35185. _isInIntermediateRendering(): boolean;
  35186. /**
  35187. * Lambda returning the list of potentially active meshes.
  35188. */
  35189. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35190. /**
  35191. * Lambda returning the list of potentially active sub meshes.
  35192. */
  35193. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35194. /**
  35195. * Lambda returning the list of potentially intersecting sub meshes.
  35196. */
  35197. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35198. /**
  35199. * Lambda returning the list of potentially colliding sub meshes.
  35200. */
  35201. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35202. private _activeMeshesFrozen;
  35203. /**
  35204. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35205. * @returns the current scene
  35206. */
  35207. freezeActiveMeshes(): Scene;
  35208. /**
  35209. * Use this function to restart evaluating active meshes on every frame
  35210. * @returns the current scene
  35211. */
  35212. unfreezeActiveMeshes(): Scene;
  35213. private _evaluateActiveMeshes;
  35214. private _activeMesh;
  35215. /**
  35216. * Update the transform matrix to update from the current active camera
  35217. * @param force defines a boolean used to force the update even if cache is up to date
  35218. */
  35219. updateTransformMatrix(force?: boolean): void;
  35220. private _bindFrameBuffer;
  35221. /** @hidden */
  35222. _allowPostProcessClearColor: boolean;
  35223. /** @hidden */
  35224. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35225. private _processSubCameras;
  35226. private _checkIntersections;
  35227. /** @hidden */
  35228. _advancePhysicsEngineStep(step: number): void;
  35229. /**
  35230. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35231. */
  35232. getDeterministicFrameTime: () => number;
  35233. /** @hidden */
  35234. _animate(): void;
  35235. /** Execute all animations (for a frame) */
  35236. animate(): void;
  35237. /**
  35238. * Render the scene
  35239. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35240. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35241. */
  35242. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35243. /**
  35244. * Freeze all materials
  35245. * A frozen material will not be updatable but should be faster to render
  35246. */
  35247. freezeMaterials(): void;
  35248. /**
  35249. * Unfreeze all materials
  35250. * A frozen material will not be updatable but should be faster to render
  35251. */
  35252. unfreezeMaterials(): void;
  35253. /**
  35254. * Releases all held ressources
  35255. */
  35256. dispose(): void;
  35257. /**
  35258. * Gets if the scene is already disposed
  35259. */
  35260. readonly isDisposed: boolean;
  35261. /**
  35262. * Call this function to reduce memory footprint of the scene.
  35263. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35264. */
  35265. clearCachedVertexData(): void;
  35266. /**
  35267. * This function will remove the local cached buffer data from texture.
  35268. * It will save memory but will prevent the texture from being rebuilt
  35269. */
  35270. cleanCachedTextureBuffer(): void;
  35271. /**
  35272. * Get the world extend vectors with an optional filter
  35273. *
  35274. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35275. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35276. */
  35277. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35278. min: Vector3;
  35279. max: Vector3;
  35280. };
  35281. /**
  35282. * Creates a ray that can be used to pick in the scene
  35283. * @param x defines the x coordinate of the origin (on-screen)
  35284. * @param y defines the y coordinate of the origin (on-screen)
  35285. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35286. * @param camera defines the camera to use for the picking
  35287. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35288. * @returns a Ray
  35289. */
  35290. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35291. /**
  35292. * Creates a ray that can be used to pick in the scene
  35293. * @param x defines the x coordinate of the origin (on-screen)
  35294. * @param y defines the y coordinate of the origin (on-screen)
  35295. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35296. * @param result defines the ray where to store the picking ray
  35297. * @param camera defines the camera to use for the picking
  35298. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35299. * @returns the current scene
  35300. */
  35301. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35302. /**
  35303. * Creates a ray that can be used to pick in the scene
  35304. * @param x defines the x coordinate of the origin (on-screen)
  35305. * @param y defines the y coordinate of the origin (on-screen)
  35306. * @param camera defines the camera to use for the picking
  35307. * @returns a Ray
  35308. */
  35309. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35310. /**
  35311. * Creates a ray that can be used to pick in the scene
  35312. * @param x defines the x coordinate of the origin (on-screen)
  35313. * @param y defines the y coordinate of the origin (on-screen)
  35314. * @param result defines the ray where to store the picking ray
  35315. * @param camera defines the camera to use for the picking
  35316. * @returns the current scene
  35317. */
  35318. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35319. /** Launch a ray to try to pick a mesh in the scene
  35320. * @param x position on screen
  35321. * @param y position on screen
  35322. * @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
  35323. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35324. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35325. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35326. * @returns a PickingInfo
  35327. */
  35328. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35329. /** Use the given ray to pick a mesh in the scene
  35330. * @param ray The ray to use to pick meshes
  35331. * @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
  35332. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35333. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35334. * @returns a PickingInfo
  35335. */
  35336. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35337. /**
  35338. * Launch a ray to try to pick a mesh in the scene
  35339. * @param x X position on screen
  35340. * @param y Y position on screen
  35341. * @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
  35342. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35343. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35344. * @returns an array of PickingInfo
  35345. */
  35346. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35347. /**
  35348. * Launch a ray to try to pick a mesh in the scene
  35349. * @param ray Ray to use
  35350. * @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
  35351. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35352. * @returns an array of PickingInfo
  35353. */
  35354. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35355. /**
  35356. * Force the value of meshUnderPointer
  35357. * @param mesh defines the mesh to use
  35358. */
  35359. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35360. /**
  35361. * Gets the mesh under the pointer
  35362. * @returns a Mesh or null if no mesh is under the pointer
  35363. */
  35364. getPointerOverMesh(): Nullable<AbstractMesh>;
  35365. /** @hidden */
  35366. _rebuildGeometries(): void;
  35367. /** @hidden */
  35368. _rebuildTextures(): void;
  35369. private _getByTags;
  35370. /**
  35371. * Get a list of meshes by tags
  35372. * @param tagsQuery defines the tags query to use
  35373. * @param forEach defines a predicate used to filter results
  35374. * @returns an array of Mesh
  35375. */
  35376. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35377. /**
  35378. * Get a list of cameras by tags
  35379. * @param tagsQuery defines the tags query to use
  35380. * @param forEach defines a predicate used to filter results
  35381. * @returns an array of Camera
  35382. */
  35383. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35384. /**
  35385. * Get a list of lights by tags
  35386. * @param tagsQuery defines the tags query to use
  35387. * @param forEach defines a predicate used to filter results
  35388. * @returns an array of Light
  35389. */
  35390. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35391. /**
  35392. * Get a list of materials by tags
  35393. * @param tagsQuery defines the tags query to use
  35394. * @param forEach defines a predicate used to filter results
  35395. * @returns an array of Material
  35396. */
  35397. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35398. /**
  35399. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35400. * This allowed control for front to back rendering or reversly depending of the special needs.
  35401. *
  35402. * @param renderingGroupId The rendering group id corresponding to its index
  35403. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35404. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35405. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35406. */
  35407. 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;
  35408. /**
  35409. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35410. *
  35411. * @param renderingGroupId The rendering group id corresponding to its index
  35412. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35413. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35414. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35415. */
  35416. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35417. /**
  35418. * Gets the current auto clear configuration for one rendering group of the rendering
  35419. * manager.
  35420. * @param index the rendering group index to get the information for
  35421. * @returns The auto clear setup for the requested rendering group
  35422. */
  35423. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35424. private _blockMaterialDirtyMechanism;
  35425. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35426. blockMaterialDirtyMechanism: boolean;
  35427. /**
  35428. * Will flag all materials as dirty to trigger new shader compilation
  35429. * @param flag defines the flag used to specify which material part must be marked as dirty
  35430. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35431. */
  35432. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35433. /** @hidden */
  35434. _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;
  35435. /** @hidden */
  35436. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35437. }
  35438. }
  35439. declare module "babylonjs/assetContainer" {
  35440. import { AbstractScene } from "babylonjs/abstractScene";
  35441. import { Scene } from "babylonjs/scene";
  35442. import { Mesh } from "babylonjs/Meshes/mesh";
  35443. /**
  35444. * Set of assets to keep when moving a scene into an asset container.
  35445. */
  35446. export class KeepAssets extends AbstractScene {
  35447. }
  35448. /**
  35449. * Container with a set of assets that can be added or removed from a scene.
  35450. */
  35451. export class AssetContainer extends AbstractScene {
  35452. /**
  35453. * The scene the AssetContainer belongs to.
  35454. */
  35455. scene: Scene;
  35456. /**
  35457. * Instantiates an AssetContainer.
  35458. * @param scene The scene the AssetContainer belongs to.
  35459. */
  35460. constructor(scene: Scene);
  35461. /**
  35462. * Adds all the assets from the container to the scene.
  35463. */
  35464. addAllToScene(): void;
  35465. /**
  35466. * Removes all the assets in the container from the scene
  35467. */
  35468. removeAllFromScene(): void;
  35469. /**
  35470. * Disposes all the assets in the container
  35471. */
  35472. dispose(): void;
  35473. private _moveAssets;
  35474. /**
  35475. * Removes all the assets contained in the scene and adds them to the container.
  35476. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35477. */
  35478. moveAllFromScene(keepAssets?: KeepAssets): void;
  35479. /**
  35480. * 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.
  35481. * @returns the root mesh
  35482. */
  35483. createRootMesh(): Mesh;
  35484. }
  35485. }
  35486. declare module "babylonjs/abstractScene" {
  35487. import { Scene } from "babylonjs/scene";
  35488. import { Nullable } from "babylonjs/types";
  35489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35490. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35491. import { Geometry } from "babylonjs/Meshes/geometry";
  35492. import { Skeleton } from "babylonjs/Bones/skeleton";
  35493. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35494. import { AssetContainer } from "babylonjs/assetContainer";
  35495. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35496. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35498. import { Material } from "babylonjs/Materials/material";
  35499. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35500. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35501. import { Camera } from "babylonjs/Cameras/camera";
  35502. import { Light } from "babylonjs/Lights/light";
  35503. import { Node } from "babylonjs/node";
  35504. import { Animation } from "babylonjs/Animations/animation";
  35505. /**
  35506. * Defines how the parser contract is defined.
  35507. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35508. */
  35509. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35510. /**
  35511. * Defines how the individual parser contract is defined.
  35512. * These parser can parse an individual asset
  35513. */
  35514. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35515. /**
  35516. * Base class of the scene acting as a container for the different elements composing a scene.
  35517. * This class is dynamically extended by the different components of the scene increasing
  35518. * flexibility and reducing coupling
  35519. */
  35520. export abstract class AbstractScene {
  35521. /**
  35522. * Stores the list of available parsers in the application.
  35523. */
  35524. private static _BabylonFileParsers;
  35525. /**
  35526. * Stores the list of available individual parsers in the application.
  35527. */
  35528. private static _IndividualBabylonFileParsers;
  35529. /**
  35530. * Adds a parser in the list of available ones
  35531. * @param name Defines the name of the parser
  35532. * @param parser Defines the parser to add
  35533. */
  35534. static AddParser(name: string, parser: BabylonFileParser): void;
  35535. /**
  35536. * Gets a general parser from the list of avaialble ones
  35537. * @param name Defines the name of the parser
  35538. * @returns the requested parser or null
  35539. */
  35540. static GetParser(name: string): Nullable<BabylonFileParser>;
  35541. /**
  35542. * Adds n individual parser in the list of available ones
  35543. * @param name Defines the name of the parser
  35544. * @param parser Defines the parser to add
  35545. */
  35546. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35547. /**
  35548. * Gets an individual parser from the list of avaialble ones
  35549. * @param name Defines the name of the parser
  35550. * @returns the requested parser or null
  35551. */
  35552. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35553. /**
  35554. * Parser json data and populate both a scene and its associated container object
  35555. * @param jsonData Defines the data to parse
  35556. * @param scene Defines the scene to parse the data for
  35557. * @param container Defines the container attached to the parsing sequence
  35558. * @param rootUrl Defines the root url of the data
  35559. */
  35560. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35561. /**
  35562. * Gets the list of root nodes (ie. nodes with no parent)
  35563. */
  35564. rootNodes: Node[];
  35565. /** All of the cameras added to this scene
  35566. * @see http://doc.babylonjs.com/babylon101/cameras
  35567. */
  35568. cameras: Camera[];
  35569. /**
  35570. * All of the lights added to this scene
  35571. * @see http://doc.babylonjs.com/babylon101/lights
  35572. */
  35573. lights: Light[];
  35574. /**
  35575. * All of the (abstract) meshes added to this scene
  35576. */
  35577. meshes: AbstractMesh[];
  35578. /**
  35579. * The list of skeletons added to the scene
  35580. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35581. */
  35582. skeletons: Skeleton[];
  35583. /**
  35584. * All of the particle systems added to this scene
  35585. * @see http://doc.babylonjs.com/babylon101/particles
  35586. */
  35587. particleSystems: IParticleSystem[];
  35588. /**
  35589. * Gets a list of Animations associated with the scene
  35590. */
  35591. animations: Animation[];
  35592. /**
  35593. * All of the animation groups added to this scene
  35594. * @see http://doc.babylonjs.com/how_to/group
  35595. */
  35596. animationGroups: AnimationGroup[];
  35597. /**
  35598. * All of the multi-materials added to this scene
  35599. * @see http://doc.babylonjs.com/how_to/multi_materials
  35600. */
  35601. multiMaterials: MultiMaterial[];
  35602. /**
  35603. * All of the materials added to this scene
  35604. * In the context of a Scene, it is not supposed to be modified manually.
  35605. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35606. * Note also that the order of the Material wihin the array is not significant and might change.
  35607. * @see http://doc.babylonjs.com/babylon101/materials
  35608. */
  35609. materials: Material[];
  35610. /**
  35611. * The list of morph target managers added to the scene
  35612. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35613. */
  35614. morphTargetManagers: MorphTargetManager[];
  35615. /**
  35616. * The list of geometries used in the scene.
  35617. */
  35618. geometries: Geometry[];
  35619. /**
  35620. * All of the tranform nodes added to this scene
  35621. * In the context of a Scene, it is not supposed to be modified manually.
  35622. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35623. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35624. * @see http://doc.babylonjs.com/how_to/transformnode
  35625. */
  35626. transformNodes: TransformNode[];
  35627. /**
  35628. * ActionManagers available on the scene.
  35629. */
  35630. actionManagers: AbstractActionManager[];
  35631. /**
  35632. * Textures to keep.
  35633. */
  35634. textures: BaseTexture[];
  35635. /**
  35636. * Environment texture for the scene
  35637. */
  35638. environmentTexture: Nullable<BaseTexture>;
  35639. }
  35640. }
  35641. declare module "babylonjs/Audio/sound" {
  35642. import { Observable } from "babylonjs/Misc/observable";
  35643. import { Vector3 } from "babylonjs/Maths/math.vector";
  35644. import { Nullable } from "babylonjs/types";
  35645. import { Scene } from "babylonjs/scene";
  35646. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35647. /**
  35648. * Interface used to define options for Sound class
  35649. */
  35650. export interface ISoundOptions {
  35651. /**
  35652. * Does the sound autoplay once loaded.
  35653. */
  35654. autoplay?: boolean;
  35655. /**
  35656. * Does the sound loop after it finishes playing once.
  35657. */
  35658. loop?: boolean;
  35659. /**
  35660. * Sound's volume
  35661. */
  35662. volume?: number;
  35663. /**
  35664. * Is it a spatial sound?
  35665. */
  35666. spatialSound?: boolean;
  35667. /**
  35668. * Maximum distance to hear that sound
  35669. */
  35670. maxDistance?: number;
  35671. /**
  35672. * Uses user defined attenuation function
  35673. */
  35674. useCustomAttenuation?: boolean;
  35675. /**
  35676. * Define the roll off factor of spatial sounds.
  35677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35678. */
  35679. rolloffFactor?: number;
  35680. /**
  35681. * Define the reference distance the sound should be heard perfectly.
  35682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35683. */
  35684. refDistance?: number;
  35685. /**
  35686. * Define the distance attenuation model the sound will follow.
  35687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35688. */
  35689. distanceModel?: string;
  35690. /**
  35691. * Defines the playback speed (1 by default)
  35692. */
  35693. playbackRate?: number;
  35694. /**
  35695. * Defines if the sound is from a streaming source
  35696. */
  35697. streaming?: boolean;
  35698. /**
  35699. * Defines an optional length (in seconds) inside the sound file
  35700. */
  35701. length?: number;
  35702. /**
  35703. * Defines an optional offset (in seconds) inside the sound file
  35704. */
  35705. offset?: number;
  35706. /**
  35707. * If true, URLs will not be required to state the audio file codec to use.
  35708. */
  35709. skipCodecCheck?: boolean;
  35710. }
  35711. /**
  35712. * Defines a sound that can be played in the application.
  35713. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35715. */
  35716. export class Sound {
  35717. /**
  35718. * The name of the sound in the scene.
  35719. */
  35720. name: string;
  35721. /**
  35722. * Does the sound autoplay once loaded.
  35723. */
  35724. autoplay: boolean;
  35725. /**
  35726. * Does the sound loop after it finishes playing once.
  35727. */
  35728. loop: boolean;
  35729. /**
  35730. * Does the sound use a custom attenuation curve to simulate the falloff
  35731. * happening when the source gets further away from the camera.
  35732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35733. */
  35734. useCustomAttenuation: boolean;
  35735. /**
  35736. * The sound track id this sound belongs to.
  35737. */
  35738. soundTrackId: number;
  35739. /**
  35740. * Is this sound currently played.
  35741. */
  35742. isPlaying: boolean;
  35743. /**
  35744. * Is this sound currently paused.
  35745. */
  35746. isPaused: boolean;
  35747. /**
  35748. * Does this sound enables spatial sound.
  35749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35750. */
  35751. spatialSound: boolean;
  35752. /**
  35753. * Define the reference distance the sound should be heard perfectly.
  35754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35755. */
  35756. refDistance: number;
  35757. /**
  35758. * Define the roll off factor of spatial sounds.
  35759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35760. */
  35761. rolloffFactor: number;
  35762. /**
  35763. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35765. */
  35766. maxDistance: number;
  35767. /**
  35768. * Define the distance attenuation model the sound will follow.
  35769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35770. */
  35771. distanceModel: string;
  35772. /**
  35773. * @hidden
  35774. * Back Compat
  35775. **/
  35776. onended: () => any;
  35777. /**
  35778. * Observable event when the current playing sound finishes.
  35779. */
  35780. onEndedObservable: Observable<Sound>;
  35781. private _panningModel;
  35782. private _playbackRate;
  35783. private _streaming;
  35784. private _startTime;
  35785. private _startOffset;
  35786. private _position;
  35787. /** @hidden */
  35788. _positionInEmitterSpace: boolean;
  35789. private _localDirection;
  35790. private _volume;
  35791. private _isReadyToPlay;
  35792. private _isDirectional;
  35793. private _readyToPlayCallback;
  35794. private _audioBuffer;
  35795. private _soundSource;
  35796. private _streamingSource;
  35797. private _soundPanner;
  35798. private _soundGain;
  35799. private _inputAudioNode;
  35800. private _outputAudioNode;
  35801. private _coneInnerAngle;
  35802. private _coneOuterAngle;
  35803. private _coneOuterGain;
  35804. private _scene;
  35805. private _connectedTransformNode;
  35806. private _customAttenuationFunction;
  35807. private _registerFunc;
  35808. private _isOutputConnected;
  35809. private _htmlAudioElement;
  35810. private _urlType;
  35811. private _length?;
  35812. private _offset?;
  35813. /** @hidden */
  35814. static _SceneComponentInitialization: (scene: Scene) => void;
  35815. /**
  35816. * Create a sound and attach it to a scene
  35817. * @param name Name of your sound
  35818. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35819. * @param scene defines the scene the sound belongs to
  35820. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35821. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35822. */
  35823. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35824. /**
  35825. * Release the sound and its associated resources
  35826. */
  35827. dispose(): void;
  35828. /**
  35829. * Gets if the sounds is ready to be played or not.
  35830. * @returns true if ready, otherwise false
  35831. */
  35832. isReady(): boolean;
  35833. private _soundLoaded;
  35834. /**
  35835. * Sets the data of the sound from an audiobuffer
  35836. * @param audioBuffer The audioBuffer containing the data
  35837. */
  35838. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35839. /**
  35840. * Updates the current sounds options such as maxdistance, loop...
  35841. * @param options A JSON object containing values named as the object properties
  35842. */
  35843. updateOptions(options: ISoundOptions): void;
  35844. private _createSpatialParameters;
  35845. private _updateSpatialParameters;
  35846. /**
  35847. * Switch the panning model to HRTF:
  35848. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35850. */
  35851. switchPanningModelToHRTF(): void;
  35852. /**
  35853. * Switch the panning model to Equal Power:
  35854. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35856. */
  35857. switchPanningModelToEqualPower(): void;
  35858. private _switchPanningModel;
  35859. /**
  35860. * Connect this sound to a sound track audio node like gain...
  35861. * @param soundTrackAudioNode the sound track audio node to connect to
  35862. */
  35863. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35864. /**
  35865. * Transform this sound into a directional source
  35866. * @param coneInnerAngle Size of the inner cone in degree
  35867. * @param coneOuterAngle Size of the outer cone in degree
  35868. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35869. */
  35870. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35871. /**
  35872. * Gets or sets the inner angle for the directional cone.
  35873. */
  35874. /**
  35875. * Gets or sets the inner angle for the directional cone.
  35876. */
  35877. directionalConeInnerAngle: number;
  35878. /**
  35879. * Gets or sets the outer angle for the directional cone.
  35880. */
  35881. /**
  35882. * Gets or sets the outer angle for the directional cone.
  35883. */
  35884. directionalConeOuterAngle: number;
  35885. /**
  35886. * Sets the position of the emitter if spatial sound is enabled
  35887. * @param newPosition Defines the new posisiton
  35888. */
  35889. setPosition(newPosition: Vector3): void;
  35890. /**
  35891. * Sets the local direction of the emitter if spatial sound is enabled
  35892. * @param newLocalDirection Defines the new local direction
  35893. */
  35894. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35895. private _updateDirection;
  35896. /** @hidden */
  35897. updateDistanceFromListener(): void;
  35898. /**
  35899. * Sets a new custom attenuation function for the sound.
  35900. * @param callback Defines the function used for the attenuation
  35901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35902. */
  35903. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35904. /**
  35905. * Play the sound
  35906. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35907. * @param offset (optional) Start the sound at a specific time in seconds
  35908. * @param length (optional) Sound duration (in seconds)
  35909. */
  35910. play(time?: number, offset?: number, length?: number): void;
  35911. private _onended;
  35912. /**
  35913. * Stop the sound
  35914. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35915. */
  35916. stop(time?: number): void;
  35917. /**
  35918. * Put the sound in pause
  35919. */
  35920. pause(): void;
  35921. /**
  35922. * Sets a dedicated volume for this sounds
  35923. * @param newVolume Define the new volume of the sound
  35924. * @param time Define time for gradual change to new volume
  35925. */
  35926. setVolume(newVolume: number, time?: number): void;
  35927. /**
  35928. * Set the sound play back rate
  35929. * @param newPlaybackRate Define the playback rate the sound should be played at
  35930. */
  35931. setPlaybackRate(newPlaybackRate: number): void;
  35932. /**
  35933. * Gets the volume of the sound.
  35934. * @returns the volume of the sound
  35935. */
  35936. getVolume(): number;
  35937. /**
  35938. * Attach the sound to a dedicated mesh
  35939. * @param transformNode The transform node to connect the sound with
  35940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35941. */
  35942. attachToMesh(transformNode: TransformNode): void;
  35943. /**
  35944. * Detach the sound from the previously attached mesh
  35945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35946. */
  35947. detachFromMesh(): void;
  35948. private _onRegisterAfterWorldMatrixUpdate;
  35949. /**
  35950. * Clone the current sound in the scene.
  35951. * @returns the new sound clone
  35952. */
  35953. clone(): Nullable<Sound>;
  35954. /**
  35955. * Gets the current underlying audio buffer containing the data
  35956. * @returns the audio buffer
  35957. */
  35958. getAudioBuffer(): Nullable<AudioBuffer>;
  35959. /**
  35960. * Serializes the Sound in a JSON representation
  35961. * @returns the JSON representation of the sound
  35962. */
  35963. serialize(): any;
  35964. /**
  35965. * Parse a JSON representation of a sound to innstantiate in a given scene
  35966. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35967. * @param scene Define the scene the new parsed sound should be created in
  35968. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35969. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35970. * @returns the newly parsed sound
  35971. */
  35972. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35973. }
  35974. }
  35975. declare module "babylonjs/Actions/directAudioActions" {
  35976. import { Action } from "babylonjs/Actions/action";
  35977. import { Condition } from "babylonjs/Actions/condition";
  35978. import { Sound } from "babylonjs/Audio/sound";
  35979. /**
  35980. * This defines an action helpful to play a defined sound on a triggered action.
  35981. */
  35982. export class PlaySoundAction extends Action {
  35983. private _sound;
  35984. /**
  35985. * Instantiate the action
  35986. * @param triggerOptions defines the trigger options
  35987. * @param sound defines the sound to play
  35988. * @param condition defines the trigger related conditions
  35989. */
  35990. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35991. /** @hidden */
  35992. _prepare(): void;
  35993. /**
  35994. * Execute the action and play the sound.
  35995. */
  35996. execute(): void;
  35997. /**
  35998. * Serializes the actions and its related information.
  35999. * @param parent defines the object to serialize in
  36000. * @returns the serialized object
  36001. */
  36002. serialize(parent: any): any;
  36003. }
  36004. /**
  36005. * This defines an action helpful to stop a defined sound on a triggered action.
  36006. */
  36007. export class StopSoundAction extends Action {
  36008. private _sound;
  36009. /**
  36010. * Instantiate the action
  36011. * @param triggerOptions defines the trigger options
  36012. * @param sound defines the sound to stop
  36013. * @param condition defines the trigger related conditions
  36014. */
  36015. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36016. /** @hidden */
  36017. _prepare(): void;
  36018. /**
  36019. * Execute the action and stop the sound.
  36020. */
  36021. execute(): void;
  36022. /**
  36023. * Serializes the actions and its related information.
  36024. * @param parent defines the object to serialize in
  36025. * @returns the serialized object
  36026. */
  36027. serialize(parent: any): any;
  36028. }
  36029. }
  36030. declare module "babylonjs/Actions/interpolateValueAction" {
  36031. import { Action } from "babylonjs/Actions/action";
  36032. import { Condition } from "babylonjs/Actions/condition";
  36033. import { Observable } from "babylonjs/Misc/observable";
  36034. /**
  36035. * This defines an action responsible to change the value of a property
  36036. * by interpolating between its current value and the newly set one once triggered.
  36037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36038. */
  36039. export class InterpolateValueAction extends Action {
  36040. /**
  36041. * Defines the path of the property where the value should be interpolated
  36042. */
  36043. propertyPath: string;
  36044. /**
  36045. * Defines the target value at the end of the interpolation.
  36046. */
  36047. value: any;
  36048. /**
  36049. * Defines the time it will take for the property to interpolate to the value.
  36050. */
  36051. duration: number;
  36052. /**
  36053. * Defines if the other scene animations should be stopped when the action has been triggered
  36054. */
  36055. stopOtherAnimations?: boolean;
  36056. /**
  36057. * Defines a callback raised once the interpolation animation has been done.
  36058. */
  36059. onInterpolationDone?: () => void;
  36060. /**
  36061. * Observable triggered once the interpolation animation has been done.
  36062. */
  36063. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36064. private _target;
  36065. private _effectiveTarget;
  36066. private _property;
  36067. /**
  36068. * Instantiate the action
  36069. * @param triggerOptions defines the trigger options
  36070. * @param target defines the object containing the value to interpolate
  36071. * @param propertyPath defines the path to the property in the target object
  36072. * @param value defines the target value at the end of the interpolation
  36073. * @param duration deines the time it will take for the property to interpolate to the value.
  36074. * @param condition defines the trigger related conditions
  36075. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36076. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36077. */
  36078. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36079. /** @hidden */
  36080. _prepare(): void;
  36081. /**
  36082. * Execute the action starts the value interpolation.
  36083. */
  36084. execute(): void;
  36085. /**
  36086. * Serializes the actions and its related information.
  36087. * @param parent defines the object to serialize in
  36088. * @returns the serialized object
  36089. */
  36090. serialize(parent: any): any;
  36091. }
  36092. }
  36093. declare module "babylonjs/Actions/index" {
  36094. export * from "babylonjs/Actions/abstractActionManager";
  36095. export * from "babylonjs/Actions/action";
  36096. export * from "babylonjs/Actions/actionEvent";
  36097. export * from "babylonjs/Actions/actionManager";
  36098. export * from "babylonjs/Actions/condition";
  36099. export * from "babylonjs/Actions/directActions";
  36100. export * from "babylonjs/Actions/directAudioActions";
  36101. export * from "babylonjs/Actions/interpolateValueAction";
  36102. }
  36103. declare module "babylonjs/Animations/index" {
  36104. export * from "babylonjs/Animations/animatable";
  36105. export * from "babylonjs/Animations/animation";
  36106. export * from "babylonjs/Animations/animationGroup";
  36107. export * from "babylonjs/Animations/animationPropertiesOverride";
  36108. export * from "babylonjs/Animations/easing";
  36109. export * from "babylonjs/Animations/runtimeAnimation";
  36110. export * from "babylonjs/Animations/animationEvent";
  36111. export * from "babylonjs/Animations/animationGroup";
  36112. export * from "babylonjs/Animations/animationKey";
  36113. export * from "babylonjs/Animations/animationRange";
  36114. export * from "babylonjs/Animations/animatable.interface";
  36115. }
  36116. declare module "babylonjs/Audio/soundTrack" {
  36117. import { Sound } from "babylonjs/Audio/sound";
  36118. import { Analyser } from "babylonjs/Audio/analyser";
  36119. import { Scene } from "babylonjs/scene";
  36120. /**
  36121. * Options allowed during the creation of a sound track.
  36122. */
  36123. export interface ISoundTrackOptions {
  36124. /**
  36125. * The volume the sound track should take during creation
  36126. */
  36127. volume?: number;
  36128. /**
  36129. * Define if the sound track is the main sound track of the scene
  36130. */
  36131. mainTrack?: boolean;
  36132. }
  36133. /**
  36134. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36135. * It will be also used in a future release to apply effects on a specific track.
  36136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36137. */
  36138. export class SoundTrack {
  36139. /**
  36140. * The unique identifier of the sound track in the scene.
  36141. */
  36142. id: number;
  36143. /**
  36144. * The list of sounds included in the sound track.
  36145. */
  36146. soundCollection: Array<Sound>;
  36147. private _outputAudioNode;
  36148. private _scene;
  36149. private _isMainTrack;
  36150. private _connectedAnalyser;
  36151. private _options;
  36152. private _isInitialized;
  36153. /**
  36154. * Creates a new sound track.
  36155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36156. * @param scene Define the scene the sound track belongs to
  36157. * @param options
  36158. */
  36159. constructor(scene: Scene, options?: ISoundTrackOptions);
  36160. private _initializeSoundTrackAudioGraph;
  36161. /**
  36162. * Release the sound track and its associated resources
  36163. */
  36164. dispose(): void;
  36165. /**
  36166. * Adds a sound to this sound track
  36167. * @param sound define the cound to add
  36168. * @ignoreNaming
  36169. */
  36170. AddSound(sound: Sound): void;
  36171. /**
  36172. * Removes a sound to this sound track
  36173. * @param sound define the cound to remove
  36174. * @ignoreNaming
  36175. */
  36176. RemoveSound(sound: Sound): void;
  36177. /**
  36178. * Set a global volume for the full sound track.
  36179. * @param newVolume Define the new volume of the sound track
  36180. */
  36181. setVolume(newVolume: number): void;
  36182. /**
  36183. * Switch the panning model to HRTF:
  36184. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36186. */
  36187. switchPanningModelToHRTF(): void;
  36188. /**
  36189. * Switch the panning model to Equal Power:
  36190. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36192. */
  36193. switchPanningModelToEqualPower(): void;
  36194. /**
  36195. * Connect the sound track to an audio analyser allowing some amazing
  36196. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36198. * @param analyser The analyser to connect to the engine
  36199. */
  36200. connectToAnalyser(analyser: Analyser): void;
  36201. }
  36202. }
  36203. declare module "babylonjs/Audio/audioSceneComponent" {
  36204. import { Sound } from "babylonjs/Audio/sound";
  36205. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36206. import { Nullable } from "babylonjs/types";
  36207. import { Vector3 } from "babylonjs/Maths/math.vector";
  36208. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36209. import { Scene } from "babylonjs/scene";
  36210. import { AbstractScene } from "babylonjs/abstractScene";
  36211. import "babylonjs/Audio/audioEngine";
  36212. module "babylonjs/abstractScene" {
  36213. interface AbstractScene {
  36214. /**
  36215. * The list of sounds used in the scene.
  36216. */
  36217. sounds: Nullable<Array<Sound>>;
  36218. }
  36219. }
  36220. module "babylonjs/scene" {
  36221. interface Scene {
  36222. /**
  36223. * @hidden
  36224. * Backing field
  36225. */
  36226. _mainSoundTrack: SoundTrack;
  36227. /**
  36228. * The main sound track played by the scene.
  36229. * It cotains your primary collection of sounds.
  36230. */
  36231. mainSoundTrack: SoundTrack;
  36232. /**
  36233. * The list of sound tracks added to the scene
  36234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36235. */
  36236. soundTracks: Nullable<Array<SoundTrack>>;
  36237. /**
  36238. * Gets a sound using a given name
  36239. * @param name defines the name to search for
  36240. * @return the found sound or null if not found at all.
  36241. */
  36242. getSoundByName(name: string): Nullable<Sound>;
  36243. /**
  36244. * Gets or sets if audio support is enabled
  36245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36246. */
  36247. audioEnabled: boolean;
  36248. /**
  36249. * Gets or sets if audio will be output to headphones
  36250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36251. */
  36252. headphone: boolean;
  36253. /**
  36254. * Gets or sets custom audio listener position provider
  36255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36256. */
  36257. audioListenerPositionProvider: Nullable<() => Vector3>;
  36258. }
  36259. }
  36260. /**
  36261. * Defines the sound scene component responsible to manage any sounds
  36262. * in a given scene.
  36263. */
  36264. export class AudioSceneComponent implements ISceneSerializableComponent {
  36265. /**
  36266. * The component name helpfull to identify the component in the list of scene components.
  36267. */
  36268. readonly name: string;
  36269. /**
  36270. * The scene the component belongs to.
  36271. */
  36272. scene: Scene;
  36273. private _audioEnabled;
  36274. /**
  36275. * Gets whether audio is enabled or not.
  36276. * Please use related enable/disable method to switch state.
  36277. */
  36278. readonly audioEnabled: boolean;
  36279. private _headphone;
  36280. /**
  36281. * Gets whether audio is outputing to headphone or not.
  36282. * Please use the according Switch methods to change output.
  36283. */
  36284. readonly headphone: boolean;
  36285. private _audioListenerPositionProvider;
  36286. /**
  36287. * Gets the current audio listener position provider
  36288. */
  36289. /**
  36290. * Sets a custom listener position for all sounds in the scene
  36291. * By default, this is the position of the first active camera
  36292. */
  36293. audioListenerPositionProvider: Nullable<() => Vector3>;
  36294. /**
  36295. * Creates a new instance of the component for the given scene
  36296. * @param scene Defines the scene to register the component in
  36297. */
  36298. constructor(scene: Scene);
  36299. /**
  36300. * Registers the component in a given scene
  36301. */
  36302. register(): void;
  36303. /**
  36304. * Rebuilds the elements related to this component in case of
  36305. * context lost for instance.
  36306. */
  36307. rebuild(): void;
  36308. /**
  36309. * Serializes the component data to the specified json object
  36310. * @param serializationObject The object to serialize to
  36311. */
  36312. serialize(serializationObject: any): void;
  36313. /**
  36314. * Adds all the elements from the container to the scene
  36315. * @param container the container holding the elements
  36316. */
  36317. addFromContainer(container: AbstractScene): void;
  36318. /**
  36319. * Removes all the elements in the container from the scene
  36320. * @param container contains the elements to remove
  36321. * @param dispose if the removed element should be disposed (default: false)
  36322. */
  36323. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36324. /**
  36325. * Disposes the component and the associated ressources.
  36326. */
  36327. dispose(): void;
  36328. /**
  36329. * Disables audio in the associated scene.
  36330. */
  36331. disableAudio(): void;
  36332. /**
  36333. * Enables audio in the associated scene.
  36334. */
  36335. enableAudio(): void;
  36336. /**
  36337. * Switch audio to headphone output.
  36338. */
  36339. switchAudioModeForHeadphones(): void;
  36340. /**
  36341. * Switch audio to normal speakers.
  36342. */
  36343. switchAudioModeForNormalSpeakers(): void;
  36344. private _afterRender;
  36345. }
  36346. }
  36347. declare module "babylonjs/Audio/weightedsound" {
  36348. import { Sound } from "babylonjs/Audio/sound";
  36349. /**
  36350. * Wraps one or more Sound objects and selects one with random weight for playback.
  36351. */
  36352. export class WeightedSound {
  36353. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36354. loop: boolean;
  36355. private _coneInnerAngle;
  36356. private _coneOuterAngle;
  36357. private _volume;
  36358. /** A Sound is currently playing. */
  36359. isPlaying: boolean;
  36360. /** A Sound is currently paused. */
  36361. isPaused: boolean;
  36362. private _sounds;
  36363. private _weights;
  36364. private _currentIndex?;
  36365. /**
  36366. * Creates a new WeightedSound from the list of sounds given.
  36367. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36368. * @param sounds Array of Sounds that will be selected from.
  36369. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36370. */
  36371. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36372. /**
  36373. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36374. */
  36375. /**
  36376. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36377. */
  36378. directionalConeInnerAngle: number;
  36379. /**
  36380. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36381. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36382. */
  36383. /**
  36384. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36385. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36386. */
  36387. directionalConeOuterAngle: number;
  36388. /**
  36389. * Playback volume.
  36390. */
  36391. /**
  36392. * Playback volume.
  36393. */
  36394. volume: number;
  36395. private _onended;
  36396. /**
  36397. * Suspend playback
  36398. */
  36399. pause(): void;
  36400. /**
  36401. * Stop playback
  36402. */
  36403. stop(): void;
  36404. /**
  36405. * Start playback.
  36406. * @param startOffset Position the clip head at a specific time in seconds.
  36407. */
  36408. play(startOffset?: number): void;
  36409. }
  36410. }
  36411. declare module "babylonjs/Audio/index" {
  36412. export * from "babylonjs/Audio/analyser";
  36413. export * from "babylonjs/Audio/audioEngine";
  36414. export * from "babylonjs/Audio/audioSceneComponent";
  36415. export * from "babylonjs/Audio/sound";
  36416. export * from "babylonjs/Audio/soundTrack";
  36417. export * from "babylonjs/Audio/weightedsound";
  36418. }
  36419. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36420. import { Behavior } from "babylonjs/Behaviors/behavior";
  36421. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36422. import { BackEase } from "babylonjs/Animations/easing";
  36423. /**
  36424. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36425. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36426. */
  36427. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36428. /**
  36429. * Gets the name of the behavior.
  36430. */
  36431. readonly name: string;
  36432. /**
  36433. * The easing function used by animations
  36434. */
  36435. static EasingFunction: BackEase;
  36436. /**
  36437. * The easing mode used by animations
  36438. */
  36439. static EasingMode: number;
  36440. /**
  36441. * The duration of the animation, in milliseconds
  36442. */
  36443. transitionDuration: number;
  36444. /**
  36445. * Length of the distance animated by the transition when lower radius is reached
  36446. */
  36447. lowerRadiusTransitionRange: number;
  36448. /**
  36449. * Length of the distance animated by the transition when upper radius is reached
  36450. */
  36451. upperRadiusTransitionRange: number;
  36452. private _autoTransitionRange;
  36453. /**
  36454. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36455. */
  36456. /**
  36457. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36458. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36459. */
  36460. autoTransitionRange: boolean;
  36461. private _attachedCamera;
  36462. private _onAfterCheckInputsObserver;
  36463. private _onMeshTargetChangedObserver;
  36464. /**
  36465. * Initializes the behavior.
  36466. */
  36467. init(): void;
  36468. /**
  36469. * Attaches the behavior to its arc rotate camera.
  36470. * @param camera Defines the camera to attach the behavior to
  36471. */
  36472. attach(camera: ArcRotateCamera): void;
  36473. /**
  36474. * Detaches the behavior from its current arc rotate camera.
  36475. */
  36476. detach(): void;
  36477. private _radiusIsAnimating;
  36478. private _radiusBounceTransition;
  36479. private _animatables;
  36480. private _cachedWheelPrecision;
  36481. /**
  36482. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36483. * @param radiusLimit The limit to check against.
  36484. * @return Bool to indicate if at limit.
  36485. */
  36486. private _isRadiusAtLimit;
  36487. /**
  36488. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36489. * @param radiusDelta The delta by which to animate to. Can be negative.
  36490. */
  36491. private _applyBoundRadiusAnimation;
  36492. /**
  36493. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36494. */
  36495. protected _clearAnimationLocks(): void;
  36496. /**
  36497. * Stops and removes all animations that have been applied to the camera
  36498. */
  36499. stopAllAnimations(): void;
  36500. }
  36501. }
  36502. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36503. import { Behavior } from "babylonjs/Behaviors/behavior";
  36504. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36505. import { ExponentialEase } from "babylonjs/Animations/easing";
  36506. import { Nullable } from "babylonjs/types";
  36507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36508. import { Vector3 } from "babylonjs/Maths/math.vector";
  36509. /**
  36510. * 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.
  36511. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36512. */
  36513. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36514. /**
  36515. * Gets the name of the behavior.
  36516. */
  36517. readonly name: string;
  36518. private _mode;
  36519. private _radiusScale;
  36520. private _positionScale;
  36521. private _defaultElevation;
  36522. private _elevationReturnTime;
  36523. private _elevationReturnWaitTime;
  36524. private _zoomStopsAnimation;
  36525. private _framingTime;
  36526. /**
  36527. * The easing function used by animations
  36528. */
  36529. static EasingFunction: ExponentialEase;
  36530. /**
  36531. * The easing mode used by animations
  36532. */
  36533. static EasingMode: number;
  36534. /**
  36535. * Sets the current mode used by the behavior
  36536. */
  36537. /**
  36538. * Gets current mode used by the behavior.
  36539. */
  36540. mode: number;
  36541. /**
  36542. * Sets the scale applied to the radius (1 by default)
  36543. */
  36544. /**
  36545. * Gets the scale applied to the radius
  36546. */
  36547. radiusScale: number;
  36548. /**
  36549. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36550. */
  36551. /**
  36552. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36553. */
  36554. positionScale: number;
  36555. /**
  36556. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36557. * behaviour is triggered, in radians.
  36558. */
  36559. /**
  36560. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36561. * behaviour is triggered, in radians.
  36562. */
  36563. defaultElevation: number;
  36564. /**
  36565. * Sets the time (in milliseconds) taken to return to the default beta position.
  36566. * Negative value indicates camera should not return to default.
  36567. */
  36568. /**
  36569. * Gets the time (in milliseconds) taken to return to the default beta position.
  36570. * Negative value indicates camera should not return to default.
  36571. */
  36572. elevationReturnTime: number;
  36573. /**
  36574. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36575. */
  36576. /**
  36577. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36578. */
  36579. elevationReturnWaitTime: number;
  36580. /**
  36581. * Sets the flag that indicates if user zooming should stop animation.
  36582. */
  36583. /**
  36584. * Gets the flag that indicates if user zooming should stop animation.
  36585. */
  36586. zoomStopsAnimation: boolean;
  36587. /**
  36588. * Sets the transition time when framing the mesh, in milliseconds
  36589. */
  36590. /**
  36591. * Gets the transition time when framing the mesh, in milliseconds
  36592. */
  36593. framingTime: number;
  36594. /**
  36595. * Define if the behavior should automatically change the configured
  36596. * camera limits and sensibilities.
  36597. */
  36598. autoCorrectCameraLimitsAndSensibility: boolean;
  36599. private _onPrePointerObservableObserver;
  36600. private _onAfterCheckInputsObserver;
  36601. private _onMeshTargetChangedObserver;
  36602. private _attachedCamera;
  36603. private _isPointerDown;
  36604. private _lastInteractionTime;
  36605. /**
  36606. * Initializes the behavior.
  36607. */
  36608. init(): void;
  36609. /**
  36610. * Attaches the behavior to its arc rotate camera.
  36611. * @param camera Defines the camera to attach the behavior to
  36612. */
  36613. attach(camera: ArcRotateCamera): void;
  36614. /**
  36615. * Detaches the behavior from its current arc rotate camera.
  36616. */
  36617. detach(): void;
  36618. private _animatables;
  36619. private _betaIsAnimating;
  36620. private _betaTransition;
  36621. private _radiusTransition;
  36622. private _vectorTransition;
  36623. /**
  36624. * Targets the given mesh and updates zoom level accordingly.
  36625. * @param mesh The mesh to target.
  36626. * @param radius Optional. If a cached radius position already exists, overrides default.
  36627. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36628. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36629. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36630. */
  36631. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36632. /**
  36633. * Targets the given mesh with its children and updates zoom level accordingly.
  36634. * @param mesh The mesh to target.
  36635. * @param radius Optional. If a cached radius position already exists, overrides default.
  36636. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36637. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36638. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36639. */
  36640. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36641. /**
  36642. * Targets the given meshes with their children and updates zoom level accordingly.
  36643. * @param meshes The mesh to target.
  36644. * @param radius Optional. If a cached radius position already exists, overrides default.
  36645. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36646. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36647. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36648. */
  36649. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36650. /**
  36651. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36652. * @param minimumWorld Determines the smaller position of the bounding box extend
  36653. * @param maximumWorld Determines the bigger position of the bounding box extend
  36654. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36655. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36656. */
  36657. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36658. /**
  36659. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36660. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36661. * frustum width.
  36662. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36663. * to fully enclose the mesh in the viewing frustum.
  36664. */
  36665. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36666. /**
  36667. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36668. * is automatically returned to its default position (expected to be above ground plane).
  36669. */
  36670. private _maintainCameraAboveGround;
  36671. /**
  36672. * Returns the frustum slope based on the canvas ratio and camera FOV
  36673. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36674. */
  36675. private _getFrustumSlope;
  36676. /**
  36677. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36678. */
  36679. private _clearAnimationLocks;
  36680. /**
  36681. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36682. */
  36683. private _applyUserInteraction;
  36684. /**
  36685. * Stops and removes all animations that have been applied to the camera
  36686. */
  36687. stopAllAnimations(): void;
  36688. /**
  36689. * Gets a value indicating if the user is moving the camera
  36690. */
  36691. readonly isUserIsMoving: boolean;
  36692. /**
  36693. * The camera can move all the way towards the mesh.
  36694. */
  36695. static IgnoreBoundsSizeMode: number;
  36696. /**
  36697. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36698. */
  36699. static FitFrustumSidesMode: number;
  36700. }
  36701. }
  36702. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36703. import { Nullable } from "babylonjs/types";
  36704. import { Camera } from "babylonjs/Cameras/camera";
  36705. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36706. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36707. /**
  36708. * Base class for Camera Pointer Inputs.
  36709. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36710. * for example usage.
  36711. */
  36712. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36713. /**
  36714. * Defines the camera the input is attached to.
  36715. */
  36716. abstract camera: Camera;
  36717. /**
  36718. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36719. */
  36720. protected _altKey: boolean;
  36721. protected _ctrlKey: boolean;
  36722. protected _metaKey: boolean;
  36723. protected _shiftKey: boolean;
  36724. /**
  36725. * Which mouse buttons were pressed at time of last mouse event.
  36726. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36727. */
  36728. protected _buttonsPressed: number;
  36729. /**
  36730. * Defines the buttons associated with the input to handle camera move.
  36731. */
  36732. buttons: number[];
  36733. /**
  36734. * Attach the input controls to a specific dom element to get the input from.
  36735. * @param element Defines the element the controls should be listened from
  36736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36737. */
  36738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36739. /**
  36740. * Detach the current controls from the specified dom element.
  36741. * @param element Defines the element to stop listening the inputs from
  36742. */
  36743. detachControl(element: Nullable<HTMLElement>): void;
  36744. /**
  36745. * Gets the class name of the current input.
  36746. * @returns the class name
  36747. */
  36748. getClassName(): string;
  36749. /**
  36750. * Get the friendly name associated with the input class.
  36751. * @returns the input friendly name
  36752. */
  36753. getSimpleName(): string;
  36754. /**
  36755. * Called on pointer POINTERDOUBLETAP event.
  36756. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36757. */
  36758. protected onDoubleTap(type: string): void;
  36759. /**
  36760. * Called on pointer POINTERMOVE event if only a single touch is active.
  36761. * Override this method to provide functionality.
  36762. */
  36763. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36764. /**
  36765. * Called on pointer POINTERMOVE event if multiple touches are active.
  36766. * Override this method to provide functionality.
  36767. */
  36768. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36769. /**
  36770. * Called on JS contextmenu event.
  36771. * Override this method to provide functionality.
  36772. */
  36773. protected onContextMenu(evt: PointerEvent): void;
  36774. /**
  36775. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36776. * press.
  36777. * Override this method to provide functionality.
  36778. */
  36779. protected onButtonDown(evt: PointerEvent): void;
  36780. /**
  36781. * Called each time a new POINTERUP event occurs. Ie, for each button
  36782. * release.
  36783. * Override this method to provide functionality.
  36784. */
  36785. protected onButtonUp(evt: PointerEvent): void;
  36786. /**
  36787. * Called when window becomes inactive.
  36788. * Override this method to provide functionality.
  36789. */
  36790. protected onLostFocus(): void;
  36791. private _pointerInput;
  36792. private _observer;
  36793. private _onLostFocus;
  36794. private pointA;
  36795. private pointB;
  36796. }
  36797. }
  36798. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36799. import { Nullable } from "babylonjs/types";
  36800. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36801. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36802. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36803. /**
  36804. * Manage the pointers inputs to control an arc rotate camera.
  36805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36806. */
  36807. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36808. /**
  36809. * Defines the camera the input is attached to.
  36810. */
  36811. camera: ArcRotateCamera;
  36812. /**
  36813. * Gets the class name of the current input.
  36814. * @returns the class name
  36815. */
  36816. getClassName(): string;
  36817. /**
  36818. * Defines the buttons associated with the input to handle camera move.
  36819. */
  36820. buttons: number[];
  36821. /**
  36822. * Defines the pointer angular sensibility along the X axis or how fast is
  36823. * the camera rotating.
  36824. */
  36825. angularSensibilityX: number;
  36826. /**
  36827. * Defines the pointer angular sensibility along the Y axis or how fast is
  36828. * the camera rotating.
  36829. */
  36830. angularSensibilityY: number;
  36831. /**
  36832. * Defines the pointer pinch precision or how fast is the camera zooming.
  36833. */
  36834. pinchPrecision: number;
  36835. /**
  36836. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36837. * from 0.
  36838. * It defines the percentage of current camera.radius to use as delta when
  36839. * pinch zoom is used.
  36840. */
  36841. pinchDeltaPercentage: number;
  36842. /**
  36843. * Defines the pointer panning sensibility or how fast is the camera moving.
  36844. */
  36845. panningSensibility: number;
  36846. /**
  36847. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36848. */
  36849. multiTouchPanning: boolean;
  36850. /**
  36851. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36852. * zoom (pinch) through multitouch.
  36853. */
  36854. multiTouchPanAndZoom: boolean;
  36855. /**
  36856. * Revers pinch action direction.
  36857. */
  36858. pinchInwards: boolean;
  36859. private _isPanClick;
  36860. private _twoFingerActivityCount;
  36861. private _isPinching;
  36862. /**
  36863. * Called on pointer POINTERMOVE event if only a single touch is active.
  36864. */
  36865. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36866. /**
  36867. * Called on pointer POINTERDOUBLETAP event.
  36868. */
  36869. protected onDoubleTap(type: string): void;
  36870. /**
  36871. * Called on pointer POINTERMOVE event if multiple touches are active.
  36872. */
  36873. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36874. /**
  36875. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36876. * press.
  36877. */
  36878. protected onButtonDown(evt: PointerEvent): void;
  36879. /**
  36880. * Called each time a new POINTERUP event occurs. Ie, for each button
  36881. * release.
  36882. */
  36883. protected onButtonUp(evt: PointerEvent): void;
  36884. /**
  36885. * Called when window becomes inactive.
  36886. */
  36887. protected onLostFocus(): void;
  36888. }
  36889. }
  36890. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36891. import { Nullable } from "babylonjs/types";
  36892. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36894. /**
  36895. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36897. */
  36898. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36899. /**
  36900. * Defines the camera the input is attached to.
  36901. */
  36902. camera: ArcRotateCamera;
  36903. /**
  36904. * Defines the list of key codes associated with the up action (increase alpha)
  36905. */
  36906. keysUp: number[];
  36907. /**
  36908. * Defines the list of key codes associated with the down action (decrease alpha)
  36909. */
  36910. keysDown: number[];
  36911. /**
  36912. * Defines the list of key codes associated with the left action (increase beta)
  36913. */
  36914. keysLeft: number[];
  36915. /**
  36916. * Defines the list of key codes associated with the right action (decrease beta)
  36917. */
  36918. keysRight: number[];
  36919. /**
  36920. * Defines the list of key codes associated with the reset action.
  36921. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36922. */
  36923. keysReset: number[];
  36924. /**
  36925. * Defines the panning sensibility of the inputs.
  36926. * (How fast is the camera paning)
  36927. */
  36928. panningSensibility: number;
  36929. /**
  36930. * Defines the zooming sensibility of the inputs.
  36931. * (How fast is the camera zooming)
  36932. */
  36933. zoomingSensibility: number;
  36934. /**
  36935. * Defines wether maintaining the alt key down switch the movement mode from
  36936. * orientation to zoom.
  36937. */
  36938. useAltToZoom: boolean;
  36939. /**
  36940. * Rotation speed of the camera
  36941. */
  36942. angularSpeed: number;
  36943. private _keys;
  36944. private _ctrlPressed;
  36945. private _altPressed;
  36946. private _onCanvasBlurObserver;
  36947. private _onKeyboardObserver;
  36948. private _engine;
  36949. private _scene;
  36950. /**
  36951. * Attach the input controls to a specific dom element to get the input from.
  36952. * @param element Defines the element the controls should be listened from
  36953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36954. */
  36955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36956. /**
  36957. * Detach the current controls from the specified dom element.
  36958. * @param element Defines the element to stop listening the inputs from
  36959. */
  36960. detachControl(element: Nullable<HTMLElement>): void;
  36961. /**
  36962. * Update the current camera state depending on the inputs that have been used this frame.
  36963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36964. */
  36965. checkInputs(): void;
  36966. /**
  36967. * Gets the class name of the current intput.
  36968. * @returns the class name
  36969. */
  36970. getClassName(): string;
  36971. /**
  36972. * Get the friendly name associated with the input class.
  36973. * @returns the input friendly name
  36974. */
  36975. getSimpleName(): string;
  36976. }
  36977. }
  36978. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36979. import { Nullable } from "babylonjs/types";
  36980. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36981. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36982. /**
  36983. * Manage the mouse wheel inputs to control an arc rotate camera.
  36984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36985. */
  36986. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36987. /**
  36988. * Defines the camera the input is attached to.
  36989. */
  36990. camera: ArcRotateCamera;
  36991. /**
  36992. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36993. */
  36994. wheelPrecision: number;
  36995. /**
  36996. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36997. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36998. */
  36999. wheelDeltaPercentage: number;
  37000. private _wheel;
  37001. private _observer;
  37002. private computeDeltaFromMouseWheelLegacyEvent;
  37003. /**
  37004. * Attach the input controls to a specific dom element to get the input from.
  37005. * @param element Defines the element the controls should be listened from
  37006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37007. */
  37008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37009. /**
  37010. * Detach the current controls from the specified dom element.
  37011. * @param element Defines the element to stop listening the inputs from
  37012. */
  37013. detachControl(element: Nullable<HTMLElement>): void;
  37014. /**
  37015. * Gets the class name of the current intput.
  37016. * @returns the class name
  37017. */
  37018. getClassName(): string;
  37019. /**
  37020. * Get the friendly name associated with the input class.
  37021. * @returns the input friendly name
  37022. */
  37023. getSimpleName(): string;
  37024. }
  37025. }
  37026. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37027. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37028. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37029. /**
  37030. * Default Inputs manager for the ArcRotateCamera.
  37031. * It groups all the default supported inputs for ease of use.
  37032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37033. */
  37034. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37035. /**
  37036. * Instantiates a new ArcRotateCameraInputsManager.
  37037. * @param camera Defines the camera the inputs belong to
  37038. */
  37039. constructor(camera: ArcRotateCamera);
  37040. /**
  37041. * Add mouse wheel input support to the input manager.
  37042. * @returns the current input manager
  37043. */
  37044. addMouseWheel(): ArcRotateCameraInputsManager;
  37045. /**
  37046. * Add pointers input support to the input manager.
  37047. * @returns the current input manager
  37048. */
  37049. addPointers(): ArcRotateCameraInputsManager;
  37050. /**
  37051. * Add keyboard input support to the input manager.
  37052. * @returns the current input manager
  37053. */
  37054. addKeyboard(): ArcRotateCameraInputsManager;
  37055. }
  37056. }
  37057. declare module "babylonjs/Cameras/arcRotateCamera" {
  37058. import { Observable } from "babylonjs/Misc/observable";
  37059. import { Nullable } from "babylonjs/types";
  37060. import { Scene } from "babylonjs/scene";
  37061. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37063. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37064. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37065. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37066. import { Camera } from "babylonjs/Cameras/camera";
  37067. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37068. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37069. import { Collider } from "babylonjs/Collisions/collider";
  37070. /**
  37071. * This represents an orbital type of camera.
  37072. *
  37073. * 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.
  37074. * 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.
  37075. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37076. */
  37077. export class ArcRotateCamera extends TargetCamera {
  37078. /**
  37079. * Defines the rotation angle of the camera along the longitudinal axis.
  37080. */
  37081. alpha: number;
  37082. /**
  37083. * Defines the rotation angle of the camera along the latitudinal axis.
  37084. */
  37085. beta: number;
  37086. /**
  37087. * Defines the radius of the camera from it s target point.
  37088. */
  37089. radius: number;
  37090. protected _target: Vector3;
  37091. protected _targetHost: Nullable<AbstractMesh>;
  37092. /**
  37093. * Defines the target point of the camera.
  37094. * The camera looks towards it form the radius distance.
  37095. */
  37096. target: Vector3;
  37097. /**
  37098. * Define the current local position of the camera in the scene
  37099. */
  37100. position: Vector3;
  37101. protected _upVector: Vector3;
  37102. protected _upToYMatrix: Matrix;
  37103. protected _YToUpMatrix: Matrix;
  37104. /**
  37105. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37106. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37107. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37108. */
  37109. upVector: Vector3;
  37110. /**
  37111. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37112. */
  37113. setMatUp(): void;
  37114. /**
  37115. * Current inertia value on the longitudinal axis.
  37116. * The bigger this number the longer it will take for the camera to stop.
  37117. */
  37118. inertialAlphaOffset: number;
  37119. /**
  37120. * Current inertia value on the latitudinal axis.
  37121. * The bigger this number the longer it will take for the camera to stop.
  37122. */
  37123. inertialBetaOffset: number;
  37124. /**
  37125. * Current inertia value on the radius axis.
  37126. * The bigger this number the longer it will take for the camera to stop.
  37127. */
  37128. inertialRadiusOffset: number;
  37129. /**
  37130. * Minimum allowed angle on the longitudinal axis.
  37131. * This can help limiting how the Camera is able to move in the scene.
  37132. */
  37133. lowerAlphaLimit: Nullable<number>;
  37134. /**
  37135. * Maximum allowed angle on the longitudinal axis.
  37136. * This can help limiting how the Camera is able to move in the scene.
  37137. */
  37138. upperAlphaLimit: Nullable<number>;
  37139. /**
  37140. * Minimum allowed angle on the latitudinal axis.
  37141. * This can help limiting how the Camera is able to move in the scene.
  37142. */
  37143. lowerBetaLimit: number;
  37144. /**
  37145. * Maximum allowed angle on the latitudinal axis.
  37146. * This can help limiting how the Camera is able to move in the scene.
  37147. */
  37148. upperBetaLimit: number;
  37149. /**
  37150. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37151. * This can help limiting how the Camera is able to move in the scene.
  37152. */
  37153. lowerRadiusLimit: Nullable<number>;
  37154. /**
  37155. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37156. * This can help limiting how the Camera is able to move in the scene.
  37157. */
  37158. upperRadiusLimit: Nullable<number>;
  37159. /**
  37160. * Defines the current inertia value used during panning of the camera along the X axis.
  37161. */
  37162. inertialPanningX: number;
  37163. /**
  37164. * Defines the current inertia value used during panning of the camera along the Y axis.
  37165. */
  37166. inertialPanningY: number;
  37167. /**
  37168. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37169. * Basically if your fingers moves away from more than this distance you will be considered
  37170. * in pinch mode.
  37171. */
  37172. pinchToPanMaxDistance: number;
  37173. /**
  37174. * Defines the maximum distance the camera can pan.
  37175. * This could help keeping the cammera always in your scene.
  37176. */
  37177. panningDistanceLimit: Nullable<number>;
  37178. /**
  37179. * Defines the target of the camera before paning.
  37180. */
  37181. panningOriginTarget: Vector3;
  37182. /**
  37183. * Defines the value of the inertia used during panning.
  37184. * 0 would mean stop inertia and one would mean no decelleration at all.
  37185. */
  37186. panningInertia: number;
  37187. /**
  37188. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37189. */
  37190. angularSensibilityX: number;
  37191. /**
  37192. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37193. */
  37194. angularSensibilityY: number;
  37195. /**
  37196. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37197. */
  37198. pinchPrecision: number;
  37199. /**
  37200. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37201. * It will be used instead of pinchDeltaPrecision if different from 0.
  37202. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37203. */
  37204. pinchDeltaPercentage: number;
  37205. /**
  37206. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37207. */
  37208. panningSensibility: number;
  37209. /**
  37210. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37211. */
  37212. keysUp: number[];
  37213. /**
  37214. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37215. */
  37216. keysDown: number[];
  37217. /**
  37218. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37219. */
  37220. keysLeft: number[];
  37221. /**
  37222. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37223. */
  37224. keysRight: number[];
  37225. /**
  37226. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37227. */
  37228. wheelPrecision: number;
  37229. /**
  37230. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37231. * It will be used instead of pinchDeltaPrecision if different from 0.
  37232. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37233. */
  37234. wheelDeltaPercentage: number;
  37235. /**
  37236. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37237. */
  37238. zoomOnFactor: number;
  37239. /**
  37240. * Defines a screen offset for the camera position.
  37241. */
  37242. targetScreenOffset: Vector2;
  37243. /**
  37244. * Allows the camera to be completely reversed.
  37245. * If false the camera can not arrive upside down.
  37246. */
  37247. allowUpsideDown: boolean;
  37248. /**
  37249. * Define if double tap/click is used to restore the previously saved state of the camera.
  37250. */
  37251. useInputToRestoreState: boolean;
  37252. /** @hidden */
  37253. _viewMatrix: Matrix;
  37254. /** @hidden */
  37255. _useCtrlForPanning: boolean;
  37256. /** @hidden */
  37257. _panningMouseButton: number;
  37258. /**
  37259. * Defines the input associated to the camera.
  37260. */
  37261. inputs: ArcRotateCameraInputsManager;
  37262. /** @hidden */
  37263. _reset: () => void;
  37264. /**
  37265. * Defines the allowed panning axis.
  37266. */
  37267. panningAxis: Vector3;
  37268. protected _localDirection: Vector3;
  37269. protected _transformedDirection: Vector3;
  37270. private _bouncingBehavior;
  37271. /**
  37272. * Gets the bouncing behavior of the camera if it has been enabled.
  37273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37274. */
  37275. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37276. /**
  37277. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37279. */
  37280. useBouncingBehavior: boolean;
  37281. private _framingBehavior;
  37282. /**
  37283. * Gets the framing behavior of the camera if it has been enabled.
  37284. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37285. */
  37286. readonly framingBehavior: Nullable<FramingBehavior>;
  37287. /**
  37288. * Defines if the framing behavior of the camera is enabled on the camera.
  37289. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37290. */
  37291. useFramingBehavior: boolean;
  37292. private _autoRotationBehavior;
  37293. /**
  37294. * Gets the auto rotation behavior of the camera if it has been enabled.
  37295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37296. */
  37297. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37298. /**
  37299. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37300. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37301. */
  37302. useAutoRotationBehavior: boolean;
  37303. /**
  37304. * Observable triggered when the mesh target has been changed on the camera.
  37305. */
  37306. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37307. /**
  37308. * Event raised when the camera is colliding with a mesh.
  37309. */
  37310. onCollide: (collidedMesh: AbstractMesh) => void;
  37311. /**
  37312. * Defines whether the camera should check collision with the objects oh the scene.
  37313. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37314. */
  37315. checkCollisions: boolean;
  37316. /**
  37317. * Defines the collision radius of the camera.
  37318. * This simulates a sphere around the camera.
  37319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37320. */
  37321. collisionRadius: Vector3;
  37322. protected _collider: Collider;
  37323. protected _previousPosition: Vector3;
  37324. protected _collisionVelocity: Vector3;
  37325. protected _newPosition: Vector3;
  37326. protected _previousAlpha: number;
  37327. protected _previousBeta: number;
  37328. protected _previousRadius: number;
  37329. protected _collisionTriggered: boolean;
  37330. protected _targetBoundingCenter: Nullable<Vector3>;
  37331. private _computationVector;
  37332. /**
  37333. * Instantiates a new ArcRotateCamera in a given scene
  37334. * @param name Defines the name of the camera
  37335. * @param alpha Defines the camera rotation along the logitudinal axis
  37336. * @param beta Defines the camera rotation along the latitudinal axis
  37337. * @param radius Defines the camera distance from its target
  37338. * @param target Defines the camera target
  37339. * @param scene Defines the scene the camera belongs to
  37340. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37341. */
  37342. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37343. /** @hidden */
  37344. _initCache(): void;
  37345. /** @hidden */
  37346. _updateCache(ignoreParentClass?: boolean): void;
  37347. protected _getTargetPosition(): Vector3;
  37348. private _storedAlpha;
  37349. private _storedBeta;
  37350. private _storedRadius;
  37351. private _storedTarget;
  37352. private _storedTargetScreenOffset;
  37353. /**
  37354. * Stores the current state of the camera (alpha, beta, radius and target)
  37355. * @returns the camera itself
  37356. */
  37357. storeState(): Camera;
  37358. /**
  37359. * @hidden
  37360. * Restored camera state. You must call storeState() first
  37361. */
  37362. _restoreStateValues(): boolean;
  37363. /** @hidden */
  37364. _isSynchronizedViewMatrix(): boolean;
  37365. /**
  37366. * Attached controls to the current camera.
  37367. * @param element Defines the element the controls should be listened from
  37368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37369. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37370. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37371. */
  37372. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37373. /**
  37374. * Detach the current controls from the camera.
  37375. * The camera will stop reacting to inputs.
  37376. * @param element Defines the element to stop listening the inputs from
  37377. */
  37378. detachControl(element: HTMLElement): void;
  37379. /** @hidden */
  37380. _checkInputs(): void;
  37381. protected _checkLimits(): void;
  37382. /**
  37383. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37384. */
  37385. rebuildAnglesAndRadius(): void;
  37386. /**
  37387. * Use a position to define the current camera related information like aplha, beta and radius
  37388. * @param position Defines the position to set the camera at
  37389. */
  37390. setPosition(position: Vector3): void;
  37391. /**
  37392. * Defines the target the camera should look at.
  37393. * This will automatically adapt alpha beta and radius to fit within the new target.
  37394. * @param target Defines the new target as a Vector or a mesh
  37395. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37396. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37397. */
  37398. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37399. /** @hidden */
  37400. _getViewMatrix(): Matrix;
  37401. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37402. /**
  37403. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37404. * @param meshes Defines the mesh to zoom on
  37405. * @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)
  37406. */
  37407. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37408. /**
  37409. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37410. * The target will be changed but the radius
  37411. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37412. * @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)
  37413. */
  37414. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37415. min: Vector3;
  37416. max: Vector3;
  37417. distance: number;
  37418. }, doNotUpdateMaxZ?: boolean): void;
  37419. /**
  37420. * @override
  37421. * Override Camera.createRigCamera
  37422. */
  37423. createRigCamera(name: string, cameraIndex: number): Camera;
  37424. /**
  37425. * @hidden
  37426. * @override
  37427. * Override Camera._updateRigCameras
  37428. */
  37429. _updateRigCameras(): void;
  37430. /**
  37431. * Destroy the camera and release the current resources hold by it.
  37432. */
  37433. dispose(): void;
  37434. /**
  37435. * Gets the current object class name.
  37436. * @return the class name
  37437. */
  37438. getClassName(): string;
  37439. }
  37440. }
  37441. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37442. import { Behavior } from "babylonjs/Behaviors/behavior";
  37443. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37444. /**
  37445. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37446. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37447. */
  37448. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37449. /**
  37450. * Gets the name of the behavior.
  37451. */
  37452. readonly name: string;
  37453. private _zoomStopsAnimation;
  37454. private _idleRotationSpeed;
  37455. private _idleRotationWaitTime;
  37456. private _idleRotationSpinupTime;
  37457. /**
  37458. * Sets the flag that indicates if user zooming should stop animation.
  37459. */
  37460. /**
  37461. * Gets the flag that indicates if user zooming should stop animation.
  37462. */
  37463. zoomStopsAnimation: boolean;
  37464. /**
  37465. * Sets the default speed at which the camera rotates around the model.
  37466. */
  37467. /**
  37468. * Gets the default speed at which the camera rotates around the model.
  37469. */
  37470. idleRotationSpeed: number;
  37471. /**
  37472. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37473. */
  37474. /**
  37475. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37476. */
  37477. idleRotationWaitTime: number;
  37478. /**
  37479. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37480. */
  37481. /**
  37482. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37483. */
  37484. idleRotationSpinupTime: number;
  37485. /**
  37486. * Gets a value indicating if the camera is currently rotating because of this behavior
  37487. */
  37488. readonly rotationInProgress: boolean;
  37489. private _onPrePointerObservableObserver;
  37490. private _onAfterCheckInputsObserver;
  37491. private _attachedCamera;
  37492. private _isPointerDown;
  37493. private _lastFrameTime;
  37494. private _lastInteractionTime;
  37495. private _cameraRotationSpeed;
  37496. /**
  37497. * Initializes the behavior.
  37498. */
  37499. init(): void;
  37500. /**
  37501. * Attaches the behavior to its arc rotate camera.
  37502. * @param camera Defines the camera to attach the behavior to
  37503. */
  37504. attach(camera: ArcRotateCamera): void;
  37505. /**
  37506. * Detaches the behavior from its current arc rotate camera.
  37507. */
  37508. detach(): void;
  37509. /**
  37510. * Returns true if user is scrolling.
  37511. * @return true if user is scrolling.
  37512. */
  37513. private _userIsZooming;
  37514. private _lastFrameRadius;
  37515. private _shouldAnimationStopForInteraction;
  37516. /**
  37517. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37518. */
  37519. private _applyUserInteraction;
  37520. private _userIsMoving;
  37521. }
  37522. }
  37523. declare module "babylonjs/Behaviors/Cameras/index" {
  37524. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37525. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37526. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37527. }
  37528. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37529. import { Mesh } from "babylonjs/Meshes/mesh";
  37530. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37531. import { Behavior } from "babylonjs/Behaviors/behavior";
  37532. /**
  37533. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37534. */
  37535. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37536. private ui;
  37537. /**
  37538. * The name of the behavior
  37539. */
  37540. name: string;
  37541. /**
  37542. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37543. */
  37544. distanceAwayFromFace: number;
  37545. /**
  37546. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37547. */
  37548. distanceAwayFromBottomOfFace: number;
  37549. private _faceVectors;
  37550. private _target;
  37551. private _scene;
  37552. private _onRenderObserver;
  37553. private _tmpMatrix;
  37554. private _tmpVector;
  37555. /**
  37556. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37557. * @param ui The transform node that should be attched to the mesh
  37558. */
  37559. constructor(ui: TransformNode);
  37560. /**
  37561. * Initializes the behavior
  37562. */
  37563. init(): void;
  37564. private _closestFace;
  37565. private _zeroVector;
  37566. private _lookAtTmpMatrix;
  37567. private _lookAtToRef;
  37568. /**
  37569. * Attaches the AttachToBoxBehavior to the passed in mesh
  37570. * @param target The mesh that the specified node will be attached to
  37571. */
  37572. attach(target: Mesh): void;
  37573. /**
  37574. * Detaches the behavior from the mesh
  37575. */
  37576. detach(): void;
  37577. }
  37578. }
  37579. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37580. import { Behavior } from "babylonjs/Behaviors/behavior";
  37581. import { Mesh } from "babylonjs/Meshes/mesh";
  37582. /**
  37583. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37584. */
  37585. export class FadeInOutBehavior implements Behavior<Mesh> {
  37586. /**
  37587. * Time in milliseconds to delay before fading in (Default: 0)
  37588. */
  37589. delay: number;
  37590. /**
  37591. * Time in milliseconds for the mesh to fade in (Default: 300)
  37592. */
  37593. fadeInTime: number;
  37594. private _millisecondsPerFrame;
  37595. private _hovered;
  37596. private _hoverValue;
  37597. private _ownerNode;
  37598. /**
  37599. * Instatiates the FadeInOutBehavior
  37600. */
  37601. constructor();
  37602. /**
  37603. * The name of the behavior
  37604. */
  37605. readonly name: string;
  37606. /**
  37607. * Initializes the behavior
  37608. */
  37609. init(): void;
  37610. /**
  37611. * Attaches the fade behavior on the passed in mesh
  37612. * @param ownerNode The mesh that will be faded in/out once attached
  37613. */
  37614. attach(ownerNode: Mesh): void;
  37615. /**
  37616. * Detaches the behavior from the mesh
  37617. */
  37618. detach(): void;
  37619. /**
  37620. * Triggers the mesh to begin fading in or out
  37621. * @param value if the object should fade in or out (true to fade in)
  37622. */
  37623. fadeIn(value: boolean): void;
  37624. private _update;
  37625. private _setAllVisibility;
  37626. }
  37627. }
  37628. declare module "babylonjs/Misc/pivotTools" {
  37629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37630. /**
  37631. * Class containing a set of static utilities functions for managing Pivots
  37632. * @hidden
  37633. */
  37634. export class PivotTools {
  37635. private static _PivotCached;
  37636. private static _OldPivotPoint;
  37637. private static _PivotTranslation;
  37638. private static _PivotTmpVector;
  37639. /** @hidden */
  37640. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37641. /** @hidden */
  37642. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37643. }
  37644. }
  37645. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37646. import { Scene } from "babylonjs/scene";
  37647. import { Vector4 } from "babylonjs/Maths/math.vector";
  37648. import { Mesh } from "babylonjs/Meshes/mesh";
  37649. import { Nullable } from "babylonjs/types";
  37650. import { Plane } from "babylonjs/Maths/math.plane";
  37651. /**
  37652. * Class containing static functions to help procedurally build meshes
  37653. */
  37654. export class PlaneBuilder {
  37655. /**
  37656. * Creates a plane mesh
  37657. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37658. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37659. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37663. * @param name defines the name of the mesh
  37664. * @param options defines the options used to create the mesh
  37665. * @param scene defines the hosting scene
  37666. * @returns the plane mesh
  37667. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37668. */
  37669. static CreatePlane(name: string, options: {
  37670. size?: number;
  37671. width?: number;
  37672. height?: number;
  37673. sideOrientation?: number;
  37674. frontUVs?: Vector4;
  37675. backUVs?: Vector4;
  37676. updatable?: boolean;
  37677. sourcePlane?: Plane;
  37678. }, scene?: Nullable<Scene>): Mesh;
  37679. }
  37680. }
  37681. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37682. import { Behavior } from "babylonjs/Behaviors/behavior";
  37683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37684. import { Observable } from "babylonjs/Misc/observable";
  37685. import { Vector3 } from "babylonjs/Maths/math.vector";
  37686. import { Ray } from "babylonjs/Culling/ray";
  37687. import "babylonjs/Meshes/Builders/planeBuilder";
  37688. /**
  37689. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37690. */
  37691. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37692. private static _AnyMouseID;
  37693. /**
  37694. * Abstract mesh the behavior is set on
  37695. */
  37696. attachedNode: AbstractMesh;
  37697. private _dragPlane;
  37698. private _scene;
  37699. private _pointerObserver;
  37700. private _beforeRenderObserver;
  37701. private static _planeScene;
  37702. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37703. /**
  37704. * 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)
  37705. */
  37706. maxDragAngle: number;
  37707. /**
  37708. * @hidden
  37709. */
  37710. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37711. /**
  37712. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37713. */
  37714. currentDraggingPointerID: number;
  37715. /**
  37716. * The last position where the pointer hit the drag plane in world space
  37717. */
  37718. lastDragPosition: Vector3;
  37719. /**
  37720. * If the behavior is currently in a dragging state
  37721. */
  37722. dragging: boolean;
  37723. /**
  37724. * 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)
  37725. */
  37726. dragDeltaRatio: number;
  37727. /**
  37728. * If the drag plane orientation should be updated during the dragging (Default: true)
  37729. */
  37730. updateDragPlane: boolean;
  37731. private _debugMode;
  37732. private _moving;
  37733. /**
  37734. * Fires each time the attached mesh is dragged with the pointer
  37735. * * delta between last drag position and current drag position in world space
  37736. * * dragDistance along the drag axis
  37737. * * dragPlaneNormal normal of the current drag plane used during the drag
  37738. * * dragPlanePoint in world space where the drag intersects the drag plane
  37739. */
  37740. onDragObservable: Observable<{
  37741. delta: Vector3;
  37742. dragPlanePoint: Vector3;
  37743. dragPlaneNormal: Vector3;
  37744. dragDistance: number;
  37745. pointerId: number;
  37746. }>;
  37747. /**
  37748. * Fires each time a drag begins (eg. mouse down on mesh)
  37749. */
  37750. onDragStartObservable: Observable<{
  37751. dragPlanePoint: Vector3;
  37752. pointerId: number;
  37753. }>;
  37754. /**
  37755. * Fires each time a drag ends (eg. mouse release after drag)
  37756. */
  37757. onDragEndObservable: Observable<{
  37758. dragPlanePoint: Vector3;
  37759. pointerId: number;
  37760. }>;
  37761. /**
  37762. * If the attached mesh should be moved when dragged
  37763. */
  37764. moveAttached: boolean;
  37765. /**
  37766. * If the drag behavior will react to drag events (Default: true)
  37767. */
  37768. enabled: boolean;
  37769. /**
  37770. * If pointer events should start and release the drag (Default: true)
  37771. */
  37772. startAndReleaseDragOnPointerEvents: boolean;
  37773. /**
  37774. * If camera controls should be detached during the drag
  37775. */
  37776. detachCameraControls: boolean;
  37777. /**
  37778. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37779. */
  37780. useObjectOrienationForDragging: boolean;
  37781. private _options;
  37782. /**
  37783. * Creates a pointer drag behavior that can be attached to a mesh
  37784. * @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)
  37785. */
  37786. constructor(options?: {
  37787. dragAxis?: Vector3;
  37788. dragPlaneNormal?: Vector3;
  37789. });
  37790. /**
  37791. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37792. */
  37793. validateDrag: (targetPosition: Vector3) => boolean;
  37794. /**
  37795. * The name of the behavior
  37796. */
  37797. readonly name: string;
  37798. /**
  37799. * Initializes the behavior
  37800. */
  37801. init(): void;
  37802. private _tmpVector;
  37803. private _alternatePickedPoint;
  37804. private _worldDragAxis;
  37805. private _targetPosition;
  37806. private _attachedElement;
  37807. /**
  37808. * Attaches the drag behavior the passed in mesh
  37809. * @param ownerNode The mesh that will be dragged around once attached
  37810. */
  37811. attach(ownerNode: AbstractMesh): void;
  37812. /**
  37813. * Force relase the drag action by code.
  37814. */
  37815. releaseDrag(): void;
  37816. private _startDragRay;
  37817. private _lastPointerRay;
  37818. /**
  37819. * Simulates the start of a pointer drag event on the behavior
  37820. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37821. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37822. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37823. */
  37824. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37825. private _startDrag;
  37826. private _dragDelta;
  37827. private _moveDrag;
  37828. private _pickWithRayOnDragPlane;
  37829. private _pointA;
  37830. private _pointB;
  37831. private _pointC;
  37832. private _lineA;
  37833. private _lineB;
  37834. private _localAxis;
  37835. private _lookAt;
  37836. private _updateDragPlanePosition;
  37837. /**
  37838. * Detaches the behavior from the mesh
  37839. */
  37840. detach(): void;
  37841. }
  37842. }
  37843. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37844. import { Mesh } from "babylonjs/Meshes/mesh";
  37845. import { Behavior } from "babylonjs/Behaviors/behavior";
  37846. /**
  37847. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37848. */
  37849. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37850. private _dragBehaviorA;
  37851. private _dragBehaviorB;
  37852. private _startDistance;
  37853. private _initialScale;
  37854. private _targetScale;
  37855. private _ownerNode;
  37856. private _sceneRenderObserver;
  37857. /**
  37858. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37859. */
  37860. constructor();
  37861. /**
  37862. * The name of the behavior
  37863. */
  37864. readonly name: string;
  37865. /**
  37866. * Initializes the behavior
  37867. */
  37868. init(): void;
  37869. private _getCurrentDistance;
  37870. /**
  37871. * Attaches the scale behavior the passed in mesh
  37872. * @param ownerNode The mesh that will be scaled around once attached
  37873. */
  37874. attach(ownerNode: Mesh): void;
  37875. /**
  37876. * Detaches the behavior from the mesh
  37877. */
  37878. detach(): void;
  37879. }
  37880. }
  37881. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37882. import { Behavior } from "babylonjs/Behaviors/behavior";
  37883. import { Mesh } from "babylonjs/Meshes/mesh";
  37884. import { Observable } from "babylonjs/Misc/observable";
  37885. /**
  37886. * 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
  37887. */
  37888. export class SixDofDragBehavior implements Behavior<Mesh> {
  37889. private static _virtualScene;
  37890. private _ownerNode;
  37891. private _sceneRenderObserver;
  37892. private _scene;
  37893. private _targetPosition;
  37894. private _virtualOriginMesh;
  37895. private _virtualDragMesh;
  37896. private _pointerObserver;
  37897. private _moving;
  37898. private _startingOrientation;
  37899. /**
  37900. * 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)
  37901. */
  37902. private zDragFactor;
  37903. /**
  37904. * If the object should rotate to face the drag origin
  37905. */
  37906. rotateDraggedObject: boolean;
  37907. /**
  37908. * If the behavior is currently in a dragging state
  37909. */
  37910. dragging: boolean;
  37911. /**
  37912. * 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)
  37913. */
  37914. dragDeltaRatio: number;
  37915. /**
  37916. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37917. */
  37918. currentDraggingPointerID: number;
  37919. /**
  37920. * If camera controls should be detached during the drag
  37921. */
  37922. detachCameraControls: boolean;
  37923. /**
  37924. * Fires each time a drag starts
  37925. */
  37926. onDragStartObservable: Observable<{}>;
  37927. /**
  37928. * Fires each time a drag ends (eg. mouse release after drag)
  37929. */
  37930. onDragEndObservable: Observable<{}>;
  37931. /**
  37932. * 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
  37933. */
  37934. constructor();
  37935. /**
  37936. * The name of the behavior
  37937. */
  37938. readonly name: string;
  37939. /**
  37940. * Initializes the behavior
  37941. */
  37942. init(): void;
  37943. /**
  37944. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37945. */
  37946. private readonly _pointerCamera;
  37947. /**
  37948. * Attaches the scale behavior the passed in mesh
  37949. * @param ownerNode The mesh that will be scaled around once attached
  37950. */
  37951. attach(ownerNode: Mesh): void;
  37952. /**
  37953. * Detaches the behavior from the mesh
  37954. */
  37955. detach(): void;
  37956. }
  37957. }
  37958. declare module "babylonjs/Behaviors/Meshes/index" {
  37959. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37960. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37961. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37962. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37963. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37964. }
  37965. declare module "babylonjs/Behaviors/index" {
  37966. export * from "babylonjs/Behaviors/behavior";
  37967. export * from "babylonjs/Behaviors/Cameras/index";
  37968. export * from "babylonjs/Behaviors/Meshes/index";
  37969. }
  37970. declare module "babylonjs/Bones/boneIKController" {
  37971. import { Bone } from "babylonjs/Bones/bone";
  37972. import { Vector3 } from "babylonjs/Maths/math.vector";
  37973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37974. import { Nullable } from "babylonjs/types";
  37975. /**
  37976. * Class used to apply inverse kinematics to bones
  37977. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37978. */
  37979. export class BoneIKController {
  37980. private static _tmpVecs;
  37981. private static _tmpQuat;
  37982. private static _tmpMats;
  37983. /**
  37984. * Gets or sets the target mesh
  37985. */
  37986. targetMesh: AbstractMesh;
  37987. /** Gets or sets the mesh used as pole */
  37988. poleTargetMesh: AbstractMesh;
  37989. /**
  37990. * Gets or sets the bone used as pole
  37991. */
  37992. poleTargetBone: Nullable<Bone>;
  37993. /**
  37994. * Gets or sets the target position
  37995. */
  37996. targetPosition: Vector3;
  37997. /**
  37998. * Gets or sets the pole target position
  37999. */
  38000. poleTargetPosition: Vector3;
  38001. /**
  38002. * Gets or sets the pole target local offset
  38003. */
  38004. poleTargetLocalOffset: Vector3;
  38005. /**
  38006. * Gets or sets the pole angle
  38007. */
  38008. poleAngle: number;
  38009. /**
  38010. * Gets or sets the mesh associated with the controller
  38011. */
  38012. mesh: AbstractMesh;
  38013. /**
  38014. * 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)
  38015. */
  38016. slerpAmount: number;
  38017. private _bone1Quat;
  38018. private _bone1Mat;
  38019. private _bone2Ang;
  38020. private _bone1;
  38021. private _bone2;
  38022. private _bone1Length;
  38023. private _bone2Length;
  38024. private _maxAngle;
  38025. private _maxReach;
  38026. private _rightHandedSystem;
  38027. private _bendAxis;
  38028. private _slerping;
  38029. private _adjustRoll;
  38030. /**
  38031. * Gets or sets maximum allowed angle
  38032. */
  38033. maxAngle: number;
  38034. /**
  38035. * Creates a new BoneIKController
  38036. * @param mesh defines the mesh to control
  38037. * @param bone defines the bone to control
  38038. * @param options defines options to set up the controller
  38039. */
  38040. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38041. targetMesh?: AbstractMesh;
  38042. poleTargetMesh?: AbstractMesh;
  38043. poleTargetBone?: Bone;
  38044. poleTargetLocalOffset?: Vector3;
  38045. poleAngle?: number;
  38046. bendAxis?: Vector3;
  38047. maxAngle?: number;
  38048. slerpAmount?: number;
  38049. });
  38050. private _setMaxAngle;
  38051. /**
  38052. * Force the controller to update the bones
  38053. */
  38054. update(): void;
  38055. }
  38056. }
  38057. declare module "babylonjs/Bones/boneLookController" {
  38058. import { Vector3 } from "babylonjs/Maths/math.vector";
  38059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38060. import { Bone } from "babylonjs/Bones/bone";
  38061. import { Space } from "babylonjs/Maths/math.axis";
  38062. /**
  38063. * Class used to make a bone look toward a point in space
  38064. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38065. */
  38066. export class BoneLookController {
  38067. private static _tmpVecs;
  38068. private static _tmpQuat;
  38069. private static _tmpMats;
  38070. /**
  38071. * The target Vector3 that the bone will look at
  38072. */
  38073. target: Vector3;
  38074. /**
  38075. * The mesh that the bone is attached to
  38076. */
  38077. mesh: AbstractMesh;
  38078. /**
  38079. * The bone that will be looking to the target
  38080. */
  38081. bone: Bone;
  38082. /**
  38083. * The up axis of the coordinate system that is used when the bone is rotated
  38084. */
  38085. upAxis: Vector3;
  38086. /**
  38087. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38088. */
  38089. upAxisSpace: Space;
  38090. /**
  38091. * Used to make an adjustment to the yaw of the bone
  38092. */
  38093. adjustYaw: number;
  38094. /**
  38095. * Used to make an adjustment to the pitch of the bone
  38096. */
  38097. adjustPitch: number;
  38098. /**
  38099. * Used to make an adjustment to the roll of the bone
  38100. */
  38101. adjustRoll: number;
  38102. /**
  38103. * 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)
  38104. */
  38105. slerpAmount: number;
  38106. private _minYaw;
  38107. private _maxYaw;
  38108. private _minPitch;
  38109. private _maxPitch;
  38110. private _minYawSin;
  38111. private _minYawCos;
  38112. private _maxYawSin;
  38113. private _maxYawCos;
  38114. private _midYawConstraint;
  38115. private _minPitchTan;
  38116. private _maxPitchTan;
  38117. private _boneQuat;
  38118. private _slerping;
  38119. private _transformYawPitch;
  38120. private _transformYawPitchInv;
  38121. private _firstFrameSkipped;
  38122. private _yawRange;
  38123. private _fowardAxis;
  38124. /**
  38125. * Gets or sets the minimum yaw angle that the bone can look to
  38126. */
  38127. minYaw: number;
  38128. /**
  38129. * Gets or sets the maximum yaw angle that the bone can look to
  38130. */
  38131. maxYaw: number;
  38132. /**
  38133. * Gets or sets the minimum pitch angle that the bone can look to
  38134. */
  38135. minPitch: number;
  38136. /**
  38137. * Gets or sets the maximum pitch angle that the bone can look to
  38138. */
  38139. maxPitch: number;
  38140. /**
  38141. * Create a BoneLookController
  38142. * @param mesh the mesh that the bone belongs to
  38143. * @param bone the bone that will be looking to the target
  38144. * @param target the target Vector3 to look at
  38145. * @param options optional settings:
  38146. * * maxYaw: the maximum angle the bone will yaw to
  38147. * * minYaw: the minimum angle the bone will yaw to
  38148. * * maxPitch: the maximum angle the bone will pitch to
  38149. * * minPitch: the minimum angle the bone will yaw to
  38150. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38151. * * upAxis: the up axis of the coordinate system
  38152. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38153. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38154. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38155. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38156. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38157. * * adjustRoll: used to make an adjustment to the roll of the bone
  38158. **/
  38159. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38160. maxYaw?: number;
  38161. minYaw?: number;
  38162. maxPitch?: number;
  38163. minPitch?: number;
  38164. slerpAmount?: number;
  38165. upAxis?: Vector3;
  38166. upAxisSpace?: Space;
  38167. yawAxis?: Vector3;
  38168. pitchAxis?: Vector3;
  38169. adjustYaw?: number;
  38170. adjustPitch?: number;
  38171. adjustRoll?: number;
  38172. });
  38173. /**
  38174. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38175. */
  38176. update(): void;
  38177. private _getAngleDiff;
  38178. private _getAngleBetween;
  38179. private _isAngleBetween;
  38180. }
  38181. }
  38182. declare module "babylonjs/Bones/index" {
  38183. export * from "babylonjs/Bones/bone";
  38184. export * from "babylonjs/Bones/boneIKController";
  38185. export * from "babylonjs/Bones/boneLookController";
  38186. export * from "babylonjs/Bones/skeleton";
  38187. }
  38188. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38189. import { Nullable } from "babylonjs/types";
  38190. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38191. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38192. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38193. /**
  38194. * Manage the gamepad inputs to control an arc rotate camera.
  38195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38196. */
  38197. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38198. /**
  38199. * Defines the camera the input is attached to.
  38200. */
  38201. camera: ArcRotateCamera;
  38202. /**
  38203. * Defines the gamepad the input is gathering event from.
  38204. */
  38205. gamepad: Nullable<Gamepad>;
  38206. /**
  38207. * Defines the gamepad rotation sensiblity.
  38208. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38209. */
  38210. gamepadRotationSensibility: number;
  38211. /**
  38212. * Defines the gamepad move sensiblity.
  38213. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38214. */
  38215. gamepadMoveSensibility: number;
  38216. private _onGamepadConnectedObserver;
  38217. private _onGamepadDisconnectedObserver;
  38218. /**
  38219. * Attach the input controls to a specific dom element to get the input from.
  38220. * @param element Defines the element the controls should be listened from
  38221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38222. */
  38223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38224. /**
  38225. * Detach the current controls from the specified dom element.
  38226. * @param element Defines the element to stop listening the inputs from
  38227. */
  38228. detachControl(element: Nullable<HTMLElement>): void;
  38229. /**
  38230. * Update the current camera state depending on the inputs that have been used this frame.
  38231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38232. */
  38233. checkInputs(): void;
  38234. /**
  38235. * Gets the class name of the current intput.
  38236. * @returns the class name
  38237. */
  38238. getClassName(): string;
  38239. /**
  38240. * Get the friendly name associated with the input class.
  38241. * @returns the input friendly name
  38242. */
  38243. getSimpleName(): string;
  38244. }
  38245. }
  38246. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38247. import { Nullable } from "babylonjs/types";
  38248. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38249. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38250. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38251. interface ArcRotateCameraInputsManager {
  38252. /**
  38253. * Add orientation input support to the input manager.
  38254. * @returns the current input manager
  38255. */
  38256. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38257. }
  38258. }
  38259. /**
  38260. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38262. */
  38263. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38264. /**
  38265. * Defines the camera the input is attached to.
  38266. */
  38267. camera: ArcRotateCamera;
  38268. /**
  38269. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38270. */
  38271. alphaCorrection: number;
  38272. /**
  38273. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38274. */
  38275. gammaCorrection: number;
  38276. private _alpha;
  38277. private _gamma;
  38278. private _dirty;
  38279. private _deviceOrientationHandler;
  38280. /**
  38281. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38282. */
  38283. constructor();
  38284. /**
  38285. * Attach the input controls to a specific dom element to get the input from.
  38286. * @param element Defines the element the controls should be listened from
  38287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38288. */
  38289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38290. /** @hidden */
  38291. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38292. /**
  38293. * Update the current camera state depending on the inputs that have been used this frame.
  38294. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38295. */
  38296. checkInputs(): void;
  38297. /**
  38298. * Detach the current controls from the specified dom element.
  38299. * @param element Defines the element to stop listening the inputs from
  38300. */
  38301. detachControl(element: Nullable<HTMLElement>): void;
  38302. /**
  38303. * Gets the class name of the current intput.
  38304. * @returns the class name
  38305. */
  38306. getClassName(): string;
  38307. /**
  38308. * Get the friendly name associated with the input class.
  38309. * @returns the input friendly name
  38310. */
  38311. getSimpleName(): string;
  38312. }
  38313. }
  38314. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38315. import { Nullable } from "babylonjs/types";
  38316. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38317. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38318. /**
  38319. * Listen to mouse events to control the camera.
  38320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38321. */
  38322. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38323. /**
  38324. * Defines the camera the input is attached to.
  38325. */
  38326. camera: FlyCamera;
  38327. /**
  38328. * Defines if touch is enabled. (Default is true.)
  38329. */
  38330. touchEnabled: boolean;
  38331. /**
  38332. * Defines the buttons associated with the input to handle camera rotation.
  38333. */
  38334. buttons: number[];
  38335. /**
  38336. * Assign buttons for Yaw control.
  38337. */
  38338. buttonsYaw: number[];
  38339. /**
  38340. * Assign buttons for Pitch control.
  38341. */
  38342. buttonsPitch: number[];
  38343. /**
  38344. * Assign buttons for Roll control.
  38345. */
  38346. buttonsRoll: number[];
  38347. /**
  38348. * Detect if any button is being pressed while mouse is moved.
  38349. * -1 = Mouse locked.
  38350. * 0 = Left button.
  38351. * 1 = Middle Button.
  38352. * 2 = Right Button.
  38353. */
  38354. activeButton: number;
  38355. /**
  38356. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38357. * Higher values reduce its sensitivity.
  38358. */
  38359. angularSensibility: number;
  38360. private _mousemoveCallback;
  38361. private _observer;
  38362. private _rollObserver;
  38363. private previousPosition;
  38364. private noPreventDefault;
  38365. private element;
  38366. /**
  38367. * Listen to mouse events to control the camera.
  38368. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38370. */
  38371. constructor(touchEnabled?: boolean);
  38372. /**
  38373. * Attach the mouse control to the HTML DOM element.
  38374. * @param element Defines the element that listens to the input events.
  38375. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38376. */
  38377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38378. /**
  38379. * Detach the current controls from the specified dom element.
  38380. * @param element Defines the element to stop listening the inputs from
  38381. */
  38382. detachControl(element: Nullable<HTMLElement>): void;
  38383. /**
  38384. * Gets the class name of the current input.
  38385. * @returns the class name.
  38386. */
  38387. getClassName(): string;
  38388. /**
  38389. * Get the friendly name associated with the input class.
  38390. * @returns the input's friendly name.
  38391. */
  38392. getSimpleName(): string;
  38393. private _pointerInput;
  38394. private _onMouseMove;
  38395. /**
  38396. * Rotate camera by mouse offset.
  38397. */
  38398. private rotateCamera;
  38399. }
  38400. }
  38401. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38402. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38403. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38404. /**
  38405. * Default Inputs manager for the FlyCamera.
  38406. * It groups all the default supported inputs for ease of use.
  38407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38408. */
  38409. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38410. /**
  38411. * Instantiates a new FlyCameraInputsManager.
  38412. * @param camera Defines the camera the inputs belong to.
  38413. */
  38414. constructor(camera: FlyCamera);
  38415. /**
  38416. * Add keyboard input support to the input manager.
  38417. * @returns the new FlyCameraKeyboardMoveInput().
  38418. */
  38419. addKeyboard(): FlyCameraInputsManager;
  38420. /**
  38421. * Add mouse input support to the input manager.
  38422. * @param touchEnabled Enable touch screen support.
  38423. * @returns the new FlyCameraMouseInput().
  38424. */
  38425. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38426. }
  38427. }
  38428. declare module "babylonjs/Cameras/flyCamera" {
  38429. import { Scene } from "babylonjs/scene";
  38430. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38432. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38433. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38434. /**
  38435. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38436. * such as in a 3D Space Shooter or a Flight Simulator.
  38437. */
  38438. export class FlyCamera extends TargetCamera {
  38439. /**
  38440. * Define the collision ellipsoid of the camera.
  38441. * This is helpful for simulating a camera body, like a player's body.
  38442. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38443. */
  38444. ellipsoid: Vector3;
  38445. /**
  38446. * Define an offset for the position of the ellipsoid around the camera.
  38447. * This can be helpful if the camera is attached away from the player's body center,
  38448. * such as at its head.
  38449. */
  38450. ellipsoidOffset: Vector3;
  38451. /**
  38452. * Enable or disable collisions of the camera with the rest of the scene objects.
  38453. */
  38454. checkCollisions: boolean;
  38455. /**
  38456. * Enable or disable gravity on the camera.
  38457. */
  38458. applyGravity: boolean;
  38459. /**
  38460. * Define the current direction the camera is moving to.
  38461. */
  38462. cameraDirection: Vector3;
  38463. /**
  38464. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38465. * This overrides and empties cameraRotation.
  38466. */
  38467. rotationQuaternion: Quaternion;
  38468. /**
  38469. * Track Roll to maintain the wanted Rolling when looking around.
  38470. */
  38471. _trackRoll: number;
  38472. /**
  38473. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38474. */
  38475. rollCorrect: number;
  38476. /**
  38477. * Mimic a banked turn, Rolling the camera when Yawing.
  38478. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38479. */
  38480. bankedTurn: boolean;
  38481. /**
  38482. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38483. */
  38484. bankedTurnLimit: number;
  38485. /**
  38486. * Value of 0 disables the banked Roll.
  38487. * Value of 1 is equal to the Yaw angle in radians.
  38488. */
  38489. bankedTurnMultiplier: number;
  38490. /**
  38491. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38492. */
  38493. inputs: FlyCameraInputsManager;
  38494. /**
  38495. * Gets the input sensibility for mouse input.
  38496. * Higher values reduce sensitivity.
  38497. */
  38498. /**
  38499. * Sets the input sensibility for a mouse input.
  38500. * Higher values reduce sensitivity.
  38501. */
  38502. angularSensibility: number;
  38503. /**
  38504. * Get the keys for camera movement forward.
  38505. */
  38506. /**
  38507. * Set the keys for camera movement forward.
  38508. */
  38509. keysForward: number[];
  38510. /**
  38511. * Get the keys for camera movement backward.
  38512. */
  38513. keysBackward: number[];
  38514. /**
  38515. * Get the keys for camera movement up.
  38516. */
  38517. /**
  38518. * Set the keys for camera movement up.
  38519. */
  38520. keysUp: number[];
  38521. /**
  38522. * Get the keys for camera movement down.
  38523. */
  38524. /**
  38525. * Set the keys for camera movement down.
  38526. */
  38527. keysDown: number[];
  38528. /**
  38529. * Get the keys for camera movement left.
  38530. */
  38531. /**
  38532. * Set the keys for camera movement left.
  38533. */
  38534. keysLeft: number[];
  38535. /**
  38536. * Set the keys for camera movement right.
  38537. */
  38538. /**
  38539. * Set the keys for camera movement right.
  38540. */
  38541. keysRight: number[];
  38542. /**
  38543. * Event raised when the camera collides with a mesh in the scene.
  38544. */
  38545. onCollide: (collidedMesh: AbstractMesh) => void;
  38546. private _collider;
  38547. private _needMoveForGravity;
  38548. private _oldPosition;
  38549. private _diffPosition;
  38550. private _newPosition;
  38551. /** @hidden */
  38552. _localDirection: Vector3;
  38553. /** @hidden */
  38554. _transformedDirection: Vector3;
  38555. /**
  38556. * Instantiates a FlyCamera.
  38557. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38558. * such as in a 3D Space Shooter or a Flight Simulator.
  38559. * @param name Define the name of the camera in the scene.
  38560. * @param position Define the starting position of the camera in the scene.
  38561. * @param scene Define the scene the camera belongs to.
  38562. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38563. */
  38564. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38565. /**
  38566. * Attach a control to the HTML DOM element.
  38567. * @param element Defines the element that listens to the input events.
  38568. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38569. */
  38570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38571. /**
  38572. * Detach a control from the HTML DOM element.
  38573. * The camera will stop reacting to that input.
  38574. * @param element Defines the element that listens to the input events.
  38575. */
  38576. detachControl(element: HTMLElement): void;
  38577. private _collisionMask;
  38578. /**
  38579. * Get the mask that the camera ignores in collision events.
  38580. */
  38581. /**
  38582. * Set the mask that the camera ignores in collision events.
  38583. */
  38584. collisionMask: number;
  38585. /** @hidden */
  38586. _collideWithWorld(displacement: Vector3): void;
  38587. /** @hidden */
  38588. private _onCollisionPositionChange;
  38589. /** @hidden */
  38590. _checkInputs(): void;
  38591. /** @hidden */
  38592. _decideIfNeedsToMove(): boolean;
  38593. /** @hidden */
  38594. _updatePosition(): void;
  38595. /**
  38596. * Restore the Roll to its target value at the rate specified.
  38597. * @param rate - Higher means slower restoring.
  38598. * @hidden
  38599. */
  38600. restoreRoll(rate: number): void;
  38601. /**
  38602. * Destroy the camera and release the current resources held by it.
  38603. */
  38604. dispose(): void;
  38605. /**
  38606. * Get the current object class name.
  38607. * @returns the class name.
  38608. */
  38609. getClassName(): string;
  38610. }
  38611. }
  38612. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38613. import { Nullable } from "babylonjs/types";
  38614. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38615. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38616. /**
  38617. * Listen to keyboard events to control the camera.
  38618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38619. */
  38620. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38621. /**
  38622. * Defines the camera the input is attached to.
  38623. */
  38624. camera: FlyCamera;
  38625. /**
  38626. * The list of keyboard keys used to control the forward move of the camera.
  38627. */
  38628. keysForward: number[];
  38629. /**
  38630. * The list of keyboard keys used to control the backward move of the camera.
  38631. */
  38632. keysBackward: number[];
  38633. /**
  38634. * The list of keyboard keys used to control the forward move of the camera.
  38635. */
  38636. keysUp: number[];
  38637. /**
  38638. * The list of keyboard keys used to control the backward move of the camera.
  38639. */
  38640. keysDown: number[];
  38641. /**
  38642. * The list of keyboard keys used to control the right strafe move of the camera.
  38643. */
  38644. keysRight: number[];
  38645. /**
  38646. * The list of keyboard keys used to control the left strafe move of the camera.
  38647. */
  38648. keysLeft: number[];
  38649. private _keys;
  38650. private _onCanvasBlurObserver;
  38651. private _onKeyboardObserver;
  38652. private _engine;
  38653. private _scene;
  38654. /**
  38655. * Attach the input controls to a specific dom element to get the input from.
  38656. * @param element Defines the element the controls should be listened from
  38657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38658. */
  38659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38660. /**
  38661. * Detach the current controls from the specified dom element.
  38662. * @param element Defines the element to stop listening the inputs from
  38663. */
  38664. detachControl(element: Nullable<HTMLElement>): void;
  38665. /**
  38666. * Gets the class name of the current intput.
  38667. * @returns the class name
  38668. */
  38669. getClassName(): string;
  38670. /** @hidden */
  38671. _onLostFocus(e: FocusEvent): void;
  38672. /**
  38673. * Get the friendly name associated with the input class.
  38674. * @returns the input friendly name
  38675. */
  38676. getSimpleName(): string;
  38677. /**
  38678. * Update the current camera state depending on the inputs that have been used this frame.
  38679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38680. */
  38681. checkInputs(): void;
  38682. }
  38683. }
  38684. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38685. import { Nullable } from "babylonjs/types";
  38686. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38687. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38688. /**
  38689. * Manage the mouse wheel inputs to control a follow camera.
  38690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38691. */
  38692. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38693. /**
  38694. * Defines the camera the input is attached to.
  38695. */
  38696. camera: FollowCamera;
  38697. /**
  38698. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38699. */
  38700. axisControlRadius: boolean;
  38701. /**
  38702. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38703. */
  38704. axisControlHeight: boolean;
  38705. /**
  38706. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38707. */
  38708. axisControlRotation: boolean;
  38709. /**
  38710. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38711. * relation to mouseWheel events.
  38712. */
  38713. wheelPrecision: number;
  38714. /**
  38715. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38716. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38717. */
  38718. wheelDeltaPercentage: number;
  38719. private _wheel;
  38720. private _observer;
  38721. /**
  38722. * Attach the input controls to a specific dom element to get the input from.
  38723. * @param element Defines the element the controls should be listened from
  38724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38725. */
  38726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38727. /**
  38728. * Detach the current controls from the specified dom element.
  38729. * @param element Defines the element to stop listening the inputs from
  38730. */
  38731. detachControl(element: Nullable<HTMLElement>): void;
  38732. /**
  38733. * Gets the class name of the current intput.
  38734. * @returns the class name
  38735. */
  38736. getClassName(): string;
  38737. /**
  38738. * Get the friendly name associated with the input class.
  38739. * @returns the input friendly name
  38740. */
  38741. getSimpleName(): string;
  38742. }
  38743. }
  38744. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38745. import { Nullable } from "babylonjs/types";
  38746. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38747. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38748. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38749. /**
  38750. * Manage the pointers inputs to control an follow camera.
  38751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38752. */
  38753. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38754. /**
  38755. * Defines the camera the input is attached to.
  38756. */
  38757. camera: FollowCamera;
  38758. /**
  38759. * Gets the class name of the current input.
  38760. * @returns the class name
  38761. */
  38762. getClassName(): string;
  38763. /**
  38764. * Defines the pointer angular sensibility along the X axis or how fast is
  38765. * the camera rotating.
  38766. * A negative number will reverse the axis direction.
  38767. */
  38768. angularSensibilityX: number;
  38769. /**
  38770. * Defines the pointer angular sensibility along the Y axis or how fast is
  38771. * the camera rotating.
  38772. * A negative number will reverse the axis direction.
  38773. */
  38774. angularSensibilityY: number;
  38775. /**
  38776. * Defines the pointer pinch precision or how fast is the camera zooming.
  38777. * A negative number will reverse the axis direction.
  38778. */
  38779. pinchPrecision: number;
  38780. /**
  38781. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38782. * from 0.
  38783. * It defines the percentage of current camera.radius to use as delta when
  38784. * pinch zoom is used.
  38785. */
  38786. pinchDeltaPercentage: number;
  38787. /**
  38788. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38789. */
  38790. axisXControlRadius: boolean;
  38791. /**
  38792. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38793. */
  38794. axisXControlHeight: boolean;
  38795. /**
  38796. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38797. */
  38798. axisXControlRotation: boolean;
  38799. /**
  38800. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38801. */
  38802. axisYControlRadius: boolean;
  38803. /**
  38804. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38805. */
  38806. axisYControlHeight: boolean;
  38807. /**
  38808. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38809. */
  38810. axisYControlRotation: boolean;
  38811. /**
  38812. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38813. */
  38814. axisPinchControlRadius: boolean;
  38815. /**
  38816. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38817. */
  38818. axisPinchControlHeight: boolean;
  38819. /**
  38820. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38821. */
  38822. axisPinchControlRotation: boolean;
  38823. /**
  38824. * Log error messages if basic misconfiguration has occurred.
  38825. */
  38826. warningEnable: boolean;
  38827. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38828. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38829. private _warningCounter;
  38830. private _warning;
  38831. }
  38832. }
  38833. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38834. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38835. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38836. /**
  38837. * Default Inputs manager for the FollowCamera.
  38838. * It groups all the default supported inputs for ease of use.
  38839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38840. */
  38841. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38842. /**
  38843. * Instantiates a new FollowCameraInputsManager.
  38844. * @param camera Defines the camera the inputs belong to
  38845. */
  38846. constructor(camera: FollowCamera);
  38847. /**
  38848. * Add keyboard input support to the input manager.
  38849. * @returns the current input manager
  38850. */
  38851. addKeyboard(): FollowCameraInputsManager;
  38852. /**
  38853. * Add mouse wheel input support to the input manager.
  38854. * @returns the current input manager
  38855. */
  38856. addMouseWheel(): FollowCameraInputsManager;
  38857. /**
  38858. * Add pointers input support to the input manager.
  38859. * @returns the current input manager
  38860. */
  38861. addPointers(): FollowCameraInputsManager;
  38862. /**
  38863. * Add orientation input support to the input manager.
  38864. * @returns the current input manager
  38865. */
  38866. addVRDeviceOrientation(): FollowCameraInputsManager;
  38867. }
  38868. }
  38869. declare module "babylonjs/Cameras/followCamera" {
  38870. import { Nullable } from "babylonjs/types";
  38871. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38872. import { Scene } from "babylonjs/scene";
  38873. import { Vector3 } from "babylonjs/Maths/math.vector";
  38874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38875. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38876. /**
  38877. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38878. * an arc rotate version arcFollowCamera are available.
  38879. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38880. */
  38881. export class FollowCamera extends TargetCamera {
  38882. /**
  38883. * Distance the follow camera should follow an object at
  38884. */
  38885. radius: number;
  38886. /**
  38887. * Minimum allowed distance of the camera to the axis of rotation
  38888. * (The camera can not get closer).
  38889. * This can help limiting how the Camera is able to move in the scene.
  38890. */
  38891. lowerRadiusLimit: Nullable<number>;
  38892. /**
  38893. * Maximum allowed distance of the camera to the axis of rotation
  38894. * (The camera can not get further).
  38895. * This can help limiting how the Camera is able to move in the scene.
  38896. */
  38897. upperRadiusLimit: Nullable<number>;
  38898. /**
  38899. * Define a rotation offset between the camera and the object it follows
  38900. */
  38901. rotationOffset: number;
  38902. /**
  38903. * Minimum allowed angle to camera position relative to target object.
  38904. * This can help limiting how the Camera is able to move in the scene.
  38905. */
  38906. lowerRotationOffsetLimit: Nullable<number>;
  38907. /**
  38908. * Maximum allowed angle to camera position relative to target object.
  38909. * This can help limiting how the Camera is able to move in the scene.
  38910. */
  38911. upperRotationOffsetLimit: Nullable<number>;
  38912. /**
  38913. * Define a height offset between the camera and the object it follows.
  38914. * It can help following an object from the top (like a car chaing a plane)
  38915. */
  38916. heightOffset: number;
  38917. /**
  38918. * Minimum allowed height of camera position relative to target object.
  38919. * This can help limiting how the Camera is able to move in the scene.
  38920. */
  38921. lowerHeightOffsetLimit: Nullable<number>;
  38922. /**
  38923. * Maximum allowed height of camera position relative to target object.
  38924. * This can help limiting how the Camera is able to move in the scene.
  38925. */
  38926. upperHeightOffsetLimit: Nullable<number>;
  38927. /**
  38928. * Define how fast the camera can accelerate to follow it s target.
  38929. */
  38930. cameraAcceleration: number;
  38931. /**
  38932. * Define the speed limit of the camera following an object.
  38933. */
  38934. maxCameraSpeed: number;
  38935. /**
  38936. * Define the target of the camera.
  38937. */
  38938. lockedTarget: Nullable<AbstractMesh>;
  38939. /**
  38940. * Defines the input associated with the camera.
  38941. */
  38942. inputs: FollowCameraInputsManager;
  38943. /**
  38944. * Instantiates the follow camera.
  38945. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38946. * @param name Define the name of the camera in the scene
  38947. * @param position Define the position of the camera
  38948. * @param scene Define the scene the camera belong to
  38949. * @param lockedTarget Define the target of the camera
  38950. */
  38951. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38952. private _follow;
  38953. /**
  38954. * Attached controls to the current camera.
  38955. * @param element Defines the element the controls should be listened from
  38956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38957. */
  38958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38959. /**
  38960. * Detach the current controls from the camera.
  38961. * The camera will stop reacting to inputs.
  38962. * @param element Defines the element to stop listening the inputs from
  38963. */
  38964. detachControl(element: HTMLElement): void;
  38965. /** @hidden */
  38966. _checkInputs(): void;
  38967. private _checkLimits;
  38968. /**
  38969. * Gets the camera class name.
  38970. * @returns the class name
  38971. */
  38972. getClassName(): string;
  38973. }
  38974. /**
  38975. * Arc Rotate version of the follow camera.
  38976. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38977. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38978. */
  38979. export class ArcFollowCamera extends TargetCamera {
  38980. /** The longitudinal angle of the camera */
  38981. alpha: number;
  38982. /** The latitudinal angle of the camera */
  38983. beta: number;
  38984. /** The radius of the camera from its target */
  38985. radius: number;
  38986. /** Define the camera target (the messh it should follow) */
  38987. target: Nullable<AbstractMesh>;
  38988. private _cartesianCoordinates;
  38989. /**
  38990. * Instantiates a new ArcFollowCamera
  38991. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38992. * @param name Define the name of the camera
  38993. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38994. * @param beta Define the rotation angle of the camera around the elevation axis
  38995. * @param radius Define the radius of the camera from its target point
  38996. * @param target Define the target of the camera
  38997. * @param scene Define the scene the camera belongs to
  38998. */
  38999. constructor(name: string,
  39000. /** The longitudinal angle of the camera */
  39001. alpha: number,
  39002. /** The latitudinal angle of the camera */
  39003. beta: number,
  39004. /** The radius of the camera from its target */
  39005. radius: number,
  39006. /** Define the camera target (the messh it should follow) */
  39007. target: Nullable<AbstractMesh>, scene: Scene);
  39008. private _follow;
  39009. /** @hidden */
  39010. _checkInputs(): void;
  39011. /**
  39012. * Returns the class name of the object.
  39013. * It is mostly used internally for serialization purposes.
  39014. */
  39015. getClassName(): string;
  39016. }
  39017. }
  39018. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39019. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39020. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39021. import { Nullable } from "babylonjs/types";
  39022. /**
  39023. * Manage the keyboard inputs to control the movement of a follow camera.
  39024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39025. */
  39026. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39027. /**
  39028. * Defines the camera the input is attached to.
  39029. */
  39030. camera: FollowCamera;
  39031. /**
  39032. * Defines the list of key codes associated with the up action (increase heightOffset)
  39033. */
  39034. keysHeightOffsetIncr: number[];
  39035. /**
  39036. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39037. */
  39038. keysHeightOffsetDecr: number[];
  39039. /**
  39040. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39041. */
  39042. keysHeightOffsetModifierAlt: boolean;
  39043. /**
  39044. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39045. */
  39046. keysHeightOffsetModifierCtrl: boolean;
  39047. /**
  39048. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39049. */
  39050. keysHeightOffsetModifierShift: boolean;
  39051. /**
  39052. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39053. */
  39054. keysRotationOffsetIncr: number[];
  39055. /**
  39056. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39057. */
  39058. keysRotationOffsetDecr: number[];
  39059. /**
  39060. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39061. */
  39062. keysRotationOffsetModifierAlt: boolean;
  39063. /**
  39064. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39065. */
  39066. keysRotationOffsetModifierCtrl: boolean;
  39067. /**
  39068. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39069. */
  39070. keysRotationOffsetModifierShift: boolean;
  39071. /**
  39072. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39073. */
  39074. keysRadiusIncr: number[];
  39075. /**
  39076. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39077. */
  39078. keysRadiusDecr: number[];
  39079. /**
  39080. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39081. */
  39082. keysRadiusModifierAlt: boolean;
  39083. /**
  39084. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39085. */
  39086. keysRadiusModifierCtrl: boolean;
  39087. /**
  39088. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39089. */
  39090. keysRadiusModifierShift: boolean;
  39091. /**
  39092. * Defines the rate of change of heightOffset.
  39093. */
  39094. heightSensibility: number;
  39095. /**
  39096. * Defines the rate of change of rotationOffset.
  39097. */
  39098. rotationSensibility: number;
  39099. /**
  39100. * Defines the rate of change of radius.
  39101. */
  39102. radiusSensibility: number;
  39103. private _keys;
  39104. private _ctrlPressed;
  39105. private _altPressed;
  39106. private _shiftPressed;
  39107. private _onCanvasBlurObserver;
  39108. private _onKeyboardObserver;
  39109. private _engine;
  39110. private _scene;
  39111. /**
  39112. * Attach the input controls to a specific dom element to get the input from.
  39113. * @param element Defines the element the controls should be listened from
  39114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39115. */
  39116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39117. /**
  39118. * Detach the current controls from the specified dom element.
  39119. * @param element Defines the element to stop listening the inputs from
  39120. */
  39121. detachControl(element: Nullable<HTMLElement>): void;
  39122. /**
  39123. * Update the current camera state depending on the inputs that have been used this frame.
  39124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39125. */
  39126. checkInputs(): void;
  39127. /**
  39128. * Gets the class name of the current input.
  39129. * @returns the class name
  39130. */
  39131. getClassName(): string;
  39132. /**
  39133. * Get the friendly name associated with the input class.
  39134. * @returns the input friendly name
  39135. */
  39136. getSimpleName(): string;
  39137. /**
  39138. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39139. * allow modification of the heightOffset value.
  39140. */
  39141. private _modifierHeightOffset;
  39142. /**
  39143. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39144. * allow modification of the rotationOffset value.
  39145. */
  39146. private _modifierRotationOffset;
  39147. /**
  39148. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39149. * allow modification of the radius value.
  39150. */
  39151. private _modifierRadius;
  39152. }
  39153. }
  39154. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39155. import { Nullable } from "babylonjs/types";
  39156. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39157. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39158. import { Observable } from "babylonjs/Misc/observable";
  39159. module "babylonjs/Cameras/freeCameraInputsManager" {
  39160. interface FreeCameraInputsManager {
  39161. /**
  39162. * @hidden
  39163. */
  39164. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39165. /**
  39166. * Add orientation input support to the input manager.
  39167. * @returns the current input manager
  39168. */
  39169. addDeviceOrientation(): FreeCameraInputsManager;
  39170. }
  39171. }
  39172. /**
  39173. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39174. * Screen rotation is taken into account.
  39175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39176. */
  39177. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39178. private _camera;
  39179. private _screenOrientationAngle;
  39180. private _constantTranform;
  39181. private _screenQuaternion;
  39182. private _alpha;
  39183. private _beta;
  39184. private _gamma;
  39185. /**
  39186. * Can be used to detect if a device orientation sensor is availible on a device
  39187. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39188. * @returns a promise that will resolve on orientation change
  39189. */
  39190. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39191. /**
  39192. * @hidden
  39193. */
  39194. _onDeviceOrientationChangedObservable: Observable<void>;
  39195. /**
  39196. * Instantiates a new input
  39197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39198. */
  39199. constructor();
  39200. /**
  39201. * Define the camera controlled by the input.
  39202. */
  39203. camera: FreeCamera;
  39204. /**
  39205. * Attach the input controls to a specific dom element to get the input from.
  39206. * @param element Defines the element the controls should be listened from
  39207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39208. */
  39209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39210. private _orientationChanged;
  39211. private _deviceOrientation;
  39212. /**
  39213. * Detach the current controls from the specified dom element.
  39214. * @param element Defines the element to stop listening the inputs from
  39215. */
  39216. detachControl(element: Nullable<HTMLElement>): void;
  39217. /**
  39218. * Update the current camera state depending on the inputs that have been used this frame.
  39219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39220. */
  39221. checkInputs(): void;
  39222. /**
  39223. * Gets the class name of the current intput.
  39224. * @returns the class name
  39225. */
  39226. getClassName(): string;
  39227. /**
  39228. * Get the friendly name associated with the input class.
  39229. * @returns the input friendly name
  39230. */
  39231. getSimpleName(): string;
  39232. }
  39233. }
  39234. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39235. import { Nullable } from "babylonjs/types";
  39236. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39237. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39238. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39239. /**
  39240. * Manage the gamepad inputs to control a free camera.
  39241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39242. */
  39243. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39244. /**
  39245. * Define the camera the input is attached to.
  39246. */
  39247. camera: FreeCamera;
  39248. /**
  39249. * Define the Gamepad controlling the input
  39250. */
  39251. gamepad: Nullable<Gamepad>;
  39252. /**
  39253. * Defines the gamepad rotation sensiblity.
  39254. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39255. */
  39256. gamepadAngularSensibility: number;
  39257. /**
  39258. * Defines the gamepad move sensiblity.
  39259. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39260. */
  39261. gamepadMoveSensibility: number;
  39262. private _onGamepadConnectedObserver;
  39263. private _onGamepadDisconnectedObserver;
  39264. private _cameraTransform;
  39265. private _deltaTransform;
  39266. private _vector3;
  39267. private _vector2;
  39268. /**
  39269. * Attach the input controls to a specific dom element to get the input from.
  39270. * @param element Defines the element the controls should be listened from
  39271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39272. */
  39273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39274. /**
  39275. * Detach the current controls from the specified dom element.
  39276. * @param element Defines the element to stop listening the inputs from
  39277. */
  39278. detachControl(element: Nullable<HTMLElement>): void;
  39279. /**
  39280. * Update the current camera state depending on the inputs that have been used this frame.
  39281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39282. */
  39283. checkInputs(): void;
  39284. /**
  39285. * Gets the class name of the current intput.
  39286. * @returns the class name
  39287. */
  39288. getClassName(): string;
  39289. /**
  39290. * Get the friendly name associated with the input class.
  39291. * @returns the input friendly name
  39292. */
  39293. getSimpleName(): string;
  39294. }
  39295. }
  39296. declare module "babylonjs/Misc/virtualJoystick" {
  39297. import { Nullable } from "babylonjs/types";
  39298. import { Vector3 } from "babylonjs/Maths/math.vector";
  39299. /**
  39300. * Defines the potential axis of a Joystick
  39301. */
  39302. export enum JoystickAxis {
  39303. /** X axis */
  39304. X = 0,
  39305. /** Y axis */
  39306. Y = 1,
  39307. /** Z axis */
  39308. Z = 2
  39309. }
  39310. /**
  39311. * Class used to define virtual joystick (used in touch mode)
  39312. */
  39313. export class VirtualJoystick {
  39314. /**
  39315. * Gets or sets a boolean indicating that left and right values must be inverted
  39316. */
  39317. reverseLeftRight: boolean;
  39318. /**
  39319. * Gets or sets a boolean indicating that up and down values must be inverted
  39320. */
  39321. reverseUpDown: boolean;
  39322. /**
  39323. * Gets the offset value for the position (ie. the change of the position value)
  39324. */
  39325. deltaPosition: Vector3;
  39326. /**
  39327. * Gets a boolean indicating if the virtual joystick was pressed
  39328. */
  39329. pressed: boolean;
  39330. /**
  39331. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39332. */
  39333. static Canvas: Nullable<HTMLCanvasElement>;
  39334. private static _globalJoystickIndex;
  39335. private static vjCanvasContext;
  39336. private static vjCanvasWidth;
  39337. private static vjCanvasHeight;
  39338. private static halfWidth;
  39339. private _action;
  39340. private _axisTargetedByLeftAndRight;
  39341. private _axisTargetedByUpAndDown;
  39342. private _joystickSensibility;
  39343. private _inversedSensibility;
  39344. private _joystickPointerID;
  39345. private _joystickColor;
  39346. private _joystickPointerPos;
  39347. private _joystickPreviousPointerPos;
  39348. private _joystickPointerStartPos;
  39349. private _deltaJoystickVector;
  39350. private _leftJoystick;
  39351. private _touches;
  39352. private _onPointerDownHandlerRef;
  39353. private _onPointerMoveHandlerRef;
  39354. private _onPointerUpHandlerRef;
  39355. private _onResize;
  39356. /**
  39357. * Creates a new virtual joystick
  39358. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39359. */
  39360. constructor(leftJoystick?: boolean);
  39361. /**
  39362. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39363. * @param newJoystickSensibility defines the new sensibility
  39364. */
  39365. setJoystickSensibility(newJoystickSensibility: number): void;
  39366. private _onPointerDown;
  39367. private _onPointerMove;
  39368. private _onPointerUp;
  39369. /**
  39370. * Change the color of the virtual joystick
  39371. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39372. */
  39373. setJoystickColor(newColor: string): void;
  39374. /**
  39375. * Defines a callback to call when the joystick is touched
  39376. * @param action defines the callback
  39377. */
  39378. setActionOnTouch(action: () => any): void;
  39379. /**
  39380. * Defines which axis you'd like to control for left & right
  39381. * @param axis defines the axis to use
  39382. */
  39383. setAxisForLeftRight(axis: JoystickAxis): void;
  39384. /**
  39385. * Defines which axis you'd like to control for up & down
  39386. * @param axis defines the axis to use
  39387. */
  39388. setAxisForUpDown(axis: JoystickAxis): void;
  39389. private _drawVirtualJoystick;
  39390. /**
  39391. * Release internal HTML canvas
  39392. */
  39393. releaseCanvas(): void;
  39394. }
  39395. }
  39396. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39397. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39398. import { Nullable } from "babylonjs/types";
  39399. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39400. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39401. module "babylonjs/Cameras/freeCameraInputsManager" {
  39402. interface FreeCameraInputsManager {
  39403. /**
  39404. * Add virtual joystick input support to the input manager.
  39405. * @returns the current input manager
  39406. */
  39407. addVirtualJoystick(): FreeCameraInputsManager;
  39408. }
  39409. }
  39410. /**
  39411. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39413. */
  39414. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39415. /**
  39416. * Defines the camera the input is attached to.
  39417. */
  39418. camera: FreeCamera;
  39419. private _leftjoystick;
  39420. private _rightjoystick;
  39421. /**
  39422. * Gets the left stick of the virtual joystick.
  39423. * @returns The virtual Joystick
  39424. */
  39425. getLeftJoystick(): VirtualJoystick;
  39426. /**
  39427. * Gets the right stick of the virtual joystick.
  39428. * @returns The virtual Joystick
  39429. */
  39430. getRightJoystick(): VirtualJoystick;
  39431. /**
  39432. * Update the current camera state depending on the inputs that have been used this frame.
  39433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39434. */
  39435. checkInputs(): void;
  39436. /**
  39437. * Attach the input controls to a specific dom element to get the input from.
  39438. * @param element Defines the element the controls should be listened from
  39439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39440. */
  39441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39442. /**
  39443. * Detach the current controls from the specified dom element.
  39444. * @param element Defines the element to stop listening the inputs from
  39445. */
  39446. detachControl(element: Nullable<HTMLElement>): void;
  39447. /**
  39448. * Gets the class name of the current intput.
  39449. * @returns the class name
  39450. */
  39451. getClassName(): string;
  39452. /**
  39453. * Get the friendly name associated with the input class.
  39454. * @returns the input friendly name
  39455. */
  39456. getSimpleName(): string;
  39457. }
  39458. }
  39459. declare module "babylonjs/Cameras/Inputs/index" {
  39460. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39461. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39462. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39463. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39464. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39465. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39466. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39467. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39468. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39469. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39470. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39471. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39472. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39473. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39474. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39475. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39476. }
  39477. declare module "babylonjs/Cameras/touchCamera" {
  39478. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39479. import { Scene } from "babylonjs/scene";
  39480. import { Vector3 } from "babylonjs/Maths/math.vector";
  39481. /**
  39482. * This represents a FPS type of camera controlled by touch.
  39483. * This is like a universal camera minus the Gamepad controls.
  39484. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39485. */
  39486. export class TouchCamera extends FreeCamera {
  39487. /**
  39488. * Defines the touch sensibility for rotation.
  39489. * The higher the faster.
  39490. */
  39491. touchAngularSensibility: number;
  39492. /**
  39493. * Defines the touch sensibility for move.
  39494. * The higher the faster.
  39495. */
  39496. touchMoveSensibility: number;
  39497. /**
  39498. * Instantiates a new touch camera.
  39499. * This represents a FPS type of camera controlled by touch.
  39500. * This is like a universal camera minus the Gamepad controls.
  39501. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39502. * @param name Define the name of the camera in the scene
  39503. * @param position Define the start position of the camera in the scene
  39504. * @param scene Define the scene the camera belongs to
  39505. */
  39506. constructor(name: string, position: Vector3, scene: Scene);
  39507. /**
  39508. * Gets the current object class name.
  39509. * @return the class name
  39510. */
  39511. getClassName(): string;
  39512. /** @hidden */
  39513. _setupInputs(): void;
  39514. }
  39515. }
  39516. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39517. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39518. import { Scene } from "babylonjs/scene";
  39519. import { Vector3 } from "babylonjs/Maths/math.vector";
  39520. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39521. import { Axis } from "babylonjs/Maths/math.axis";
  39522. /**
  39523. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39524. * being tilted forward or back and left or right.
  39525. */
  39526. export class DeviceOrientationCamera extends FreeCamera {
  39527. private _initialQuaternion;
  39528. private _quaternionCache;
  39529. private _tmpDragQuaternion;
  39530. private _disablePointerInputWhenUsingDeviceOrientation;
  39531. /**
  39532. * Creates a new device orientation camera
  39533. * @param name The name of the camera
  39534. * @param position The start position camera
  39535. * @param scene The scene the camera belongs to
  39536. */
  39537. constructor(name: string, position: Vector3, scene: Scene);
  39538. /**
  39539. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39540. */
  39541. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39542. private _dragFactor;
  39543. /**
  39544. * Enabled turning on the y axis when the orientation sensor is active
  39545. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39546. */
  39547. enableHorizontalDragging(dragFactor?: number): void;
  39548. /**
  39549. * Gets the current instance class name ("DeviceOrientationCamera").
  39550. * This helps avoiding instanceof at run time.
  39551. * @returns the class name
  39552. */
  39553. getClassName(): string;
  39554. /**
  39555. * @hidden
  39556. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39557. */
  39558. _checkInputs(): void;
  39559. /**
  39560. * Reset the camera to its default orientation on the specified axis only.
  39561. * @param axis The axis to reset
  39562. */
  39563. resetToCurrentRotation(axis?: Axis): void;
  39564. }
  39565. }
  39566. declare module "babylonjs/Gamepads/xboxGamepad" {
  39567. import { Observable } from "babylonjs/Misc/observable";
  39568. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39569. /**
  39570. * Defines supported buttons for XBox360 compatible gamepads
  39571. */
  39572. export enum Xbox360Button {
  39573. /** A */
  39574. A = 0,
  39575. /** B */
  39576. B = 1,
  39577. /** X */
  39578. X = 2,
  39579. /** Y */
  39580. Y = 3,
  39581. /** Start */
  39582. Start = 4,
  39583. /** Back */
  39584. Back = 5,
  39585. /** Left button */
  39586. LB = 6,
  39587. /** Right button */
  39588. RB = 7,
  39589. /** Left stick */
  39590. LeftStick = 8,
  39591. /** Right stick */
  39592. RightStick = 9
  39593. }
  39594. /** Defines values for XBox360 DPad */
  39595. export enum Xbox360Dpad {
  39596. /** Up */
  39597. Up = 0,
  39598. /** Down */
  39599. Down = 1,
  39600. /** Left */
  39601. Left = 2,
  39602. /** Right */
  39603. Right = 3
  39604. }
  39605. /**
  39606. * Defines a XBox360 gamepad
  39607. */
  39608. export class Xbox360Pad extends Gamepad {
  39609. private _leftTrigger;
  39610. private _rightTrigger;
  39611. private _onlefttriggerchanged;
  39612. private _onrighttriggerchanged;
  39613. private _onbuttondown;
  39614. private _onbuttonup;
  39615. private _ondpaddown;
  39616. private _ondpadup;
  39617. /** Observable raised when a button is pressed */
  39618. onButtonDownObservable: Observable<Xbox360Button>;
  39619. /** Observable raised when a button is released */
  39620. onButtonUpObservable: Observable<Xbox360Button>;
  39621. /** Observable raised when a pad is pressed */
  39622. onPadDownObservable: Observable<Xbox360Dpad>;
  39623. /** Observable raised when a pad is released */
  39624. onPadUpObservable: Observable<Xbox360Dpad>;
  39625. private _buttonA;
  39626. private _buttonB;
  39627. private _buttonX;
  39628. private _buttonY;
  39629. private _buttonBack;
  39630. private _buttonStart;
  39631. private _buttonLB;
  39632. private _buttonRB;
  39633. private _buttonLeftStick;
  39634. private _buttonRightStick;
  39635. private _dPadUp;
  39636. private _dPadDown;
  39637. private _dPadLeft;
  39638. private _dPadRight;
  39639. private _isXboxOnePad;
  39640. /**
  39641. * Creates a new XBox360 gamepad object
  39642. * @param id defines the id of this gamepad
  39643. * @param index defines its index
  39644. * @param gamepad defines the internal HTML gamepad object
  39645. * @param xboxOne defines if it is a XBox One gamepad
  39646. */
  39647. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39648. /**
  39649. * Defines the callback to call when left trigger is pressed
  39650. * @param callback defines the callback to use
  39651. */
  39652. onlefttriggerchanged(callback: (value: number) => void): void;
  39653. /**
  39654. * Defines the callback to call when right trigger is pressed
  39655. * @param callback defines the callback to use
  39656. */
  39657. onrighttriggerchanged(callback: (value: number) => void): void;
  39658. /**
  39659. * Gets the left trigger value
  39660. */
  39661. /**
  39662. * Sets the left trigger value
  39663. */
  39664. leftTrigger: number;
  39665. /**
  39666. * Gets the right trigger value
  39667. */
  39668. /**
  39669. * Sets the right trigger value
  39670. */
  39671. rightTrigger: number;
  39672. /**
  39673. * Defines the callback to call when a button is pressed
  39674. * @param callback defines the callback to use
  39675. */
  39676. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39677. /**
  39678. * Defines the callback to call when a button is released
  39679. * @param callback defines the callback to use
  39680. */
  39681. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39682. /**
  39683. * Defines the callback to call when a pad is pressed
  39684. * @param callback defines the callback to use
  39685. */
  39686. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39687. /**
  39688. * Defines the callback to call when a pad is released
  39689. * @param callback defines the callback to use
  39690. */
  39691. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39692. private _setButtonValue;
  39693. private _setDPadValue;
  39694. /**
  39695. * Gets the value of the `A` button
  39696. */
  39697. /**
  39698. * Sets the value of the `A` button
  39699. */
  39700. buttonA: number;
  39701. /**
  39702. * Gets the value of the `B` button
  39703. */
  39704. /**
  39705. * Sets the value of the `B` button
  39706. */
  39707. buttonB: number;
  39708. /**
  39709. * Gets the value of the `X` button
  39710. */
  39711. /**
  39712. * Sets the value of the `X` button
  39713. */
  39714. buttonX: number;
  39715. /**
  39716. * Gets the value of the `Y` button
  39717. */
  39718. /**
  39719. * Sets the value of the `Y` button
  39720. */
  39721. buttonY: number;
  39722. /**
  39723. * Gets the value of the `Start` button
  39724. */
  39725. /**
  39726. * Sets the value of the `Start` button
  39727. */
  39728. buttonStart: number;
  39729. /**
  39730. * Gets the value of the `Back` button
  39731. */
  39732. /**
  39733. * Sets the value of the `Back` button
  39734. */
  39735. buttonBack: number;
  39736. /**
  39737. * Gets the value of the `Left` button
  39738. */
  39739. /**
  39740. * Sets the value of the `Left` button
  39741. */
  39742. buttonLB: number;
  39743. /**
  39744. * Gets the value of the `Right` button
  39745. */
  39746. /**
  39747. * Sets the value of the `Right` button
  39748. */
  39749. buttonRB: number;
  39750. /**
  39751. * Gets the value of the Left joystick
  39752. */
  39753. /**
  39754. * Sets the value of the Left joystick
  39755. */
  39756. buttonLeftStick: number;
  39757. /**
  39758. * Gets the value of the Right joystick
  39759. */
  39760. /**
  39761. * Sets the value of the Right joystick
  39762. */
  39763. buttonRightStick: number;
  39764. /**
  39765. * Gets the value of D-pad up
  39766. */
  39767. /**
  39768. * Sets the value of D-pad up
  39769. */
  39770. dPadUp: number;
  39771. /**
  39772. * Gets the value of D-pad down
  39773. */
  39774. /**
  39775. * Sets the value of D-pad down
  39776. */
  39777. dPadDown: number;
  39778. /**
  39779. * Gets the value of D-pad left
  39780. */
  39781. /**
  39782. * Sets the value of D-pad left
  39783. */
  39784. dPadLeft: number;
  39785. /**
  39786. * Gets the value of D-pad right
  39787. */
  39788. /**
  39789. * Sets the value of D-pad right
  39790. */
  39791. dPadRight: number;
  39792. /**
  39793. * Force the gamepad to synchronize with device values
  39794. */
  39795. update(): void;
  39796. /**
  39797. * Disposes the gamepad
  39798. */
  39799. dispose(): void;
  39800. }
  39801. }
  39802. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39803. import { Observable } from "babylonjs/Misc/observable";
  39804. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39805. /**
  39806. * Defines supported buttons for DualShock compatible gamepads
  39807. */
  39808. export enum DualShockButton {
  39809. /** Cross */
  39810. Cross = 0,
  39811. /** Circle */
  39812. Circle = 1,
  39813. /** Square */
  39814. Square = 2,
  39815. /** Triangle */
  39816. Triangle = 3,
  39817. /** Options */
  39818. Options = 4,
  39819. /** Share */
  39820. Share = 5,
  39821. /** L1 */
  39822. L1 = 6,
  39823. /** R1 */
  39824. R1 = 7,
  39825. /** Left stick */
  39826. LeftStick = 8,
  39827. /** Right stick */
  39828. RightStick = 9
  39829. }
  39830. /** Defines values for DualShock DPad */
  39831. export enum DualShockDpad {
  39832. /** Up */
  39833. Up = 0,
  39834. /** Down */
  39835. Down = 1,
  39836. /** Left */
  39837. Left = 2,
  39838. /** Right */
  39839. Right = 3
  39840. }
  39841. /**
  39842. * Defines a DualShock gamepad
  39843. */
  39844. export class DualShockPad extends Gamepad {
  39845. private _leftTrigger;
  39846. private _rightTrigger;
  39847. private _onlefttriggerchanged;
  39848. private _onrighttriggerchanged;
  39849. private _onbuttondown;
  39850. private _onbuttonup;
  39851. private _ondpaddown;
  39852. private _ondpadup;
  39853. /** Observable raised when a button is pressed */
  39854. onButtonDownObservable: Observable<DualShockButton>;
  39855. /** Observable raised when a button is released */
  39856. onButtonUpObservable: Observable<DualShockButton>;
  39857. /** Observable raised when a pad is pressed */
  39858. onPadDownObservable: Observable<DualShockDpad>;
  39859. /** Observable raised when a pad is released */
  39860. onPadUpObservable: Observable<DualShockDpad>;
  39861. private _buttonCross;
  39862. private _buttonCircle;
  39863. private _buttonSquare;
  39864. private _buttonTriangle;
  39865. private _buttonShare;
  39866. private _buttonOptions;
  39867. private _buttonL1;
  39868. private _buttonR1;
  39869. private _buttonLeftStick;
  39870. private _buttonRightStick;
  39871. private _dPadUp;
  39872. private _dPadDown;
  39873. private _dPadLeft;
  39874. private _dPadRight;
  39875. /**
  39876. * Creates a new DualShock gamepad object
  39877. * @param id defines the id of this gamepad
  39878. * @param index defines its index
  39879. * @param gamepad defines the internal HTML gamepad object
  39880. */
  39881. constructor(id: string, index: number, gamepad: any);
  39882. /**
  39883. * Defines the callback to call when left trigger is pressed
  39884. * @param callback defines the callback to use
  39885. */
  39886. onlefttriggerchanged(callback: (value: number) => void): void;
  39887. /**
  39888. * Defines the callback to call when right trigger is pressed
  39889. * @param callback defines the callback to use
  39890. */
  39891. onrighttriggerchanged(callback: (value: number) => void): void;
  39892. /**
  39893. * Gets the left trigger value
  39894. */
  39895. /**
  39896. * Sets the left trigger value
  39897. */
  39898. leftTrigger: number;
  39899. /**
  39900. * Gets the right trigger value
  39901. */
  39902. /**
  39903. * Sets the right trigger value
  39904. */
  39905. rightTrigger: number;
  39906. /**
  39907. * Defines the callback to call when a button is pressed
  39908. * @param callback defines the callback to use
  39909. */
  39910. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39911. /**
  39912. * Defines the callback to call when a button is released
  39913. * @param callback defines the callback to use
  39914. */
  39915. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39916. /**
  39917. * Defines the callback to call when a pad is pressed
  39918. * @param callback defines the callback to use
  39919. */
  39920. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39921. /**
  39922. * Defines the callback to call when a pad is released
  39923. * @param callback defines the callback to use
  39924. */
  39925. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39926. private _setButtonValue;
  39927. private _setDPadValue;
  39928. /**
  39929. * Gets the value of the `Cross` button
  39930. */
  39931. /**
  39932. * Sets the value of the `Cross` button
  39933. */
  39934. buttonCross: number;
  39935. /**
  39936. * Gets the value of the `Circle` button
  39937. */
  39938. /**
  39939. * Sets the value of the `Circle` button
  39940. */
  39941. buttonCircle: number;
  39942. /**
  39943. * Gets the value of the `Square` button
  39944. */
  39945. /**
  39946. * Sets the value of the `Square` button
  39947. */
  39948. buttonSquare: number;
  39949. /**
  39950. * Gets the value of the `Triangle` button
  39951. */
  39952. /**
  39953. * Sets the value of the `Triangle` button
  39954. */
  39955. buttonTriangle: number;
  39956. /**
  39957. * Gets the value of the `Options` button
  39958. */
  39959. /**
  39960. * Sets the value of the `Options` button
  39961. */
  39962. buttonOptions: number;
  39963. /**
  39964. * Gets the value of the `Share` button
  39965. */
  39966. /**
  39967. * Sets the value of the `Share` button
  39968. */
  39969. buttonShare: number;
  39970. /**
  39971. * Gets the value of the `L1` button
  39972. */
  39973. /**
  39974. * Sets the value of the `L1` button
  39975. */
  39976. buttonL1: number;
  39977. /**
  39978. * Gets the value of the `R1` button
  39979. */
  39980. /**
  39981. * Sets the value of the `R1` button
  39982. */
  39983. buttonR1: number;
  39984. /**
  39985. * Gets the value of the Left joystick
  39986. */
  39987. /**
  39988. * Sets the value of the Left joystick
  39989. */
  39990. buttonLeftStick: number;
  39991. /**
  39992. * Gets the value of the Right joystick
  39993. */
  39994. /**
  39995. * Sets the value of the Right joystick
  39996. */
  39997. buttonRightStick: number;
  39998. /**
  39999. * Gets the value of D-pad up
  40000. */
  40001. /**
  40002. * Sets the value of D-pad up
  40003. */
  40004. dPadUp: number;
  40005. /**
  40006. * Gets the value of D-pad down
  40007. */
  40008. /**
  40009. * Sets the value of D-pad down
  40010. */
  40011. dPadDown: number;
  40012. /**
  40013. * Gets the value of D-pad left
  40014. */
  40015. /**
  40016. * Sets the value of D-pad left
  40017. */
  40018. dPadLeft: number;
  40019. /**
  40020. * Gets the value of D-pad right
  40021. */
  40022. /**
  40023. * Sets the value of D-pad right
  40024. */
  40025. dPadRight: number;
  40026. /**
  40027. * Force the gamepad to synchronize with device values
  40028. */
  40029. update(): void;
  40030. /**
  40031. * Disposes the gamepad
  40032. */
  40033. dispose(): void;
  40034. }
  40035. }
  40036. declare module "babylonjs/Gamepads/gamepadManager" {
  40037. import { Observable } from "babylonjs/Misc/observable";
  40038. import { Nullable } from "babylonjs/types";
  40039. import { Scene } from "babylonjs/scene";
  40040. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40041. /**
  40042. * Manager for handling gamepads
  40043. */
  40044. export class GamepadManager {
  40045. private _scene?;
  40046. private _babylonGamepads;
  40047. private _oneGamepadConnected;
  40048. /** @hidden */
  40049. _isMonitoring: boolean;
  40050. private _gamepadEventSupported;
  40051. private _gamepadSupport;
  40052. /**
  40053. * observable to be triggered when the gamepad controller has been connected
  40054. */
  40055. onGamepadConnectedObservable: Observable<Gamepad>;
  40056. /**
  40057. * observable to be triggered when the gamepad controller has been disconnected
  40058. */
  40059. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40060. private _onGamepadConnectedEvent;
  40061. private _onGamepadDisconnectedEvent;
  40062. /**
  40063. * Initializes the gamepad manager
  40064. * @param _scene BabylonJS scene
  40065. */
  40066. constructor(_scene?: Scene | undefined);
  40067. /**
  40068. * The gamepads in the game pad manager
  40069. */
  40070. readonly gamepads: Gamepad[];
  40071. /**
  40072. * Get the gamepad controllers based on type
  40073. * @param type The type of gamepad controller
  40074. * @returns Nullable gamepad
  40075. */
  40076. getGamepadByType(type?: number): Nullable<Gamepad>;
  40077. /**
  40078. * Disposes the gamepad manager
  40079. */
  40080. dispose(): void;
  40081. private _addNewGamepad;
  40082. private _startMonitoringGamepads;
  40083. private _stopMonitoringGamepads;
  40084. /** @hidden */
  40085. _checkGamepadsStatus(): void;
  40086. private _updateGamepadObjects;
  40087. }
  40088. }
  40089. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40090. import { Nullable } from "babylonjs/types";
  40091. import { Scene } from "babylonjs/scene";
  40092. import { ISceneComponent } from "babylonjs/sceneComponent";
  40093. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40094. module "babylonjs/scene" {
  40095. interface Scene {
  40096. /** @hidden */
  40097. _gamepadManager: Nullable<GamepadManager>;
  40098. /**
  40099. * Gets the gamepad manager associated with the scene
  40100. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40101. */
  40102. gamepadManager: GamepadManager;
  40103. }
  40104. }
  40105. module "babylonjs/Cameras/freeCameraInputsManager" {
  40106. /**
  40107. * Interface representing a free camera inputs manager
  40108. */
  40109. interface FreeCameraInputsManager {
  40110. /**
  40111. * Adds gamepad input support to the FreeCameraInputsManager.
  40112. * @returns the FreeCameraInputsManager
  40113. */
  40114. addGamepad(): FreeCameraInputsManager;
  40115. }
  40116. }
  40117. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40118. /**
  40119. * Interface representing an arc rotate camera inputs manager
  40120. */
  40121. interface ArcRotateCameraInputsManager {
  40122. /**
  40123. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40124. * @returns the camera inputs manager
  40125. */
  40126. addGamepad(): ArcRotateCameraInputsManager;
  40127. }
  40128. }
  40129. /**
  40130. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40131. */
  40132. export class GamepadSystemSceneComponent implements ISceneComponent {
  40133. /**
  40134. * The component name helpfull to identify the component in the list of scene components.
  40135. */
  40136. readonly name: string;
  40137. /**
  40138. * The scene the component belongs to.
  40139. */
  40140. scene: Scene;
  40141. /**
  40142. * Creates a new instance of the component for the given scene
  40143. * @param scene Defines the scene to register the component in
  40144. */
  40145. constructor(scene: Scene);
  40146. /**
  40147. * Registers the component in a given scene
  40148. */
  40149. register(): void;
  40150. /**
  40151. * Rebuilds the elements related to this component in case of
  40152. * context lost for instance.
  40153. */
  40154. rebuild(): void;
  40155. /**
  40156. * Disposes the component and the associated ressources
  40157. */
  40158. dispose(): void;
  40159. private _beforeCameraUpdate;
  40160. }
  40161. }
  40162. declare module "babylonjs/Cameras/universalCamera" {
  40163. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40164. import { Scene } from "babylonjs/scene";
  40165. import { Vector3 } from "babylonjs/Maths/math.vector";
  40166. import "babylonjs/Gamepads/gamepadSceneComponent";
  40167. /**
  40168. * 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,
  40169. * which still works and will still be found in many Playgrounds.
  40170. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40171. */
  40172. export class UniversalCamera extends TouchCamera {
  40173. /**
  40174. * Defines the gamepad rotation sensiblity.
  40175. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40176. */
  40177. gamepadAngularSensibility: number;
  40178. /**
  40179. * Defines the gamepad move sensiblity.
  40180. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40181. */
  40182. gamepadMoveSensibility: number;
  40183. /**
  40184. * 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,
  40185. * which still works and will still be found in many Playgrounds.
  40186. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40187. * @param name Define the name of the camera in the scene
  40188. * @param position Define the start position of the camera in the scene
  40189. * @param scene Define the scene the camera belongs to
  40190. */
  40191. constructor(name: string, position: Vector3, scene: Scene);
  40192. /**
  40193. * Gets the current object class name.
  40194. * @return the class name
  40195. */
  40196. getClassName(): string;
  40197. }
  40198. }
  40199. declare module "babylonjs/Cameras/gamepadCamera" {
  40200. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40201. import { Scene } from "babylonjs/scene";
  40202. import { Vector3 } from "babylonjs/Maths/math.vector";
  40203. /**
  40204. * This represents a FPS type of camera. This is only here for back compat purpose.
  40205. * Please use the UniversalCamera instead as both are identical.
  40206. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40207. */
  40208. export class GamepadCamera extends UniversalCamera {
  40209. /**
  40210. * Instantiates a new Gamepad Camera
  40211. * This represents a FPS type of camera. This is only here for back compat purpose.
  40212. * Please use the UniversalCamera instead as both are identical.
  40213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40214. * @param name Define the name of the camera in the scene
  40215. * @param position Define the start position of the camera in the scene
  40216. * @param scene Define the scene the camera belongs to
  40217. */
  40218. constructor(name: string, position: Vector3, scene: Scene);
  40219. /**
  40220. * Gets the current object class name.
  40221. * @return the class name
  40222. */
  40223. getClassName(): string;
  40224. }
  40225. }
  40226. declare module "babylonjs/Shaders/pass.fragment" {
  40227. /** @hidden */
  40228. export var passPixelShader: {
  40229. name: string;
  40230. shader: string;
  40231. };
  40232. }
  40233. declare module "babylonjs/Shaders/passCube.fragment" {
  40234. /** @hidden */
  40235. export var passCubePixelShader: {
  40236. name: string;
  40237. shader: string;
  40238. };
  40239. }
  40240. declare module "babylonjs/PostProcesses/passPostProcess" {
  40241. import { Nullable } from "babylonjs/types";
  40242. import { Camera } from "babylonjs/Cameras/camera";
  40243. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40244. import { Engine } from "babylonjs/Engines/engine";
  40245. import "babylonjs/Shaders/pass.fragment";
  40246. import "babylonjs/Shaders/passCube.fragment";
  40247. /**
  40248. * PassPostProcess which produces an output the same as it's input
  40249. */
  40250. export class PassPostProcess extends PostProcess {
  40251. /**
  40252. * Creates the PassPostProcess
  40253. * @param name The name of the effect.
  40254. * @param options The required width/height ratio to downsize to before computing the render pass.
  40255. * @param camera The camera to apply the render pass to.
  40256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40257. * @param engine The engine which the post process will be applied. (default: current engine)
  40258. * @param reusable If the post process can be reused on the same frame. (default: false)
  40259. * @param textureType The type of texture to be used when performing the post processing.
  40260. * @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)
  40261. */
  40262. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40263. }
  40264. /**
  40265. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40266. */
  40267. export class PassCubePostProcess extends PostProcess {
  40268. private _face;
  40269. /**
  40270. * Gets or sets the cube face to display.
  40271. * * 0 is +X
  40272. * * 1 is -X
  40273. * * 2 is +Y
  40274. * * 3 is -Y
  40275. * * 4 is +Z
  40276. * * 5 is -Z
  40277. */
  40278. face: number;
  40279. /**
  40280. * Creates the PassCubePostProcess
  40281. * @param name The name of the effect.
  40282. * @param options The required width/height ratio to downsize to before computing the render pass.
  40283. * @param camera The camera to apply the render pass to.
  40284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40285. * @param engine The engine which the post process will be applied. (default: current engine)
  40286. * @param reusable If the post process can be reused on the same frame. (default: false)
  40287. * @param textureType The type of texture to be used when performing the post processing.
  40288. * @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)
  40289. */
  40290. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40291. }
  40292. }
  40293. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40294. /** @hidden */
  40295. export var anaglyphPixelShader: {
  40296. name: string;
  40297. shader: string;
  40298. };
  40299. }
  40300. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40301. import { Engine } from "babylonjs/Engines/engine";
  40302. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40303. import { Camera } from "babylonjs/Cameras/camera";
  40304. import "babylonjs/Shaders/anaglyph.fragment";
  40305. /**
  40306. * Postprocess used to generate anaglyphic rendering
  40307. */
  40308. export class AnaglyphPostProcess extends PostProcess {
  40309. private _passedProcess;
  40310. /**
  40311. * Creates a new AnaglyphPostProcess
  40312. * @param name defines postprocess name
  40313. * @param options defines creation options or target ratio scale
  40314. * @param rigCameras defines cameras using this postprocess
  40315. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40316. * @param engine defines hosting engine
  40317. * @param reusable defines if the postprocess will be reused multiple times per frame
  40318. */
  40319. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40320. }
  40321. }
  40322. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40323. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40324. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40325. import { Scene } from "babylonjs/scene";
  40326. import { Vector3 } from "babylonjs/Maths/math.vector";
  40327. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40328. /**
  40329. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40330. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40331. */
  40332. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40333. /**
  40334. * Creates a new AnaglyphArcRotateCamera
  40335. * @param name defines camera name
  40336. * @param alpha defines alpha angle (in radians)
  40337. * @param beta defines beta angle (in radians)
  40338. * @param radius defines radius
  40339. * @param target defines camera target
  40340. * @param interaxialDistance defines distance between each color axis
  40341. * @param scene defines the hosting scene
  40342. */
  40343. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40344. /**
  40345. * Gets camera class name
  40346. * @returns AnaglyphArcRotateCamera
  40347. */
  40348. getClassName(): string;
  40349. }
  40350. }
  40351. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40352. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40353. import { Scene } from "babylonjs/scene";
  40354. import { Vector3 } from "babylonjs/Maths/math.vector";
  40355. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40356. /**
  40357. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40358. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40359. */
  40360. export class AnaglyphFreeCamera extends FreeCamera {
  40361. /**
  40362. * Creates a new AnaglyphFreeCamera
  40363. * @param name defines camera name
  40364. * @param position defines initial position
  40365. * @param interaxialDistance defines distance between each color axis
  40366. * @param scene defines the hosting scene
  40367. */
  40368. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40369. /**
  40370. * Gets camera class name
  40371. * @returns AnaglyphFreeCamera
  40372. */
  40373. getClassName(): string;
  40374. }
  40375. }
  40376. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40377. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40378. import { Scene } from "babylonjs/scene";
  40379. import { Vector3 } from "babylonjs/Maths/math.vector";
  40380. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40381. /**
  40382. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40383. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40384. */
  40385. export class AnaglyphGamepadCamera extends GamepadCamera {
  40386. /**
  40387. * Creates a new AnaglyphGamepadCamera
  40388. * @param name defines camera name
  40389. * @param position defines initial position
  40390. * @param interaxialDistance defines distance between each color axis
  40391. * @param scene defines the hosting scene
  40392. */
  40393. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40394. /**
  40395. * Gets camera class name
  40396. * @returns AnaglyphGamepadCamera
  40397. */
  40398. getClassName(): string;
  40399. }
  40400. }
  40401. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40402. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40403. import { Scene } from "babylonjs/scene";
  40404. import { Vector3 } from "babylonjs/Maths/math.vector";
  40405. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40406. /**
  40407. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40408. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40409. */
  40410. export class AnaglyphUniversalCamera extends UniversalCamera {
  40411. /**
  40412. * Creates a new AnaglyphUniversalCamera
  40413. * @param name defines camera name
  40414. * @param position defines initial position
  40415. * @param interaxialDistance defines distance between each color axis
  40416. * @param scene defines the hosting scene
  40417. */
  40418. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40419. /**
  40420. * Gets camera class name
  40421. * @returns AnaglyphUniversalCamera
  40422. */
  40423. getClassName(): string;
  40424. }
  40425. }
  40426. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40427. /** @hidden */
  40428. export var stereoscopicInterlacePixelShader: {
  40429. name: string;
  40430. shader: string;
  40431. };
  40432. }
  40433. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40434. import { Camera } from "babylonjs/Cameras/camera";
  40435. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40436. import { Engine } from "babylonjs/Engines/engine";
  40437. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40438. /**
  40439. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40440. */
  40441. export class StereoscopicInterlacePostProcess extends PostProcess {
  40442. private _stepSize;
  40443. private _passedProcess;
  40444. /**
  40445. * Initializes a StereoscopicInterlacePostProcess
  40446. * @param name The name of the effect.
  40447. * @param rigCameras The rig cameras to be appled to the post process
  40448. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40450. * @param engine The engine which the post process will be applied. (default: current engine)
  40451. * @param reusable If the post process can be reused on the same frame. (default: false)
  40452. */
  40453. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40454. }
  40455. }
  40456. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40457. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40458. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40459. import { Scene } from "babylonjs/scene";
  40460. import { Vector3 } from "babylonjs/Maths/math.vector";
  40461. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40462. /**
  40463. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40464. * @see http://doc.babylonjs.com/features/cameras
  40465. */
  40466. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40467. /**
  40468. * Creates a new StereoscopicArcRotateCamera
  40469. * @param name defines camera name
  40470. * @param alpha defines alpha angle (in radians)
  40471. * @param beta defines beta angle (in radians)
  40472. * @param radius defines radius
  40473. * @param target defines camera target
  40474. * @param interaxialDistance defines distance between each color axis
  40475. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40476. * @param scene defines the hosting scene
  40477. */
  40478. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40479. /**
  40480. * Gets camera class name
  40481. * @returns StereoscopicArcRotateCamera
  40482. */
  40483. getClassName(): string;
  40484. }
  40485. }
  40486. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40487. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40488. import { Scene } from "babylonjs/scene";
  40489. import { Vector3 } from "babylonjs/Maths/math.vector";
  40490. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40491. /**
  40492. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40493. * @see http://doc.babylonjs.com/features/cameras
  40494. */
  40495. export class StereoscopicFreeCamera extends FreeCamera {
  40496. /**
  40497. * Creates a new StereoscopicFreeCamera
  40498. * @param name defines camera name
  40499. * @param position defines initial position
  40500. * @param interaxialDistance defines distance between each color axis
  40501. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40502. * @param scene defines the hosting scene
  40503. */
  40504. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40505. /**
  40506. * Gets camera class name
  40507. * @returns StereoscopicFreeCamera
  40508. */
  40509. getClassName(): string;
  40510. }
  40511. }
  40512. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40513. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40514. import { Scene } from "babylonjs/scene";
  40515. import { Vector3 } from "babylonjs/Maths/math.vector";
  40516. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40517. /**
  40518. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40519. * @see http://doc.babylonjs.com/features/cameras
  40520. */
  40521. export class StereoscopicGamepadCamera extends GamepadCamera {
  40522. /**
  40523. * Creates a new StereoscopicGamepadCamera
  40524. * @param name defines camera name
  40525. * @param position defines initial position
  40526. * @param interaxialDistance defines distance between each color axis
  40527. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40528. * @param scene defines the hosting scene
  40529. */
  40530. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40531. /**
  40532. * Gets camera class name
  40533. * @returns StereoscopicGamepadCamera
  40534. */
  40535. getClassName(): string;
  40536. }
  40537. }
  40538. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40539. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40540. import { Scene } from "babylonjs/scene";
  40541. import { Vector3 } from "babylonjs/Maths/math.vector";
  40542. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40543. /**
  40544. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40545. * @see http://doc.babylonjs.com/features/cameras
  40546. */
  40547. export class StereoscopicUniversalCamera extends UniversalCamera {
  40548. /**
  40549. * Creates a new StereoscopicUniversalCamera
  40550. * @param name defines camera name
  40551. * @param position defines initial position
  40552. * @param interaxialDistance defines distance between each color axis
  40553. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40554. * @param scene defines the hosting scene
  40555. */
  40556. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40557. /**
  40558. * Gets camera class name
  40559. * @returns StereoscopicUniversalCamera
  40560. */
  40561. getClassName(): string;
  40562. }
  40563. }
  40564. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40565. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40566. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40567. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40568. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40569. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40570. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40571. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40572. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40573. }
  40574. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40575. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40576. import { Scene } from "babylonjs/scene";
  40577. import { Vector3 } from "babylonjs/Maths/math.vector";
  40578. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40579. /**
  40580. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40581. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40582. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40583. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40584. */
  40585. export class VirtualJoysticksCamera extends FreeCamera {
  40586. /**
  40587. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40588. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40589. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40590. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40591. * @param name Define the name of the camera in the scene
  40592. * @param position Define the start position of the camera in the scene
  40593. * @param scene Define the scene the camera belongs to
  40594. */
  40595. constructor(name: string, position: Vector3, scene: Scene);
  40596. /**
  40597. * Gets the current object class name.
  40598. * @return the class name
  40599. */
  40600. getClassName(): string;
  40601. }
  40602. }
  40603. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40604. import { Matrix } from "babylonjs/Maths/math.vector";
  40605. /**
  40606. * This represents all the required metrics to create a VR camera.
  40607. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40608. */
  40609. export class VRCameraMetrics {
  40610. /**
  40611. * Define the horizontal resolution off the screen.
  40612. */
  40613. hResolution: number;
  40614. /**
  40615. * Define the vertical resolution off the screen.
  40616. */
  40617. vResolution: number;
  40618. /**
  40619. * Define the horizontal screen size.
  40620. */
  40621. hScreenSize: number;
  40622. /**
  40623. * Define the vertical screen size.
  40624. */
  40625. vScreenSize: number;
  40626. /**
  40627. * Define the vertical screen center position.
  40628. */
  40629. vScreenCenter: number;
  40630. /**
  40631. * Define the distance of the eyes to the screen.
  40632. */
  40633. eyeToScreenDistance: number;
  40634. /**
  40635. * Define the distance between both lenses
  40636. */
  40637. lensSeparationDistance: number;
  40638. /**
  40639. * Define the distance between both viewer's eyes.
  40640. */
  40641. interpupillaryDistance: number;
  40642. /**
  40643. * Define the distortion factor of the VR postprocess.
  40644. * Please, touch with care.
  40645. */
  40646. distortionK: number[];
  40647. /**
  40648. * Define the chromatic aberration correction factors for the VR post process.
  40649. */
  40650. chromaAbCorrection: number[];
  40651. /**
  40652. * Define the scale factor of the post process.
  40653. * The smaller the better but the slower.
  40654. */
  40655. postProcessScaleFactor: number;
  40656. /**
  40657. * Define an offset for the lens center.
  40658. */
  40659. lensCenterOffset: number;
  40660. /**
  40661. * Define if the current vr camera should compensate the distortion of the lense or not.
  40662. */
  40663. compensateDistortion: boolean;
  40664. /**
  40665. * Defines if multiview should be enabled when rendering (Default: false)
  40666. */
  40667. multiviewEnabled: boolean;
  40668. /**
  40669. * Gets the rendering aspect ratio based on the provided resolutions.
  40670. */
  40671. readonly aspectRatio: number;
  40672. /**
  40673. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40674. */
  40675. readonly aspectRatioFov: number;
  40676. /**
  40677. * @hidden
  40678. */
  40679. readonly leftHMatrix: Matrix;
  40680. /**
  40681. * @hidden
  40682. */
  40683. readonly rightHMatrix: Matrix;
  40684. /**
  40685. * @hidden
  40686. */
  40687. readonly leftPreViewMatrix: Matrix;
  40688. /**
  40689. * @hidden
  40690. */
  40691. readonly rightPreViewMatrix: Matrix;
  40692. /**
  40693. * Get the default VRMetrics based on the most generic setup.
  40694. * @returns the default vr metrics
  40695. */
  40696. static GetDefault(): VRCameraMetrics;
  40697. }
  40698. }
  40699. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40700. /** @hidden */
  40701. export var vrDistortionCorrectionPixelShader: {
  40702. name: string;
  40703. shader: string;
  40704. };
  40705. }
  40706. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40707. import { Camera } from "babylonjs/Cameras/camera";
  40708. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40710. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40711. /**
  40712. * VRDistortionCorrectionPostProcess used for mobile VR
  40713. */
  40714. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40715. private _isRightEye;
  40716. private _distortionFactors;
  40717. private _postProcessScaleFactor;
  40718. private _lensCenterOffset;
  40719. private _scaleIn;
  40720. private _scaleFactor;
  40721. private _lensCenter;
  40722. /**
  40723. * Initializes the VRDistortionCorrectionPostProcess
  40724. * @param name The name of the effect.
  40725. * @param camera The camera to apply the render pass to.
  40726. * @param isRightEye If this is for the right eye distortion
  40727. * @param vrMetrics All the required metrics for the VR camera
  40728. */
  40729. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40730. }
  40731. }
  40732. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40733. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40734. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40735. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40736. import { Scene } from "babylonjs/scene";
  40737. import { Vector3 } from "babylonjs/Maths/math.vector";
  40738. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40739. import "babylonjs/Cameras/RigModes/vrRigMode";
  40740. /**
  40741. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40742. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40743. */
  40744. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40745. /**
  40746. * Creates a new VRDeviceOrientationArcRotateCamera
  40747. * @param name defines camera name
  40748. * @param alpha defines the camera rotation along the logitudinal axis
  40749. * @param beta defines the camera rotation along the latitudinal axis
  40750. * @param radius defines the camera distance from its target
  40751. * @param target defines the camera target
  40752. * @param scene defines the scene the camera belongs to
  40753. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40754. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40755. */
  40756. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40757. /**
  40758. * Gets camera class name
  40759. * @returns VRDeviceOrientationArcRotateCamera
  40760. */
  40761. getClassName(): string;
  40762. }
  40763. }
  40764. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40765. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40766. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40767. import { Scene } from "babylonjs/scene";
  40768. import { Vector3 } from "babylonjs/Maths/math.vector";
  40769. import "babylonjs/Cameras/RigModes/vrRigMode";
  40770. /**
  40771. * Camera used to simulate VR rendering (based on FreeCamera)
  40772. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40773. */
  40774. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40775. /**
  40776. * Creates a new VRDeviceOrientationFreeCamera
  40777. * @param name defines camera name
  40778. * @param position defines the start position of the camera
  40779. * @param scene defines the scene the camera belongs to
  40780. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40781. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40782. */
  40783. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40784. /**
  40785. * Gets camera class name
  40786. * @returns VRDeviceOrientationFreeCamera
  40787. */
  40788. getClassName(): string;
  40789. }
  40790. }
  40791. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40792. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40793. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40794. import { Scene } from "babylonjs/scene";
  40795. import { Vector3 } from "babylonjs/Maths/math.vector";
  40796. import "babylonjs/Gamepads/gamepadSceneComponent";
  40797. /**
  40798. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40799. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40800. */
  40801. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40802. /**
  40803. * Creates a new VRDeviceOrientationGamepadCamera
  40804. * @param name defines camera name
  40805. * @param position defines the start position of the camera
  40806. * @param scene defines the scene the camera belongs to
  40807. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40808. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40809. */
  40810. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40811. /**
  40812. * Gets camera class name
  40813. * @returns VRDeviceOrientationGamepadCamera
  40814. */
  40815. getClassName(): string;
  40816. }
  40817. }
  40818. declare module "babylonjs/Materials/pushMaterial" {
  40819. import { Nullable } from "babylonjs/types";
  40820. import { Scene } from "babylonjs/scene";
  40821. import { Matrix } from "babylonjs/Maths/math.vector";
  40822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40823. import { Mesh } from "babylonjs/Meshes/mesh";
  40824. import { Material } from "babylonjs/Materials/material";
  40825. import { Effect } from "babylonjs/Materials/effect";
  40826. /**
  40827. * Base class of materials working in push mode in babylon JS
  40828. * @hidden
  40829. */
  40830. export class PushMaterial extends Material {
  40831. protected _activeEffect: Effect;
  40832. protected _normalMatrix: Matrix;
  40833. /**
  40834. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40835. * This means that the material can keep using a previous shader while a new one is being compiled.
  40836. * This is mostly used when shader parallel compilation is supported (true by default)
  40837. */
  40838. allowShaderHotSwapping: boolean;
  40839. constructor(name: string, scene: Scene);
  40840. getEffect(): Effect;
  40841. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40842. /**
  40843. * Binds the given world matrix to the active effect
  40844. *
  40845. * @param world the matrix to bind
  40846. */
  40847. bindOnlyWorldMatrix(world: Matrix): void;
  40848. /**
  40849. * Binds the given normal matrix to the active effect
  40850. *
  40851. * @param normalMatrix the matrix to bind
  40852. */
  40853. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40854. bind(world: Matrix, mesh?: Mesh): void;
  40855. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40856. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40857. }
  40858. }
  40859. declare module "babylonjs/Materials/materialFlags" {
  40860. /**
  40861. * This groups all the flags used to control the materials channel.
  40862. */
  40863. export class MaterialFlags {
  40864. private static _DiffuseTextureEnabled;
  40865. /**
  40866. * Are diffuse textures enabled in the application.
  40867. */
  40868. static DiffuseTextureEnabled: boolean;
  40869. private static _AmbientTextureEnabled;
  40870. /**
  40871. * Are ambient textures enabled in the application.
  40872. */
  40873. static AmbientTextureEnabled: boolean;
  40874. private static _OpacityTextureEnabled;
  40875. /**
  40876. * Are opacity textures enabled in the application.
  40877. */
  40878. static OpacityTextureEnabled: boolean;
  40879. private static _ReflectionTextureEnabled;
  40880. /**
  40881. * Are reflection textures enabled in the application.
  40882. */
  40883. static ReflectionTextureEnabled: boolean;
  40884. private static _EmissiveTextureEnabled;
  40885. /**
  40886. * Are emissive textures enabled in the application.
  40887. */
  40888. static EmissiveTextureEnabled: boolean;
  40889. private static _SpecularTextureEnabled;
  40890. /**
  40891. * Are specular textures enabled in the application.
  40892. */
  40893. static SpecularTextureEnabled: boolean;
  40894. private static _BumpTextureEnabled;
  40895. /**
  40896. * Are bump textures enabled in the application.
  40897. */
  40898. static BumpTextureEnabled: boolean;
  40899. private static _LightmapTextureEnabled;
  40900. /**
  40901. * Are lightmap textures enabled in the application.
  40902. */
  40903. static LightmapTextureEnabled: boolean;
  40904. private static _RefractionTextureEnabled;
  40905. /**
  40906. * Are refraction textures enabled in the application.
  40907. */
  40908. static RefractionTextureEnabled: boolean;
  40909. private static _ColorGradingTextureEnabled;
  40910. /**
  40911. * Are color grading textures enabled in the application.
  40912. */
  40913. static ColorGradingTextureEnabled: boolean;
  40914. private static _FresnelEnabled;
  40915. /**
  40916. * Are fresnels enabled in the application.
  40917. */
  40918. static FresnelEnabled: boolean;
  40919. private static _ClearCoatTextureEnabled;
  40920. /**
  40921. * Are clear coat textures enabled in the application.
  40922. */
  40923. static ClearCoatTextureEnabled: boolean;
  40924. private static _ClearCoatBumpTextureEnabled;
  40925. /**
  40926. * Are clear coat bump textures enabled in the application.
  40927. */
  40928. static ClearCoatBumpTextureEnabled: boolean;
  40929. private static _ClearCoatTintTextureEnabled;
  40930. /**
  40931. * Are clear coat tint textures enabled in the application.
  40932. */
  40933. static ClearCoatTintTextureEnabled: boolean;
  40934. private static _SheenTextureEnabled;
  40935. /**
  40936. * Are sheen textures enabled in the application.
  40937. */
  40938. static SheenTextureEnabled: boolean;
  40939. private static _AnisotropicTextureEnabled;
  40940. /**
  40941. * Are anisotropic textures enabled in the application.
  40942. */
  40943. static AnisotropicTextureEnabled: boolean;
  40944. private static _ThicknessTextureEnabled;
  40945. /**
  40946. * Are thickness textures enabled in the application.
  40947. */
  40948. static ThicknessTextureEnabled: boolean;
  40949. }
  40950. }
  40951. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40952. /** @hidden */
  40953. export var defaultFragmentDeclaration: {
  40954. name: string;
  40955. shader: string;
  40956. };
  40957. }
  40958. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40959. /** @hidden */
  40960. export var defaultUboDeclaration: {
  40961. name: string;
  40962. shader: string;
  40963. };
  40964. }
  40965. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40966. /** @hidden */
  40967. export var lightFragmentDeclaration: {
  40968. name: string;
  40969. shader: string;
  40970. };
  40971. }
  40972. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40973. /** @hidden */
  40974. export var lightUboDeclaration: {
  40975. name: string;
  40976. shader: string;
  40977. };
  40978. }
  40979. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40980. /** @hidden */
  40981. export var lightsFragmentFunctions: {
  40982. name: string;
  40983. shader: string;
  40984. };
  40985. }
  40986. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40987. /** @hidden */
  40988. export var shadowsFragmentFunctions: {
  40989. name: string;
  40990. shader: string;
  40991. };
  40992. }
  40993. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40994. /** @hidden */
  40995. export var fresnelFunction: {
  40996. name: string;
  40997. shader: string;
  40998. };
  40999. }
  41000. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41001. /** @hidden */
  41002. export var reflectionFunction: {
  41003. name: string;
  41004. shader: string;
  41005. };
  41006. }
  41007. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41008. /** @hidden */
  41009. export var bumpFragmentFunctions: {
  41010. name: string;
  41011. shader: string;
  41012. };
  41013. }
  41014. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41015. /** @hidden */
  41016. export var logDepthDeclaration: {
  41017. name: string;
  41018. shader: string;
  41019. };
  41020. }
  41021. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41022. /** @hidden */
  41023. export var bumpFragment: {
  41024. name: string;
  41025. shader: string;
  41026. };
  41027. }
  41028. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41029. /** @hidden */
  41030. export var depthPrePass: {
  41031. name: string;
  41032. shader: string;
  41033. };
  41034. }
  41035. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41036. /** @hidden */
  41037. export var lightFragment: {
  41038. name: string;
  41039. shader: string;
  41040. };
  41041. }
  41042. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41043. /** @hidden */
  41044. export var logDepthFragment: {
  41045. name: string;
  41046. shader: string;
  41047. };
  41048. }
  41049. declare module "babylonjs/Shaders/default.fragment" {
  41050. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41051. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41052. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41053. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41054. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41055. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41056. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41057. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41058. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41059. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41060. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41061. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41062. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41063. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41064. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41065. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41066. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41067. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41068. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41069. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41070. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41071. /** @hidden */
  41072. export var defaultPixelShader: {
  41073. name: string;
  41074. shader: string;
  41075. };
  41076. }
  41077. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41078. /** @hidden */
  41079. export var defaultVertexDeclaration: {
  41080. name: string;
  41081. shader: string;
  41082. };
  41083. }
  41084. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41085. /** @hidden */
  41086. export var bumpVertexDeclaration: {
  41087. name: string;
  41088. shader: string;
  41089. };
  41090. }
  41091. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41092. /** @hidden */
  41093. export var bumpVertex: {
  41094. name: string;
  41095. shader: string;
  41096. };
  41097. }
  41098. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41099. /** @hidden */
  41100. export var fogVertex: {
  41101. name: string;
  41102. shader: string;
  41103. };
  41104. }
  41105. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41106. /** @hidden */
  41107. export var shadowsVertex: {
  41108. name: string;
  41109. shader: string;
  41110. };
  41111. }
  41112. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41113. /** @hidden */
  41114. export var pointCloudVertex: {
  41115. name: string;
  41116. shader: string;
  41117. };
  41118. }
  41119. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41120. /** @hidden */
  41121. export var logDepthVertex: {
  41122. name: string;
  41123. shader: string;
  41124. };
  41125. }
  41126. declare module "babylonjs/Shaders/default.vertex" {
  41127. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41128. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41129. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41130. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41131. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41132. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41133. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41134. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41135. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41136. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41137. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41138. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41139. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41140. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41141. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41142. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41143. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41144. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41145. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41146. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41147. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41148. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41149. /** @hidden */
  41150. export var defaultVertexShader: {
  41151. name: string;
  41152. shader: string;
  41153. };
  41154. }
  41155. declare module "babylonjs/Materials/standardMaterial" {
  41156. import { SmartArray } from "babylonjs/Misc/smartArray";
  41157. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41158. import { Nullable } from "babylonjs/types";
  41159. import { Scene } from "babylonjs/scene";
  41160. import { Matrix } from "babylonjs/Maths/math.vector";
  41161. import { Color3 } from "babylonjs/Maths/math.color";
  41162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41164. import { Mesh } from "babylonjs/Meshes/mesh";
  41165. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41166. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41167. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41168. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41169. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41170. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41171. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41172. import "babylonjs/Shaders/default.fragment";
  41173. import "babylonjs/Shaders/default.vertex";
  41174. /** @hidden */
  41175. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41176. MAINUV1: boolean;
  41177. MAINUV2: boolean;
  41178. DIFFUSE: boolean;
  41179. DIFFUSEDIRECTUV: number;
  41180. AMBIENT: boolean;
  41181. AMBIENTDIRECTUV: number;
  41182. OPACITY: boolean;
  41183. OPACITYDIRECTUV: number;
  41184. OPACITYRGB: boolean;
  41185. REFLECTION: boolean;
  41186. EMISSIVE: boolean;
  41187. EMISSIVEDIRECTUV: number;
  41188. SPECULAR: boolean;
  41189. SPECULARDIRECTUV: number;
  41190. BUMP: boolean;
  41191. BUMPDIRECTUV: number;
  41192. PARALLAX: boolean;
  41193. PARALLAXOCCLUSION: boolean;
  41194. SPECULAROVERALPHA: boolean;
  41195. CLIPPLANE: boolean;
  41196. CLIPPLANE2: boolean;
  41197. CLIPPLANE3: boolean;
  41198. CLIPPLANE4: boolean;
  41199. ALPHATEST: boolean;
  41200. DEPTHPREPASS: boolean;
  41201. ALPHAFROMDIFFUSE: boolean;
  41202. POINTSIZE: boolean;
  41203. FOG: boolean;
  41204. SPECULARTERM: boolean;
  41205. DIFFUSEFRESNEL: boolean;
  41206. OPACITYFRESNEL: boolean;
  41207. REFLECTIONFRESNEL: boolean;
  41208. REFRACTIONFRESNEL: boolean;
  41209. EMISSIVEFRESNEL: boolean;
  41210. FRESNEL: boolean;
  41211. NORMAL: boolean;
  41212. UV1: boolean;
  41213. UV2: boolean;
  41214. VERTEXCOLOR: boolean;
  41215. VERTEXALPHA: boolean;
  41216. NUM_BONE_INFLUENCERS: number;
  41217. BonesPerMesh: number;
  41218. BONETEXTURE: boolean;
  41219. INSTANCES: boolean;
  41220. GLOSSINESS: boolean;
  41221. ROUGHNESS: boolean;
  41222. EMISSIVEASILLUMINATION: boolean;
  41223. LINKEMISSIVEWITHDIFFUSE: boolean;
  41224. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41225. LIGHTMAP: boolean;
  41226. LIGHTMAPDIRECTUV: number;
  41227. OBJECTSPACE_NORMALMAP: boolean;
  41228. USELIGHTMAPASSHADOWMAP: boolean;
  41229. REFLECTIONMAP_3D: boolean;
  41230. REFLECTIONMAP_SPHERICAL: boolean;
  41231. REFLECTIONMAP_PLANAR: boolean;
  41232. REFLECTIONMAP_CUBIC: boolean;
  41233. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41234. REFLECTIONMAP_PROJECTION: boolean;
  41235. REFLECTIONMAP_SKYBOX: boolean;
  41236. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41237. REFLECTIONMAP_EXPLICIT: boolean;
  41238. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41239. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41240. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41241. INVERTCUBICMAP: boolean;
  41242. LOGARITHMICDEPTH: boolean;
  41243. REFRACTION: boolean;
  41244. REFRACTIONMAP_3D: boolean;
  41245. REFLECTIONOVERALPHA: boolean;
  41246. TWOSIDEDLIGHTING: boolean;
  41247. SHADOWFLOAT: boolean;
  41248. MORPHTARGETS: boolean;
  41249. MORPHTARGETS_NORMAL: boolean;
  41250. MORPHTARGETS_TANGENT: boolean;
  41251. MORPHTARGETS_UV: boolean;
  41252. NUM_MORPH_INFLUENCERS: number;
  41253. NONUNIFORMSCALING: boolean;
  41254. PREMULTIPLYALPHA: boolean;
  41255. IMAGEPROCESSING: boolean;
  41256. VIGNETTE: boolean;
  41257. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41258. VIGNETTEBLENDMODEOPAQUE: boolean;
  41259. TONEMAPPING: boolean;
  41260. TONEMAPPING_ACES: boolean;
  41261. CONTRAST: boolean;
  41262. COLORCURVES: boolean;
  41263. COLORGRADING: boolean;
  41264. COLORGRADING3D: boolean;
  41265. SAMPLER3DGREENDEPTH: boolean;
  41266. SAMPLER3DBGRMAP: boolean;
  41267. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41268. MULTIVIEW: boolean;
  41269. /**
  41270. * If the reflection texture on this material is in linear color space
  41271. * @hidden
  41272. */
  41273. IS_REFLECTION_LINEAR: boolean;
  41274. /**
  41275. * If the refraction texture on this material is in linear color space
  41276. * @hidden
  41277. */
  41278. IS_REFRACTION_LINEAR: boolean;
  41279. EXPOSURE: boolean;
  41280. constructor();
  41281. setReflectionMode(modeToEnable: string): void;
  41282. }
  41283. /**
  41284. * This is the default material used in Babylon. It is the best trade off between quality
  41285. * and performances.
  41286. * @see http://doc.babylonjs.com/babylon101/materials
  41287. */
  41288. export class StandardMaterial extends PushMaterial {
  41289. private _diffuseTexture;
  41290. /**
  41291. * The basic texture of the material as viewed under a light.
  41292. */
  41293. diffuseTexture: Nullable<BaseTexture>;
  41294. private _ambientTexture;
  41295. /**
  41296. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41297. */
  41298. ambientTexture: Nullable<BaseTexture>;
  41299. private _opacityTexture;
  41300. /**
  41301. * Define the transparency of the material from a texture.
  41302. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41303. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41304. */
  41305. opacityTexture: Nullable<BaseTexture>;
  41306. private _reflectionTexture;
  41307. /**
  41308. * Define the texture used to display the reflection.
  41309. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41310. */
  41311. reflectionTexture: Nullable<BaseTexture>;
  41312. private _emissiveTexture;
  41313. /**
  41314. * Define texture of the material as if self lit.
  41315. * This will be mixed in the final result even in the absence of light.
  41316. */
  41317. emissiveTexture: Nullable<BaseTexture>;
  41318. private _specularTexture;
  41319. /**
  41320. * Define how the color and intensity of the highlight given by the light in the material.
  41321. */
  41322. specularTexture: Nullable<BaseTexture>;
  41323. private _bumpTexture;
  41324. /**
  41325. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41326. * 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.
  41327. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41328. */
  41329. bumpTexture: Nullable<BaseTexture>;
  41330. private _lightmapTexture;
  41331. /**
  41332. * Complex lighting can be computationally expensive to compute at runtime.
  41333. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41334. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41335. */
  41336. lightmapTexture: Nullable<BaseTexture>;
  41337. private _refractionTexture;
  41338. /**
  41339. * Define the texture used to display the refraction.
  41340. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41341. */
  41342. refractionTexture: Nullable<BaseTexture>;
  41343. /**
  41344. * The color of the material lit by the environmental background lighting.
  41345. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41346. */
  41347. ambientColor: Color3;
  41348. /**
  41349. * The basic color of the material as viewed under a light.
  41350. */
  41351. diffuseColor: Color3;
  41352. /**
  41353. * Define how the color and intensity of the highlight given by the light in the material.
  41354. */
  41355. specularColor: Color3;
  41356. /**
  41357. * Define the color of the material as if self lit.
  41358. * This will be mixed in the final result even in the absence of light.
  41359. */
  41360. emissiveColor: Color3;
  41361. /**
  41362. * Defines how sharp are the highlights in the material.
  41363. * The bigger the value the sharper giving a more glossy feeling to the result.
  41364. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41365. */
  41366. specularPower: number;
  41367. private _useAlphaFromDiffuseTexture;
  41368. /**
  41369. * Does the transparency come from the diffuse texture alpha channel.
  41370. */
  41371. useAlphaFromDiffuseTexture: boolean;
  41372. private _useEmissiveAsIllumination;
  41373. /**
  41374. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41375. */
  41376. useEmissiveAsIllumination: boolean;
  41377. private _linkEmissiveWithDiffuse;
  41378. /**
  41379. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41380. * the emissive level when the final color is close to one.
  41381. */
  41382. linkEmissiveWithDiffuse: boolean;
  41383. private _useSpecularOverAlpha;
  41384. /**
  41385. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41386. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41387. */
  41388. useSpecularOverAlpha: boolean;
  41389. private _useReflectionOverAlpha;
  41390. /**
  41391. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41392. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41393. */
  41394. useReflectionOverAlpha: boolean;
  41395. private _disableLighting;
  41396. /**
  41397. * Does lights from the scene impacts this material.
  41398. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41399. */
  41400. disableLighting: boolean;
  41401. private _useObjectSpaceNormalMap;
  41402. /**
  41403. * Allows using an object space normal map (instead of tangent space).
  41404. */
  41405. useObjectSpaceNormalMap: boolean;
  41406. private _useParallax;
  41407. /**
  41408. * Is parallax enabled or not.
  41409. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41410. */
  41411. useParallax: boolean;
  41412. private _useParallaxOcclusion;
  41413. /**
  41414. * Is parallax occlusion enabled or not.
  41415. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41416. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41417. */
  41418. useParallaxOcclusion: boolean;
  41419. /**
  41420. * 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.
  41421. */
  41422. parallaxScaleBias: number;
  41423. private _roughness;
  41424. /**
  41425. * Helps to define how blurry the reflections should appears in the material.
  41426. */
  41427. roughness: number;
  41428. /**
  41429. * In case of refraction, define the value of the index of refraction.
  41430. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41431. */
  41432. indexOfRefraction: number;
  41433. /**
  41434. * Invert the refraction texture alongside the y axis.
  41435. * It can be useful with procedural textures or probe for instance.
  41436. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41437. */
  41438. invertRefractionY: boolean;
  41439. /**
  41440. * Defines the alpha limits in alpha test mode.
  41441. */
  41442. alphaCutOff: number;
  41443. private _useLightmapAsShadowmap;
  41444. /**
  41445. * In case of light mapping, define whether the map contains light or shadow informations.
  41446. */
  41447. useLightmapAsShadowmap: boolean;
  41448. private _diffuseFresnelParameters;
  41449. /**
  41450. * Define the diffuse fresnel parameters of the material.
  41451. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41452. */
  41453. diffuseFresnelParameters: FresnelParameters;
  41454. private _opacityFresnelParameters;
  41455. /**
  41456. * Define the opacity fresnel parameters of the material.
  41457. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41458. */
  41459. opacityFresnelParameters: FresnelParameters;
  41460. private _reflectionFresnelParameters;
  41461. /**
  41462. * Define the reflection fresnel parameters of the material.
  41463. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41464. */
  41465. reflectionFresnelParameters: FresnelParameters;
  41466. private _refractionFresnelParameters;
  41467. /**
  41468. * Define the refraction fresnel parameters of the material.
  41469. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41470. */
  41471. refractionFresnelParameters: FresnelParameters;
  41472. private _emissiveFresnelParameters;
  41473. /**
  41474. * Define the emissive fresnel parameters of the material.
  41475. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41476. */
  41477. emissiveFresnelParameters: FresnelParameters;
  41478. private _useReflectionFresnelFromSpecular;
  41479. /**
  41480. * If true automatically deducts the fresnels values from the material specularity.
  41481. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41482. */
  41483. useReflectionFresnelFromSpecular: boolean;
  41484. private _useGlossinessFromSpecularMapAlpha;
  41485. /**
  41486. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41487. */
  41488. useGlossinessFromSpecularMapAlpha: boolean;
  41489. private _maxSimultaneousLights;
  41490. /**
  41491. * Defines the maximum number of lights that can be used in the material
  41492. */
  41493. maxSimultaneousLights: number;
  41494. private _invertNormalMapX;
  41495. /**
  41496. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41497. */
  41498. invertNormalMapX: boolean;
  41499. private _invertNormalMapY;
  41500. /**
  41501. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41502. */
  41503. invertNormalMapY: boolean;
  41504. private _twoSidedLighting;
  41505. /**
  41506. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41507. */
  41508. twoSidedLighting: boolean;
  41509. /**
  41510. * Default configuration related to image processing available in the standard Material.
  41511. */
  41512. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41513. /**
  41514. * Gets the image processing configuration used either in this material.
  41515. */
  41516. /**
  41517. * Sets the Default image processing configuration used either in the this material.
  41518. *
  41519. * If sets to null, the scene one is in use.
  41520. */
  41521. imageProcessingConfiguration: ImageProcessingConfiguration;
  41522. /**
  41523. * Keep track of the image processing observer to allow dispose and replace.
  41524. */
  41525. private _imageProcessingObserver;
  41526. /**
  41527. * Attaches a new image processing configuration to the Standard Material.
  41528. * @param configuration
  41529. */
  41530. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41531. /**
  41532. * Gets wether the color curves effect is enabled.
  41533. */
  41534. /**
  41535. * Sets wether the color curves effect is enabled.
  41536. */
  41537. cameraColorCurvesEnabled: boolean;
  41538. /**
  41539. * Gets wether the color grading effect is enabled.
  41540. */
  41541. /**
  41542. * Gets wether the color grading effect is enabled.
  41543. */
  41544. cameraColorGradingEnabled: boolean;
  41545. /**
  41546. * Gets wether tonemapping is enabled or not.
  41547. */
  41548. /**
  41549. * Sets wether tonemapping is enabled or not
  41550. */
  41551. cameraToneMappingEnabled: boolean;
  41552. /**
  41553. * The camera exposure used on this material.
  41554. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41555. * This corresponds to a photographic exposure.
  41556. */
  41557. /**
  41558. * The camera exposure used on this material.
  41559. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41560. * This corresponds to a photographic exposure.
  41561. */
  41562. cameraExposure: number;
  41563. /**
  41564. * Gets The camera contrast used on this material.
  41565. */
  41566. /**
  41567. * Sets The camera contrast used on this material.
  41568. */
  41569. cameraContrast: number;
  41570. /**
  41571. * Gets the Color Grading 2D Lookup Texture.
  41572. */
  41573. /**
  41574. * Sets the Color Grading 2D Lookup Texture.
  41575. */
  41576. cameraColorGradingTexture: Nullable<BaseTexture>;
  41577. /**
  41578. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41579. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41580. * 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;
  41581. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41582. */
  41583. /**
  41584. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41585. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41586. * 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;
  41587. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41588. */
  41589. cameraColorCurves: Nullable<ColorCurves>;
  41590. /**
  41591. * Custom callback helping to override the default shader used in the material.
  41592. */
  41593. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41594. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41595. protected _worldViewProjectionMatrix: Matrix;
  41596. protected _globalAmbientColor: Color3;
  41597. protected _useLogarithmicDepth: boolean;
  41598. protected _rebuildInParallel: boolean;
  41599. /**
  41600. * Instantiates a new standard material.
  41601. * This is the default material used in Babylon. It is the best trade off between quality
  41602. * and performances.
  41603. * @see http://doc.babylonjs.com/babylon101/materials
  41604. * @param name Define the name of the material in the scene
  41605. * @param scene Define the scene the material belong to
  41606. */
  41607. constructor(name: string, scene: Scene);
  41608. /**
  41609. * Gets a boolean indicating that current material needs to register RTT
  41610. */
  41611. readonly hasRenderTargetTextures: boolean;
  41612. /**
  41613. * Gets the current class name of the material e.g. "StandardMaterial"
  41614. * Mainly use in serialization.
  41615. * @returns the class name
  41616. */
  41617. getClassName(): string;
  41618. /**
  41619. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41620. * You can try switching to logarithmic depth.
  41621. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41622. */
  41623. useLogarithmicDepth: boolean;
  41624. /**
  41625. * Specifies if the material will require alpha blending
  41626. * @returns a boolean specifying if alpha blending is needed
  41627. */
  41628. needAlphaBlending(): boolean;
  41629. /**
  41630. * Specifies if this material should be rendered in alpha test mode
  41631. * @returns a boolean specifying if an alpha test is needed.
  41632. */
  41633. needAlphaTesting(): boolean;
  41634. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41635. /**
  41636. * Get the texture used for alpha test purpose.
  41637. * @returns the diffuse texture in case of the standard material.
  41638. */
  41639. getAlphaTestTexture(): Nullable<BaseTexture>;
  41640. /**
  41641. * Get if the submesh is ready to be used and all its information available.
  41642. * Child classes can use it to update shaders
  41643. * @param mesh defines the mesh to check
  41644. * @param subMesh defines which submesh to check
  41645. * @param useInstances specifies that instances should be used
  41646. * @returns a boolean indicating that the submesh is ready or not
  41647. */
  41648. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41649. /**
  41650. * Builds the material UBO layouts.
  41651. * Used internally during the effect preparation.
  41652. */
  41653. buildUniformLayout(): void;
  41654. /**
  41655. * Unbinds the material from the mesh
  41656. */
  41657. unbind(): void;
  41658. /**
  41659. * Binds the submesh to this material by preparing the effect and shader to draw
  41660. * @param world defines the world transformation matrix
  41661. * @param mesh defines the mesh containing the submesh
  41662. * @param subMesh defines the submesh to bind the material to
  41663. */
  41664. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41665. /**
  41666. * Get the list of animatables in the material.
  41667. * @returns the list of animatables object used in the material
  41668. */
  41669. getAnimatables(): IAnimatable[];
  41670. /**
  41671. * Gets the active textures from the material
  41672. * @returns an array of textures
  41673. */
  41674. getActiveTextures(): BaseTexture[];
  41675. /**
  41676. * Specifies if the material uses a texture
  41677. * @param texture defines the texture to check against the material
  41678. * @returns a boolean specifying if the material uses the texture
  41679. */
  41680. hasTexture(texture: BaseTexture): boolean;
  41681. /**
  41682. * Disposes the material
  41683. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41684. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41685. */
  41686. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41687. /**
  41688. * Makes a duplicate of the material, and gives it a new name
  41689. * @param name defines the new name for the duplicated material
  41690. * @returns the cloned material
  41691. */
  41692. clone(name: string): StandardMaterial;
  41693. /**
  41694. * Serializes this material in a JSON representation
  41695. * @returns the serialized material object
  41696. */
  41697. serialize(): any;
  41698. /**
  41699. * Creates a standard material from parsed material data
  41700. * @param source defines the JSON representation of the material
  41701. * @param scene defines the hosting scene
  41702. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41703. * @returns a new standard material
  41704. */
  41705. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41706. /**
  41707. * Are diffuse textures enabled in the application.
  41708. */
  41709. static DiffuseTextureEnabled: boolean;
  41710. /**
  41711. * Are ambient textures enabled in the application.
  41712. */
  41713. static AmbientTextureEnabled: boolean;
  41714. /**
  41715. * Are opacity textures enabled in the application.
  41716. */
  41717. static OpacityTextureEnabled: boolean;
  41718. /**
  41719. * Are reflection textures enabled in the application.
  41720. */
  41721. static ReflectionTextureEnabled: boolean;
  41722. /**
  41723. * Are emissive textures enabled in the application.
  41724. */
  41725. static EmissiveTextureEnabled: boolean;
  41726. /**
  41727. * Are specular textures enabled in the application.
  41728. */
  41729. static SpecularTextureEnabled: boolean;
  41730. /**
  41731. * Are bump textures enabled in the application.
  41732. */
  41733. static BumpTextureEnabled: boolean;
  41734. /**
  41735. * Are lightmap textures enabled in the application.
  41736. */
  41737. static LightmapTextureEnabled: boolean;
  41738. /**
  41739. * Are refraction textures enabled in the application.
  41740. */
  41741. static RefractionTextureEnabled: boolean;
  41742. /**
  41743. * Are color grading textures enabled in the application.
  41744. */
  41745. static ColorGradingTextureEnabled: boolean;
  41746. /**
  41747. * Are fresnels enabled in the application.
  41748. */
  41749. static FresnelEnabled: boolean;
  41750. }
  41751. }
  41752. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41753. import { Scene } from "babylonjs/scene";
  41754. import { Texture } from "babylonjs/Materials/Textures/texture";
  41755. /**
  41756. * A class extending Texture allowing drawing on a texture
  41757. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41758. */
  41759. export class DynamicTexture extends Texture {
  41760. private _generateMipMaps;
  41761. private _canvas;
  41762. private _context;
  41763. private _engine;
  41764. /**
  41765. * Creates a DynamicTexture
  41766. * @param name defines the name of the texture
  41767. * @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
  41768. * @param scene defines the scene where you want the texture
  41769. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41770. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41771. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41772. */
  41773. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41774. /**
  41775. * Get the current class name of the texture useful for serialization or dynamic coding.
  41776. * @returns "DynamicTexture"
  41777. */
  41778. getClassName(): string;
  41779. /**
  41780. * Gets the current state of canRescale
  41781. */
  41782. readonly canRescale: boolean;
  41783. private _recreate;
  41784. /**
  41785. * Scales the texture
  41786. * @param ratio the scale factor to apply to both width and height
  41787. */
  41788. scale(ratio: number): void;
  41789. /**
  41790. * Resizes the texture
  41791. * @param width the new width
  41792. * @param height the new height
  41793. */
  41794. scaleTo(width: number, height: number): void;
  41795. /**
  41796. * Gets the context of the canvas used by the texture
  41797. * @returns the canvas context of the dynamic texture
  41798. */
  41799. getContext(): CanvasRenderingContext2D;
  41800. /**
  41801. * Clears the texture
  41802. */
  41803. clear(): void;
  41804. /**
  41805. * Updates the texture
  41806. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41807. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41808. */
  41809. update(invertY?: boolean, premulAlpha?: boolean): void;
  41810. /**
  41811. * Draws text onto the texture
  41812. * @param text defines the text to be drawn
  41813. * @param x defines the placement of the text from the left
  41814. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41815. * @param font defines the font to be used with font-style, font-size, font-name
  41816. * @param color defines the color used for the text
  41817. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41818. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41819. * @param update defines whether texture is immediately update (default is true)
  41820. */
  41821. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41822. /**
  41823. * Clones the texture
  41824. * @returns the clone of the texture.
  41825. */
  41826. clone(): DynamicTexture;
  41827. /**
  41828. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41829. * @returns a serialized dynamic texture object
  41830. */
  41831. serialize(): any;
  41832. /** @hidden */
  41833. _rebuild(): void;
  41834. }
  41835. }
  41836. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41837. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41838. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41839. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41840. /** @hidden */
  41841. export var imageProcessingPixelShader: {
  41842. name: string;
  41843. shader: string;
  41844. };
  41845. }
  41846. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41847. import { Nullable } from "babylonjs/types";
  41848. import { Color4 } from "babylonjs/Maths/math.color";
  41849. import { Camera } from "babylonjs/Cameras/camera";
  41850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41851. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41852. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41853. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41854. import { Engine } from "babylonjs/Engines/engine";
  41855. import "babylonjs/Shaders/imageProcessing.fragment";
  41856. import "babylonjs/Shaders/postprocess.vertex";
  41857. /**
  41858. * ImageProcessingPostProcess
  41859. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41860. */
  41861. export class ImageProcessingPostProcess extends PostProcess {
  41862. /**
  41863. * Default configuration related to image processing available in the PBR Material.
  41864. */
  41865. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41866. /**
  41867. * Gets the image processing configuration used either in this material.
  41868. */
  41869. /**
  41870. * Sets the Default image processing configuration used either in the this material.
  41871. *
  41872. * If sets to null, the scene one is in use.
  41873. */
  41874. imageProcessingConfiguration: ImageProcessingConfiguration;
  41875. /**
  41876. * Keep track of the image processing observer to allow dispose and replace.
  41877. */
  41878. private _imageProcessingObserver;
  41879. /**
  41880. * Attaches a new image processing configuration to the PBR Material.
  41881. * @param configuration
  41882. */
  41883. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41884. /**
  41885. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41886. */
  41887. /**
  41888. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41889. */
  41890. colorCurves: Nullable<ColorCurves>;
  41891. /**
  41892. * Gets wether the color curves effect is enabled.
  41893. */
  41894. /**
  41895. * Sets wether the color curves effect is enabled.
  41896. */
  41897. colorCurvesEnabled: boolean;
  41898. /**
  41899. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41900. */
  41901. /**
  41902. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41903. */
  41904. colorGradingTexture: Nullable<BaseTexture>;
  41905. /**
  41906. * Gets wether the color grading effect is enabled.
  41907. */
  41908. /**
  41909. * Gets wether the color grading effect is enabled.
  41910. */
  41911. colorGradingEnabled: boolean;
  41912. /**
  41913. * Gets exposure used in the effect.
  41914. */
  41915. /**
  41916. * Sets exposure used in the effect.
  41917. */
  41918. exposure: number;
  41919. /**
  41920. * Gets wether tonemapping is enabled or not.
  41921. */
  41922. /**
  41923. * Sets wether tonemapping is enabled or not
  41924. */
  41925. toneMappingEnabled: boolean;
  41926. /**
  41927. * Gets the type of tone mapping effect.
  41928. */
  41929. /**
  41930. * Sets the type of tone mapping effect.
  41931. */
  41932. toneMappingType: number;
  41933. /**
  41934. * Gets contrast used in the effect.
  41935. */
  41936. /**
  41937. * Sets contrast used in the effect.
  41938. */
  41939. contrast: number;
  41940. /**
  41941. * Gets Vignette stretch size.
  41942. */
  41943. /**
  41944. * Sets Vignette stretch size.
  41945. */
  41946. vignetteStretch: number;
  41947. /**
  41948. * Gets Vignette centre X Offset.
  41949. */
  41950. /**
  41951. * Sets Vignette centre X Offset.
  41952. */
  41953. vignetteCentreX: number;
  41954. /**
  41955. * Gets Vignette centre Y Offset.
  41956. */
  41957. /**
  41958. * Sets Vignette centre Y Offset.
  41959. */
  41960. vignetteCentreY: number;
  41961. /**
  41962. * Gets Vignette weight or intensity of the vignette effect.
  41963. */
  41964. /**
  41965. * Sets Vignette weight or intensity of the vignette effect.
  41966. */
  41967. vignetteWeight: number;
  41968. /**
  41969. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41970. * if vignetteEnabled is set to true.
  41971. */
  41972. /**
  41973. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41974. * if vignetteEnabled is set to true.
  41975. */
  41976. vignetteColor: Color4;
  41977. /**
  41978. * Gets Camera field of view used by the Vignette effect.
  41979. */
  41980. /**
  41981. * Sets Camera field of view used by the Vignette effect.
  41982. */
  41983. vignetteCameraFov: number;
  41984. /**
  41985. * Gets the vignette blend mode allowing different kind of effect.
  41986. */
  41987. /**
  41988. * Sets the vignette blend mode allowing different kind of effect.
  41989. */
  41990. vignetteBlendMode: number;
  41991. /**
  41992. * Gets wether the vignette effect is enabled.
  41993. */
  41994. /**
  41995. * Sets wether the vignette effect is enabled.
  41996. */
  41997. vignetteEnabled: boolean;
  41998. private _fromLinearSpace;
  41999. /**
  42000. * Gets wether the input of the processing is in Gamma or Linear Space.
  42001. */
  42002. /**
  42003. * Sets wether the input of the processing is in Gamma or Linear Space.
  42004. */
  42005. fromLinearSpace: boolean;
  42006. /**
  42007. * Defines cache preventing GC.
  42008. */
  42009. private _defines;
  42010. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42011. /**
  42012. * "ImageProcessingPostProcess"
  42013. * @returns "ImageProcessingPostProcess"
  42014. */
  42015. getClassName(): string;
  42016. protected _updateParameters(): void;
  42017. dispose(camera?: Camera): void;
  42018. }
  42019. }
  42020. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42021. import { Scene } from "babylonjs/scene";
  42022. import { Color3 } from "babylonjs/Maths/math.color";
  42023. import { Mesh } from "babylonjs/Meshes/mesh";
  42024. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42025. import { Nullable } from "babylonjs/types";
  42026. /**
  42027. * Class containing static functions to help procedurally build meshes
  42028. */
  42029. export class GroundBuilder {
  42030. /**
  42031. * Creates a ground mesh
  42032. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42033. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42035. * @param name defines the name of the mesh
  42036. * @param options defines the options used to create the mesh
  42037. * @param scene defines the hosting scene
  42038. * @returns the ground mesh
  42039. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42040. */
  42041. static CreateGround(name: string, options: {
  42042. width?: number;
  42043. height?: number;
  42044. subdivisions?: number;
  42045. subdivisionsX?: number;
  42046. subdivisionsY?: number;
  42047. updatable?: boolean;
  42048. }, scene: any): Mesh;
  42049. /**
  42050. * Creates a tiled ground mesh
  42051. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42052. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42053. * * 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
  42054. * * 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
  42055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42056. * @param name defines the name of the mesh
  42057. * @param options defines the options used to create the mesh
  42058. * @param scene defines the hosting scene
  42059. * @returns the tiled ground mesh
  42060. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42061. */
  42062. static CreateTiledGround(name: string, options: {
  42063. xmin: number;
  42064. zmin: number;
  42065. xmax: number;
  42066. zmax: number;
  42067. subdivisions?: {
  42068. w: number;
  42069. h: number;
  42070. };
  42071. precision?: {
  42072. w: number;
  42073. h: number;
  42074. };
  42075. updatable?: boolean;
  42076. }, scene?: Nullable<Scene>): Mesh;
  42077. /**
  42078. * Creates a ground mesh from a height map
  42079. * * The parameter `url` sets the URL of the height map image resource.
  42080. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42081. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42082. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42083. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42084. * * 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.
  42085. * * 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).
  42086. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42088. * @param name defines the name of the mesh
  42089. * @param url defines the url to the height map
  42090. * @param options defines the options used to create the mesh
  42091. * @param scene defines the hosting scene
  42092. * @returns the ground mesh
  42093. * @see https://doc.babylonjs.com/babylon101/height_map
  42094. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42095. */
  42096. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42097. width?: number;
  42098. height?: number;
  42099. subdivisions?: number;
  42100. minHeight?: number;
  42101. maxHeight?: number;
  42102. colorFilter?: Color3;
  42103. alphaFilter?: number;
  42104. updatable?: boolean;
  42105. onReady?: (mesh: GroundMesh) => void;
  42106. }, scene?: Nullable<Scene>): GroundMesh;
  42107. }
  42108. }
  42109. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42110. import { Vector4 } from "babylonjs/Maths/math.vector";
  42111. import { Mesh } from "babylonjs/Meshes/mesh";
  42112. /**
  42113. * Class containing static functions to help procedurally build meshes
  42114. */
  42115. export class TorusBuilder {
  42116. /**
  42117. * Creates a torus mesh
  42118. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42119. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42120. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42124. * @param name defines the name of the mesh
  42125. * @param options defines the options used to create the mesh
  42126. * @param scene defines the hosting scene
  42127. * @returns the torus mesh
  42128. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42129. */
  42130. static CreateTorus(name: string, options: {
  42131. diameter?: number;
  42132. thickness?: number;
  42133. tessellation?: number;
  42134. updatable?: boolean;
  42135. sideOrientation?: number;
  42136. frontUVs?: Vector4;
  42137. backUVs?: Vector4;
  42138. }, scene: any): Mesh;
  42139. }
  42140. }
  42141. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42142. import { Vector4 } from "babylonjs/Maths/math.vector";
  42143. import { Color4 } from "babylonjs/Maths/math.color";
  42144. import { Mesh } from "babylonjs/Meshes/mesh";
  42145. /**
  42146. * Class containing static functions to help procedurally build meshes
  42147. */
  42148. export class CylinderBuilder {
  42149. /**
  42150. * Creates a cylinder or a cone mesh
  42151. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42152. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42153. * * 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.
  42154. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42155. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42156. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42157. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42158. * * 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).
  42159. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42160. * * 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).
  42161. * * 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
  42162. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42163. * * 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
  42164. * * 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.
  42165. * * If `enclose` is false, a ring surface is one element.
  42166. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42167. * * 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
  42168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42171. * @param name defines the name of the mesh
  42172. * @param options defines the options used to create the mesh
  42173. * @param scene defines the hosting scene
  42174. * @returns the cylinder mesh
  42175. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42176. */
  42177. static CreateCylinder(name: string, options: {
  42178. height?: number;
  42179. diameterTop?: number;
  42180. diameterBottom?: number;
  42181. diameter?: number;
  42182. tessellation?: number;
  42183. subdivisions?: number;
  42184. arc?: number;
  42185. faceColors?: Color4[];
  42186. faceUV?: Vector4[];
  42187. updatable?: boolean;
  42188. hasRings?: boolean;
  42189. enclose?: boolean;
  42190. cap?: number;
  42191. sideOrientation?: number;
  42192. frontUVs?: Vector4;
  42193. backUVs?: Vector4;
  42194. }, scene: any): Mesh;
  42195. }
  42196. }
  42197. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42198. import { Observable } from "babylonjs/Misc/observable";
  42199. import { Nullable } from "babylonjs/types";
  42200. import { Camera } from "babylonjs/Cameras/camera";
  42201. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42202. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42203. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42204. import { Scene } from "babylonjs/scene";
  42205. import { Vector3 } from "babylonjs/Maths/math.vector";
  42206. import { Color3 } from "babylonjs/Maths/math.color";
  42207. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42209. import { Mesh } from "babylonjs/Meshes/mesh";
  42210. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42211. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42212. import "babylonjs/Meshes/Builders/groundBuilder";
  42213. import "babylonjs/Meshes/Builders/torusBuilder";
  42214. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42215. import "babylonjs/Gamepads/gamepadSceneComponent";
  42216. import "babylonjs/Animations/animatable";
  42217. /**
  42218. * Options to modify the vr teleportation behavior.
  42219. */
  42220. export interface VRTeleportationOptions {
  42221. /**
  42222. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42223. */
  42224. floorMeshName?: string;
  42225. /**
  42226. * A list of meshes to be used as the teleportation floor. (default: empty)
  42227. */
  42228. floorMeshes?: Mesh[];
  42229. }
  42230. /**
  42231. * Options to modify the vr experience helper's behavior.
  42232. */
  42233. export interface VRExperienceHelperOptions extends WebVROptions {
  42234. /**
  42235. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42236. */
  42237. createDeviceOrientationCamera?: boolean;
  42238. /**
  42239. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42240. */
  42241. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42242. /**
  42243. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42244. */
  42245. laserToggle?: boolean;
  42246. /**
  42247. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42248. */
  42249. floorMeshes?: Mesh[];
  42250. /**
  42251. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42252. */
  42253. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42254. }
  42255. /**
  42256. * Event containing information after VR has been entered
  42257. */
  42258. export class OnAfterEnteringVRObservableEvent {
  42259. /**
  42260. * If entering vr was successful
  42261. */
  42262. success: boolean;
  42263. }
  42264. /**
  42265. * Helps to quickly add VR support to an existing scene.
  42266. * See http://doc.babylonjs.com/how_to/webvr_helper
  42267. */
  42268. export class VRExperienceHelper {
  42269. /** Options to modify the vr experience helper's behavior. */
  42270. webVROptions: VRExperienceHelperOptions;
  42271. private _scene;
  42272. private _position;
  42273. private _btnVR;
  42274. private _btnVRDisplayed;
  42275. private _webVRsupported;
  42276. private _webVRready;
  42277. private _webVRrequesting;
  42278. private _webVRpresenting;
  42279. private _hasEnteredVR;
  42280. private _fullscreenVRpresenting;
  42281. private _canvas;
  42282. private _webVRCamera;
  42283. private _vrDeviceOrientationCamera;
  42284. private _deviceOrientationCamera;
  42285. private _existingCamera;
  42286. private _onKeyDown;
  42287. private _onVrDisplayPresentChange;
  42288. private _onVRDisplayChanged;
  42289. private _onVRRequestPresentStart;
  42290. private _onVRRequestPresentComplete;
  42291. /**
  42292. * 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)
  42293. */
  42294. enableGazeEvenWhenNoPointerLock: boolean;
  42295. /**
  42296. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42297. */
  42298. exitVROnDoubleTap: boolean;
  42299. /**
  42300. * Observable raised right before entering VR.
  42301. */
  42302. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42303. /**
  42304. * Observable raised when entering VR has completed.
  42305. */
  42306. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42307. /**
  42308. * Observable raised when exiting VR.
  42309. */
  42310. onExitingVRObservable: Observable<VRExperienceHelper>;
  42311. /**
  42312. * Observable raised when controller mesh is loaded.
  42313. */
  42314. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42315. /** Return this.onEnteringVRObservable
  42316. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42317. */
  42318. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42319. /** Return this.onExitingVRObservable
  42320. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42321. */
  42322. readonly onExitingVR: Observable<VRExperienceHelper>;
  42323. /** Return this.onControllerMeshLoadedObservable
  42324. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42325. */
  42326. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42327. private _rayLength;
  42328. private _useCustomVRButton;
  42329. private _teleportationRequested;
  42330. private _teleportActive;
  42331. private _floorMeshName;
  42332. private _floorMeshesCollection;
  42333. private _rotationAllowed;
  42334. private _teleportBackwardsVector;
  42335. private _teleportationTarget;
  42336. private _isDefaultTeleportationTarget;
  42337. private _postProcessMove;
  42338. private _teleportationFillColor;
  42339. private _teleportationBorderColor;
  42340. private _rotationAngle;
  42341. private _haloCenter;
  42342. private _cameraGazer;
  42343. private _padSensibilityUp;
  42344. private _padSensibilityDown;
  42345. private _leftController;
  42346. private _rightController;
  42347. /**
  42348. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42349. */
  42350. onNewMeshSelected: Observable<AbstractMesh>;
  42351. /**
  42352. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42353. * This observable will provide the mesh and the controller used to select the mesh
  42354. */
  42355. onMeshSelectedWithController: Observable<{
  42356. mesh: AbstractMesh;
  42357. controller: WebVRController;
  42358. }>;
  42359. /**
  42360. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42361. */
  42362. onNewMeshPicked: Observable<PickingInfo>;
  42363. private _circleEase;
  42364. /**
  42365. * Observable raised before camera teleportation
  42366. */
  42367. onBeforeCameraTeleport: Observable<Vector3>;
  42368. /**
  42369. * Observable raised after camera teleportation
  42370. */
  42371. onAfterCameraTeleport: Observable<Vector3>;
  42372. /**
  42373. * Observable raised when current selected mesh gets unselected
  42374. */
  42375. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42376. private _raySelectionPredicate;
  42377. /**
  42378. * To be optionaly changed by user to define custom ray selection
  42379. */
  42380. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42381. /**
  42382. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42383. */
  42384. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42385. /**
  42386. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42387. */
  42388. teleportationEnabled: boolean;
  42389. private _defaultHeight;
  42390. private _teleportationInitialized;
  42391. private _interactionsEnabled;
  42392. private _interactionsRequested;
  42393. private _displayGaze;
  42394. private _displayLaserPointer;
  42395. /**
  42396. * The mesh used to display where the user is going to teleport.
  42397. */
  42398. /**
  42399. * Sets the mesh to be used to display where the user is going to teleport.
  42400. */
  42401. teleportationTarget: Mesh;
  42402. /**
  42403. * 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
  42404. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42405. * See http://doc.babylonjs.com/resources/baking_transformations
  42406. */
  42407. gazeTrackerMesh: Mesh;
  42408. /**
  42409. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42410. */
  42411. updateGazeTrackerScale: boolean;
  42412. /**
  42413. * If the gaze trackers color should be updated when selecting meshes
  42414. */
  42415. updateGazeTrackerColor: boolean;
  42416. /**
  42417. * The gaze tracking mesh corresponding to the left controller
  42418. */
  42419. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42420. /**
  42421. * The gaze tracking mesh corresponding to the right controller
  42422. */
  42423. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42424. /**
  42425. * If the ray of the gaze should be displayed.
  42426. */
  42427. /**
  42428. * Sets if the ray of the gaze should be displayed.
  42429. */
  42430. displayGaze: boolean;
  42431. /**
  42432. * If the ray of the LaserPointer should be displayed.
  42433. */
  42434. /**
  42435. * Sets if the ray of the LaserPointer should be displayed.
  42436. */
  42437. displayLaserPointer: boolean;
  42438. /**
  42439. * The deviceOrientationCamera used as the camera when not in VR.
  42440. */
  42441. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42442. /**
  42443. * Based on the current WebVR support, returns the current VR camera used.
  42444. */
  42445. readonly currentVRCamera: Nullable<Camera>;
  42446. /**
  42447. * The webVRCamera which is used when in VR.
  42448. */
  42449. readonly webVRCamera: WebVRFreeCamera;
  42450. /**
  42451. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42452. */
  42453. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42454. /**
  42455. * The html button that is used to trigger entering into VR.
  42456. */
  42457. readonly vrButton: Nullable<HTMLButtonElement>;
  42458. private readonly _teleportationRequestInitiated;
  42459. /**
  42460. * Defines wether or not Pointer lock should be requested when switching to
  42461. * full screen.
  42462. */
  42463. requestPointerLockOnFullScreen: boolean;
  42464. /**
  42465. * Instantiates a VRExperienceHelper.
  42466. * Helps to quickly add VR support to an existing scene.
  42467. * @param scene The scene the VRExperienceHelper belongs to.
  42468. * @param webVROptions Options to modify the vr experience helper's behavior.
  42469. */
  42470. constructor(scene: Scene,
  42471. /** Options to modify the vr experience helper's behavior. */
  42472. webVROptions?: VRExperienceHelperOptions);
  42473. private _onDefaultMeshLoaded;
  42474. private _onResize;
  42475. private _onFullscreenChange;
  42476. /**
  42477. * Gets a value indicating if we are currently in VR mode.
  42478. */
  42479. readonly isInVRMode: boolean;
  42480. private onVrDisplayPresentChange;
  42481. private onVRDisplayChanged;
  42482. private moveButtonToBottomRight;
  42483. private displayVRButton;
  42484. private updateButtonVisibility;
  42485. private _cachedAngularSensibility;
  42486. /**
  42487. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42488. * Otherwise, will use the fullscreen API.
  42489. */
  42490. enterVR(): void;
  42491. /**
  42492. * Attempt to exit VR, or fullscreen.
  42493. */
  42494. exitVR(): void;
  42495. /**
  42496. * The position of the vr experience helper.
  42497. */
  42498. /**
  42499. * Sets the position of the vr experience helper.
  42500. */
  42501. position: Vector3;
  42502. /**
  42503. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42504. */
  42505. enableInteractions(): void;
  42506. private readonly _noControllerIsActive;
  42507. private beforeRender;
  42508. private _isTeleportationFloor;
  42509. /**
  42510. * Adds a floor mesh to be used for teleportation.
  42511. * @param floorMesh the mesh to be used for teleportation.
  42512. */
  42513. addFloorMesh(floorMesh: Mesh): void;
  42514. /**
  42515. * Removes a floor mesh from being used for teleportation.
  42516. * @param floorMesh the mesh to be removed.
  42517. */
  42518. removeFloorMesh(floorMesh: Mesh): void;
  42519. /**
  42520. * Enables interactions and teleportation using the VR controllers and gaze.
  42521. * @param vrTeleportationOptions options to modify teleportation behavior.
  42522. */
  42523. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42524. private _onNewGamepadConnected;
  42525. private _tryEnableInteractionOnController;
  42526. private _onNewGamepadDisconnected;
  42527. private _enableInteractionOnController;
  42528. private _checkTeleportWithRay;
  42529. private _checkRotate;
  42530. private _checkTeleportBackwards;
  42531. private _enableTeleportationOnController;
  42532. private _createTeleportationCircles;
  42533. private _displayTeleportationTarget;
  42534. private _hideTeleportationTarget;
  42535. private _rotateCamera;
  42536. private _moveTeleportationSelectorTo;
  42537. private _workingVector;
  42538. private _workingQuaternion;
  42539. private _workingMatrix;
  42540. /**
  42541. * Teleports the users feet to the desired location
  42542. * @param location The location where the user's feet should be placed
  42543. */
  42544. teleportCamera(location: Vector3): void;
  42545. private _convertNormalToDirectionOfRay;
  42546. private _castRayAndSelectObject;
  42547. private _notifySelectedMeshUnselected;
  42548. /**
  42549. * Sets the color of the laser ray from the vr controllers.
  42550. * @param color new color for the ray.
  42551. */
  42552. changeLaserColor(color: Color3): void;
  42553. /**
  42554. * Sets the color of the ray from the vr headsets gaze.
  42555. * @param color new color for the ray.
  42556. */
  42557. changeGazeColor(color: Color3): void;
  42558. /**
  42559. * Exits VR and disposes of the vr experience helper
  42560. */
  42561. dispose(): void;
  42562. /**
  42563. * Gets the name of the VRExperienceHelper class
  42564. * @returns "VRExperienceHelper"
  42565. */
  42566. getClassName(): string;
  42567. }
  42568. }
  42569. declare module "babylonjs/Cameras/VR/index" {
  42570. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42571. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42572. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42573. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42574. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42575. export * from "babylonjs/Cameras/VR/webVRCamera";
  42576. }
  42577. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42578. import { Observable } from "babylonjs/Misc/observable";
  42579. import { Nullable } from "babylonjs/types";
  42580. import { IDisposable, Scene } from "babylonjs/scene";
  42581. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42582. /**
  42583. * Manages an XRSession to work with Babylon's engine
  42584. * @see https://doc.babylonjs.com/how_to/webxr
  42585. */
  42586. export class WebXRSessionManager implements IDisposable {
  42587. private scene;
  42588. /**
  42589. * Fires every time a new xrFrame arrives which can be used to update the camera
  42590. */
  42591. onXRFrameObservable: Observable<any>;
  42592. /**
  42593. * Fires when the xr session is ended either by the device or manually done
  42594. */
  42595. onXRSessionEnded: Observable<any>;
  42596. /**
  42597. * Underlying xr session
  42598. */
  42599. session: XRSession;
  42600. /**
  42601. * Type of reference space used when creating the session
  42602. */
  42603. referenceSpace: XRReferenceSpace;
  42604. /** @hidden */
  42605. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42606. /**
  42607. * Current XR frame
  42608. */
  42609. currentFrame: Nullable<XRFrame>;
  42610. private _xrNavigator;
  42611. private baseLayer;
  42612. /**
  42613. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42614. * @param scene The scene which the session should be created for
  42615. */
  42616. constructor(scene: Scene);
  42617. /**
  42618. * Initializes the manager
  42619. * After initialization enterXR can be called to start an XR session
  42620. * @returns Promise which resolves after it is initialized
  42621. */
  42622. initializeAsync(): Promise<void>;
  42623. /**
  42624. * Initializes an xr session
  42625. * @param xrSessionMode mode to initialize
  42626. * @returns a promise which will resolve once the session has been initialized
  42627. */
  42628. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42629. /**
  42630. * Sets the reference space on the xr session
  42631. * @param referenceSpace space to set
  42632. * @returns a promise that will resolve once the reference space has been set
  42633. */
  42634. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42635. /**
  42636. * Updates the render state of the session
  42637. * @param state state to set
  42638. * @returns a promise that resolves once the render state has been updated
  42639. */
  42640. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42641. /**
  42642. * Starts rendering to the xr layer
  42643. * @returns a promise that will resolve once rendering has started
  42644. */
  42645. startRenderingToXRAsync(): Promise<void>;
  42646. /**
  42647. * Stops the xrSession and restores the renderloop
  42648. * @returns Promise which resolves after it exits XR
  42649. */
  42650. exitXRAsync(): Promise<unknown>;
  42651. /**
  42652. * Checks if a session would be supported for the creation options specified
  42653. * @param sessionMode session mode to check if supported eg. immersive-vr
  42654. * @returns true if supported
  42655. */
  42656. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42657. /**
  42658. * @hidden
  42659. * Converts the render layer of xrSession to a render target
  42660. * @param session session to create render target for
  42661. * @param scene scene the new render target should be created for
  42662. */
  42663. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42664. /**
  42665. * Disposes of the session manager
  42666. */
  42667. dispose(): void;
  42668. }
  42669. }
  42670. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42671. import { Scene } from "babylonjs/scene";
  42672. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42673. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42674. /**
  42675. * WebXR Camera which holds the views for the xrSession
  42676. * @see https://doc.babylonjs.com/how_to/webxr
  42677. */
  42678. export class WebXRCamera extends FreeCamera {
  42679. private static _TmpMatrix;
  42680. /**
  42681. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42682. * @param name the name of the camera
  42683. * @param scene the scene to add the camera to
  42684. */
  42685. constructor(name: string, scene: Scene);
  42686. private _updateNumberOfRigCameras;
  42687. /** @hidden */
  42688. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42689. /**
  42690. * Updates the cameras position from the current pose information of the XR session
  42691. * @param xrSessionManager the session containing pose information
  42692. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42693. */
  42694. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42695. }
  42696. }
  42697. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42698. import { Nullable } from "babylonjs/types";
  42699. import { IDisposable } from "babylonjs/scene";
  42700. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42701. /**
  42702. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42703. */
  42704. export class WebXRManagedOutputCanvas implements IDisposable {
  42705. private helper;
  42706. private _canvas;
  42707. /**
  42708. * xrpresent context of the canvas which can be used to display/mirror xr content
  42709. */
  42710. canvasContext: WebGLRenderingContext;
  42711. /**
  42712. * xr layer for the canvas
  42713. */
  42714. xrLayer: Nullable<XRWebGLLayer>;
  42715. /**
  42716. * Initializes the xr layer for the session
  42717. * @param xrSession xr session
  42718. * @returns a promise that will resolve once the XR Layer has been created
  42719. */
  42720. initializeXRLayerAsync(xrSession: any): any;
  42721. /**
  42722. * Initializes the canvas to be added/removed upon entering/exiting xr
  42723. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42724. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42725. */
  42726. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42727. /**
  42728. * Disposes of the object
  42729. */
  42730. dispose(): void;
  42731. private _setManagedOutputCanvas;
  42732. private _addCanvas;
  42733. private _removeCanvas;
  42734. }
  42735. }
  42736. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42737. import { Observable } from "babylonjs/Misc/observable";
  42738. import { IDisposable, Scene } from "babylonjs/scene";
  42739. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42741. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42742. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42743. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42744. /**
  42745. * States of the webXR experience
  42746. */
  42747. export enum WebXRState {
  42748. /**
  42749. * Transitioning to being in XR mode
  42750. */
  42751. ENTERING_XR = 0,
  42752. /**
  42753. * Transitioning to non XR mode
  42754. */
  42755. EXITING_XR = 1,
  42756. /**
  42757. * In XR mode and presenting
  42758. */
  42759. IN_XR = 2,
  42760. /**
  42761. * Not entered XR mode
  42762. */
  42763. NOT_IN_XR = 3
  42764. }
  42765. /**
  42766. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42767. * @see https://doc.babylonjs.com/how_to/webxr
  42768. */
  42769. export class WebXRExperienceHelper implements IDisposable {
  42770. private scene;
  42771. /**
  42772. * 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
  42773. */
  42774. container: AbstractMesh;
  42775. /**
  42776. * Camera used to render xr content
  42777. */
  42778. camera: WebXRCamera;
  42779. /**
  42780. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42781. */
  42782. state: WebXRState;
  42783. private _setState;
  42784. private static _TmpVector;
  42785. /**
  42786. * Fires when the state of the experience helper has changed
  42787. */
  42788. onStateChangedObservable: Observable<WebXRState>;
  42789. /** Session manager used to keep track of xr session */
  42790. sessionManager: WebXRSessionManager;
  42791. private _nonVRCamera;
  42792. private _originalSceneAutoClear;
  42793. private _supported;
  42794. /**
  42795. * Creates the experience helper
  42796. * @param scene the scene to attach the experience helper to
  42797. * @returns a promise for the experience helper
  42798. */
  42799. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42800. /**
  42801. * Creates a WebXRExperienceHelper
  42802. * @param scene The scene the helper should be created in
  42803. */
  42804. private constructor();
  42805. /**
  42806. * Exits XR mode and returns the scene to its original state
  42807. * @returns promise that resolves after xr mode has exited
  42808. */
  42809. exitXRAsync(): Promise<unknown>;
  42810. /**
  42811. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42812. * @param sessionCreationOptions options for the XR session
  42813. * @param referenceSpaceType frame of reference of the XR session
  42814. * @param outputCanvas the output canvas that will be used to enter XR mode
  42815. * @returns promise that resolves after xr mode has entered
  42816. */
  42817. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42818. /**
  42819. * Updates the global position of the camera by moving the camera's container
  42820. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42821. * @param position The desired global position of the camera
  42822. */
  42823. setPositionOfCameraUsingContainer(position: Vector3): void;
  42824. /**
  42825. * Rotates the xr camera by rotating the camera's container around the camera's position
  42826. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42827. * @param rotation the desired quaternion rotation to apply to the camera
  42828. */
  42829. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42830. /**
  42831. * Disposes of the experience helper
  42832. */
  42833. dispose(): void;
  42834. }
  42835. }
  42836. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42837. import { Nullable } from "babylonjs/types";
  42838. import { Observable } from "babylonjs/Misc/observable";
  42839. import { IDisposable, Scene } from "babylonjs/scene";
  42840. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42841. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42842. /**
  42843. * Button which can be used to enter a different mode of XR
  42844. */
  42845. export class WebXREnterExitUIButton {
  42846. /** button element */
  42847. element: HTMLElement;
  42848. /** XR initialization options for the button */
  42849. sessionMode: XRSessionMode;
  42850. /** Reference space type */
  42851. referenceSpaceType: XRReferenceSpaceType;
  42852. /**
  42853. * Creates a WebXREnterExitUIButton
  42854. * @param element button element
  42855. * @param sessionMode XR initialization session mode
  42856. * @param referenceSpaceType the type of reference space to be used
  42857. */
  42858. constructor(
  42859. /** button element */
  42860. element: HTMLElement,
  42861. /** XR initialization options for the button */
  42862. sessionMode: XRSessionMode,
  42863. /** Reference space type */
  42864. referenceSpaceType: XRReferenceSpaceType);
  42865. /**
  42866. * Overwritable function which can be used to update the button's visuals when the state changes
  42867. * @param activeButton the current active button in the UI
  42868. */
  42869. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42870. }
  42871. /**
  42872. * Options to create the webXR UI
  42873. */
  42874. export class WebXREnterExitUIOptions {
  42875. /**
  42876. * Context to enter xr with
  42877. */
  42878. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42879. /**
  42880. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42881. */
  42882. customButtons?: Array<WebXREnterExitUIButton>;
  42883. }
  42884. /**
  42885. * UI to allow the user to enter/exit XR mode
  42886. */
  42887. export class WebXREnterExitUI implements IDisposable {
  42888. private scene;
  42889. private _overlay;
  42890. private _buttons;
  42891. private _activeButton;
  42892. /**
  42893. * Fired every time the active button is changed.
  42894. *
  42895. * When xr is entered via a button that launches xr that button will be the callback parameter
  42896. *
  42897. * When exiting xr the callback parameter will be null)
  42898. */
  42899. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42900. /**
  42901. * Creates UI to allow the user to enter/exit XR mode
  42902. * @param scene the scene to add the ui to
  42903. * @param helper the xr experience helper to enter/exit xr with
  42904. * @param options options to configure the UI
  42905. * @returns the created ui
  42906. */
  42907. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42908. private constructor();
  42909. private _updateButtons;
  42910. /**
  42911. * Disposes of the object
  42912. */
  42913. dispose(): void;
  42914. }
  42915. }
  42916. declare module "babylonjs/Cameras/XR/webXRController" {
  42917. import { Nullable } from "babylonjs/types";
  42918. import { Observable } from "babylonjs/Misc/observable";
  42919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42920. import { Ray } from "babylonjs/Culling/ray";
  42921. import { Scene } from "babylonjs/scene";
  42922. /**
  42923. * Represents an XR input
  42924. */
  42925. export class WebXRController {
  42926. private scene;
  42927. /** The underlying input source for the controller */
  42928. inputSource: XRInputSource;
  42929. private parentContainer;
  42930. /**
  42931. * 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
  42932. */
  42933. grip?: AbstractMesh;
  42934. /**
  42935. * Pointer which can be used to select objects or attach a visible laser to
  42936. */
  42937. pointer: AbstractMesh;
  42938. /**
  42939. * Event that fires when the controller is removed/disposed
  42940. */
  42941. onDisposeObservable: Observable<{}>;
  42942. private _tmpMatrix;
  42943. private _tmpQuaternion;
  42944. private _tmpVector;
  42945. /**
  42946. * Creates the controller
  42947. * @see https://doc.babylonjs.com/how_to/webxr
  42948. * @param scene the scene which the controller should be associated to
  42949. * @param inputSource the underlying input source for the controller
  42950. * @param parentContainer parent that the controller meshes should be children of
  42951. */
  42952. constructor(scene: Scene,
  42953. /** The underlying input source for the controller */
  42954. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42955. /**
  42956. * Updates the controller pose based on the given XRFrame
  42957. * @param xrFrame xr frame to update the pose with
  42958. * @param referenceSpace reference space to use
  42959. */
  42960. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42961. /**
  42962. * Gets a world space ray coming from the controller
  42963. * @param result the resulting ray
  42964. */
  42965. getWorldPointerRayToRef(result: Ray): void;
  42966. /**
  42967. * Disposes of the object
  42968. */
  42969. dispose(): void;
  42970. }
  42971. }
  42972. declare module "babylonjs/Cameras/XR/webXRInput" {
  42973. import { Observable } from "babylonjs/Misc/observable";
  42974. import { IDisposable } from "babylonjs/scene";
  42975. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42976. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42977. /**
  42978. * XR input used to track XR inputs such as controllers/rays
  42979. */
  42980. export class WebXRInput implements IDisposable {
  42981. /**
  42982. * Base experience the input listens to
  42983. */
  42984. baseExperience: WebXRExperienceHelper;
  42985. /**
  42986. * XR controllers being tracked
  42987. */
  42988. controllers: Array<WebXRController>;
  42989. private _frameObserver;
  42990. private _stateObserver;
  42991. /**
  42992. * Event when a controller has been connected/added
  42993. */
  42994. onControllerAddedObservable: Observable<WebXRController>;
  42995. /**
  42996. * Event when a controller has been removed/disconnected
  42997. */
  42998. onControllerRemovedObservable: Observable<WebXRController>;
  42999. /**
  43000. * Initializes the WebXRInput
  43001. * @param baseExperience experience helper which the input should be created for
  43002. */
  43003. constructor(
  43004. /**
  43005. * Base experience the input listens to
  43006. */
  43007. baseExperience: WebXRExperienceHelper);
  43008. private _onInputSourcesChange;
  43009. private _addAndRemoveControllers;
  43010. /**
  43011. * Disposes of the object
  43012. */
  43013. dispose(): void;
  43014. }
  43015. }
  43016. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43018. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43019. /**
  43020. * Enables teleportation
  43021. */
  43022. export class WebXRControllerTeleportation {
  43023. private _teleportationFillColor;
  43024. private _teleportationBorderColor;
  43025. private _tmpRay;
  43026. private _tmpVector;
  43027. /**
  43028. * Creates a WebXRControllerTeleportation
  43029. * @param input input manager to add teleportation to
  43030. * @param floorMeshes floormeshes which can be teleported to
  43031. */
  43032. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43033. }
  43034. }
  43035. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43036. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43037. /**
  43038. * Handles pointer input automatically for the pointer of XR controllers
  43039. */
  43040. export class WebXRControllerPointerSelection {
  43041. private static _idCounter;
  43042. private _tmpRay;
  43043. /**
  43044. * Creates a WebXRControllerPointerSelection
  43045. * @param input input manager to setup pointer selection
  43046. */
  43047. constructor(input: WebXRInput);
  43048. private _convertNormalToDirectionOfRay;
  43049. private _updatePointerDistance;
  43050. }
  43051. }
  43052. declare module "babylonjs/Loading/sceneLoader" {
  43053. import { Observable } from "babylonjs/Misc/observable";
  43054. import { Nullable } from "babylonjs/types";
  43055. import { Scene } from "babylonjs/scene";
  43056. import { Engine } from "babylonjs/Engines/engine";
  43057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43058. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43059. import { AssetContainer } from "babylonjs/assetContainer";
  43060. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43061. import { Skeleton } from "babylonjs/Bones/skeleton";
  43062. /**
  43063. * Class used to represent data loading progression
  43064. */
  43065. export class SceneLoaderProgressEvent {
  43066. /** defines if data length to load can be evaluated */
  43067. readonly lengthComputable: boolean;
  43068. /** defines the loaded data length */
  43069. readonly loaded: number;
  43070. /** defines the data length to load */
  43071. readonly total: number;
  43072. /**
  43073. * Create a new progress event
  43074. * @param lengthComputable defines if data length to load can be evaluated
  43075. * @param loaded defines the loaded data length
  43076. * @param total defines the data length to load
  43077. */
  43078. constructor(
  43079. /** defines if data length to load can be evaluated */
  43080. lengthComputable: boolean,
  43081. /** defines the loaded data length */
  43082. loaded: number,
  43083. /** defines the data length to load */
  43084. total: number);
  43085. /**
  43086. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43087. * @param event defines the source event
  43088. * @returns a new SceneLoaderProgressEvent
  43089. */
  43090. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43091. }
  43092. /**
  43093. * Interface used by SceneLoader plugins to define supported file extensions
  43094. */
  43095. export interface ISceneLoaderPluginExtensions {
  43096. /**
  43097. * Defines the list of supported extensions
  43098. */
  43099. [extension: string]: {
  43100. isBinary: boolean;
  43101. };
  43102. }
  43103. /**
  43104. * Interface used by SceneLoader plugin factory
  43105. */
  43106. export interface ISceneLoaderPluginFactory {
  43107. /**
  43108. * Defines the name of the factory
  43109. */
  43110. name: string;
  43111. /**
  43112. * Function called to create a new plugin
  43113. * @return the new plugin
  43114. */
  43115. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43116. /**
  43117. * Boolean indicating if the plugin can direct load specific data
  43118. */
  43119. canDirectLoad?: (data: string) => boolean;
  43120. }
  43121. /**
  43122. * Interface used to define a SceneLoader plugin
  43123. */
  43124. export interface ISceneLoaderPlugin {
  43125. /**
  43126. * The friendly name of this plugin.
  43127. */
  43128. name: string;
  43129. /**
  43130. * The file extensions supported by this plugin.
  43131. */
  43132. extensions: string | ISceneLoaderPluginExtensions;
  43133. /**
  43134. * Import meshes into a scene.
  43135. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43136. * @param scene The scene to import into
  43137. * @param data The data to import
  43138. * @param rootUrl The root url for scene and resources
  43139. * @param meshes The meshes array to import into
  43140. * @param particleSystems The particle systems array to import into
  43141. * @param skeletons The skeletons array to import into
  43142. * @param onError The callback when import fails
  43143. * @returns True if successful or false otherwise
  43144. */
  43145. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43146. /**
  43147. * Load into a scene.
  43148. * @param scene The scene to load into
  43149. * @param data The data to import
  43150. * @param rootUrl The root url for scene and resources
  43151. * @param onError The callback when import fails
  43152. * @returns true if successful or false otherwise
  43153. */
  43154. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43155. /**
  43156. * The callback that returns true if the data can be directly loaded.
  43157. */
  43158. canDirectLoad?: (data: string) => boolean;
  43159. /**
  43160. * The callback that allows custom handling of the root url based on the response url.
  43161. */
  43162. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43163. /**
  43164. * Load into an asset container.
  43165. * @param scene The scene to load into
  43166. * @param data The data to import
  43167. * @param rootUrl The root url for scene and resources
  43168. * @param onError The callback when import fails
  43169. * @returns The loaded asset container
  43170. */
  43171. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43172. }
  43173. /**
  43174. * Interface used to define an async SceneLoader plugin
  43175. */
  43176. export interface ISceneLoaderPluginAsync {
  43177. /**
  43178. * The friendly name of this plugin.
  43179. */
  43180. name: string;
  43181. /**
  43182. * The file extensions supported by this plugin.
  43183. */
  43184. extensions: string | ISceneLoaderPluginExtensions;
  43185. /**
  43186. * Import meshes into a scene.
  43187. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43188. * @param scene The scene to import into
  43189. * @param data The data to import
  43190. * @param rootUrl The root url for scene and resources
  43191. * @param onProgress The callback when the load progresses
  43192. * @param fileName Defines the name of the file to load
  43193. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43194. */
  43195. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43196. meshes: AbstractMesh[];
  43197. particleSystems: IParticleSystem[];
  43198. skeletons: Skeleton[];
  43199. animationGroups: AnimationGroup[];
  43200. }>;
  43201. /**
  43202. * Load into a scene.
  43203. * @param scene The scene to load into
  43204. * @param data The data to import
  43205. * @param rootUrl The root url for scene and resources
  43206. * @param onProgress The callback when the load progresses
  43207. * @param fileName Defines the name of the file to load
  43208. * @returns Nothing
  43209. */
  43210. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43211. /**
  43212. * The callback that returns true if the data can be directly loaded.
  43213. */
  43214. canDirectLoad?: (data: string) => boolean;
  43215. /**
  43216. * The callback that allows custom handling of the root url based on the response url.
  43217. */
  43218. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43219. /**
  43220. * Load into an asset container.
  43221. * @param scene The scene to load into
  43222. * @param data The data to import
  43223. * @param rootUrl The root url for scene and resources
  43224. * @param onProgress The callback when the load progresses
  43225. * @param fileName Defines the name of the file to load
  43226. * @returns The loaded asset container
  43227. */
  43228. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43229. }
  43230. /**
  43231. * Class used to load scene from various file formats using registered plugins
  43232. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43233. */
  43234. export class SceneLoader {
  43235. /**
  43236. * No logging while loading
  43237. */
  43238. static readonly NO_LOGGING: number;
  43239. /**
  43240. * Minimal logging while loading
  43241. */
  43242. static readonly MINIMAL_LOGGING: number;
  43243. /**
  43244. * Summary logging while loading
  43245. */
  43246. static readonly SUMMARY_LOGGING: number;
  43247. /**
  43248. * Detailled logging while loading
  43249. */
  43250. static readonly DETAILED_LOGGING: number;
  43251. /**
  43252. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43253. */
  43254. static ForceFullSceneLoadingForIncremental: boolean;
  43255. /**
  43256. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43257. */
  43258. static ShowLoadingScreen: boolean;
  43259. /**
  43260. * Defines the current logging level (while loading the scene)
  43261. * @ignorenaming
  43262. */
  43263. static loggingLevel: number;
  43264. /**
  43265. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43266. */
  43267. static CleanBoneMatrixWeights: boolean;
  43268. /**
  43269. * Event raised when a plugin is used to load a scene
  43270. */
  43271. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43272. private static _registeredPlugins;
  43273. private static _getDefaultPlugin;
  43274. private static _getPluginForExtension;
  43275. private static _getPluginForDirectLoad;
  43276. private static _getPluginForFilename;
  43277. private static _getDirectLoad;
  43278. private static _loadData;
  43279. private static _getFileInfo;
  43280. /**
  43281. * Gets a plugin that can load the given extension
  43282. * @param extension defines the extension to load
  43283. * @returns a plugin or null if none works
  43284. */
  43285. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43286. /**
  43287. * Gets a boolean indicating that the given extension can be loaded
  43288. * @param extension defines the extension to load
  43289. * @returns true if the extension is supported
  43290. */
  43291. static IsPluginForExtensionAvailable(extension: string): boolean;
  43292. /**
  43293. * Adds a new plugin to the list of registered plugins
  43294. * @param plugin defines the plugin to add
  43295. */
  43296. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43297. /**
  43298. * Import meshes into a scene
  43299. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43300. * @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)
  43301. * @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)
  43302. * @param scene the instance of BABYLON.Scene to append to
  43303. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43304. * @param onProgress a callback with a progress event for each file being loaded
  43305. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43306. * @param pluginExtension the extension used to determine the plugin
  43307. * @returns The loaded plugin
  43308. */
  43309. 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>;
  43310. /**
  43311. * Import meshes into a scene
  43312. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43313. * @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)
  43314. * @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)
  43315. * @param scene the instance of BABYLON.Scene to append to
  43316. * @param onProgress a callback with a progress event for each file being loaded
  43317. * @param pluginExtension the extension used to determine the plugin
  43318. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43319. */
  43320. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43321. meshes: AbstractMesh[];
  43322. particleSystems: IParticleSystem[];
  43323. skeletons: Skeleton[];
  43324. animationGroups: AnimationGroup[];
  43325. }>;
  43326. /**
  43327. * Load a scene
  43328. * @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)
  43329. * @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)
  43330. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43331. * @param onSuccess a callback with the scene when import succeeds
  43332. * @param onProgress a callback with a progress event for each file being loaded
  43333. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43334. * @param pluginExtension the extension used to determine the plugin
  43335. * @returns The loaded plugin
  43336. */
  43337. 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>;
  43338. /**
  43339. * Load a scene
  43340. * @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)
  43341. * @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)
  43342. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43343. * @param onProgress a callback with a progress event for each file being loaded
  43344. * @param pluginExtension the extension used to determine the plugin
  43345. * @returns The loaded scene
  43346. */
  43347. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43348. /**
  43349. * Append a scene
  43350. * @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)
  43351. * @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)
  43352. * @param scene is the instance of BABYLON.Scene to append to
  43353. * @param onSuccess a callback with the scene when import succeeds
  43354. * @param onProgress a callback with a progress event for each file being loaded
  43355. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43356. * @param pluginExtension the extension used to determine the plugin
  43357. * @returns The loaded plugin
  43358. */
  43359. 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>;
  43360. /**
  43361. * Append a scene
  43362. * @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)
  43363. * @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)
  43364. * @param scene is the instance of BABYLON.Scene to append to
  43365. * @param onProgress a callback with a progress event for each file being loaded
  43366. * @param pluginExtension the extension used to determine the plugin
  43367. * @returns The given scene
  43368. */
  43369. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43370. /**
  43371. * Load a scene into an asset container
  43372. * @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)
  43373. * @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)
  43374. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43375. * @param onSuccess a callback with the scene when import succeeds
  43376. * @param onProgress a callback with a progress event for each file being loaded
  43377. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43378. * @param pluginExtension the extension used to determine the plugin
  43379. * @returns The loaded plugin
  43380. */
  43381. 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>;
  43382. /**
  43383. * Load a scene into an asset container
  43384. * @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)
  43385. * @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)
  43386. * @param scene is the instance of Scene to append to
  43387. * @param onProgress a callback with a progress event for each file being loaded
  43388. * @param pluginExtension the extension used to determine the plugin
  43389. * @returns The loaded asset container
  43390. */
  43391. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43392. }
  43393. }
  43394. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43395. import { Scene } from "babylonjs/scene";
  43396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43397. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43398. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43399. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43400. /**
  43401. * Generic Controller
  43402. */
  43403. export class GenericController extends WebVRController {
  43404. /**
  43405. * Base Url for the controller model.
  43406. */
  43407. static readonly MODEL_BASE_URL: string;
  43408. /**
  43409. * File name for the controller model.
  43410. */
  43411. static readonly MODEL_FILENAME: string;
  43412. /**
  43413. * Creates a new GenericController from a gamepad
  43414. * @param vrGamepad the gamepad that the controller should be created from
  43415. */
  43416. constructor(vrGamepad: any);
  43417. /**
  43418. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43419. * @param scene scene in which to add meshes
  43420. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43421. */
  43422. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43423. /**
  43424. * Called once for each button that changed state since the last frame
  43425. * @param buttonIdx Which button index changed
  43426. * @param state New state of the button
  43427. * @param changes Which properties on the state changed since last frame
  43428. */
  43429. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43430. }
  43431. }
  43432. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43433. import { Observable } from "babylonjs/Misc/observable";
  43434. import { Scene } from "babylonjs/scene";
  43435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43436. import { Ray } from "babylonjs/Culling/ray";
  43437. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43438. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43439. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43440. /**
  43441. * Defines the WindowsMotionController object that the state of the windows motion controller
  43442. */
  43443. export class WindowsMotionController extends WebVRController {
  43444. /**
  43445. * The base url used to load the left and right controller models
  43446. */
  43447. static MODEL_BASE_URL: string;
  43448. /**
  43449. * The name of the left controller model file
  43450. */
  43451. static MODEL_LEFT_FILENAME: string;
  43452. /**
  43453. * The name of the right controller model file
  43454. */
  43455. static MODEL_RIGHT_FILENAME: string;
  43456. /**
  43457. * The controller name prefix for this controller type
  43458. */
  43459. static readonly GAMEPAD_ID_PREFIX: string;
  43460. /**
  43461. * The controller id pattern for this controller type
  43462. */
  43463. private static readonly GAMEPAD_ID_PATTERN;
  43464. private _loadedMeshInfo;
  43465. private readonly _mapping;
  43466. /**
  43467. * Fired when the trackpad on this controller is clicked
  43468. */
  43469. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43470. /**
  43471. * Fired when the trackpad on this controller is modified
  43472. */
  43473. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43474. /**
  43475. * The current x and y values of this controller's trackpad
  43476. */
  43477. trackpad: StickValues;
  43478. /**
  43479. * Creates a new WindowsMotionController from a gamepad
  43480. * @param vrGamepad the gamepad that the controller should be created from
  43481. */
  43482. constructor(vrGamepad: any);
  43483. /**
  43484. * Fired when the trigger on this controller is modified
  43485. */
  43486. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43487. /**
  43488. * Fired when the menu button on this controller is modified
  43489. */
  43490. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43491. /**
  43492. * Fired when the grip button on this controller is modified
  43493. */
  43494. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43495. /**
  43496. * Fired when the thumbstick button on this controller is modified
  43497. */
  43498. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43499. /**
  43500. * Fired when the touchpad button on this controller is modified
  43501. */
  43502. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43503. /**
  43504. * Fired when the touchpad values on this controller are modified
  43505. */
  43506. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43507. private _updateTrackpad;
  43508. /**
  43509. * Called once per frame by the engine.
  43510. */
  43511. update(): void;
  43512. /**
  43513. * Called once for each button that changed state since the last frame
  43514. * @param buttonIdx Which button index changed
  43515. * @param state New state of the button
  43516. * @param changes Which properties on the state changed since last frame
  43517. */
  43518. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43519. /**
  43520. * Moves the buttons on the controller mesh based on their current state
  43521. * @param buttonName the name of the button to move
  43522. * @param buttonValue the value of the button which determines the buttons new position
  43523. */
  43524. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43525. /**
  43526. * Moves the axis on the controller mesh based on its current state
  43527. * @param axis the index of the axis
  43528. * @param axisValue the value of the axis which determines the meshes new position
  43529. * @hidden
  43530. */
  43531. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43532. /**
  43533. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43534. * @param scene scene in which to add meshes
  43535. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43536. */
  43537. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43538. /**
  43539. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43540. * can be transformed by button presses and axes values, based on this._mapping.
  43541. *
  43542. * @param scene scene in which the meshes exist
  43543. * @param meshes list of meshes that make up the controller model to process
  43544. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43545. */
  43546. private processModel;
  43547. private createMeshInfo;
  43548. /**
  43549. * Gets the ray of the controller in the direction the controller is pointing
  43550. * @param length the length the resulting ray should be
  43551. * @returns a ray in the direction the controller is pointing
  43552. */
  43553. getForwardRay(length?: number): Ray;
  43554. /**
  43555. * Disposes of the controller
  43556. */
  43557. dispose(): void;
  43558. }
  43559. }
  43560. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43561. import { Observable } from "babylonjs/Misc/observable";
  43562. import { Scene } from "babylonjs/scene";
  43563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43564. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43565. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43566. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43567. /**
  43568. * Oculus Touch Controller
  43569. */
  43570. export class OculusTouchController extends WebVRController {
  43571. /**
  43572. * Base Url for the controller model.
  43573. */
  43574. static MODEL_BASE_URL: string;
  43575. /**
  43576. * File name for the left controller model.
  43577. */
  43578. static MODEL_LEFT_FILENAME: string;
  43579. /**
  43580. * File name for the right controller model.
  43581. */
  43582. static MODEL_RIGHT_FILENAME: string;
  43583. /**
  43584. * Base Url for the Quest controller model.
  43585. */
  43586. static QUEST_MODEL_BASE_URL: string;
  43587. /**
  43588. * @hidden
  43589. * If the controllers are running on a device that needs the updated Quest controller models
  43590. */
  43591. static _IsQuest: boolean;
  43592. /**
  43593. * Fired when the secondary trigger on this controller is modified
  43594. */
  43595. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43596. /**
  43597. * Fired when the thumb rest on this controller is modified
  43598. */
  43599. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43600. /**
  43601. * Creates a new OculusTouchController from a gamepad
  43602. * @param vrGamepad the gamepad that the controller should be created from
  43603. */
  43604. constructor(vrGamepad: any);
  43605. /**
  43606. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43607. * @param scene scene in which to add meshes
  43608. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43609. */
  43610. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43611. /**
  43612. * Fired when the A button on this controller is modified
  43613. */
  43614. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43615. /**
  43616. * Fired when the B button on this controller is modified
  43617. */
  43618. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43619. /**
  43620. * Fired when the X button on this controller is modified
  43621. */
  43622. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43623. /**
  43624. * Fired when the Y button on this controller is modified
  43625. */
  43626. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43627. /**
  43628. * Called once for each button that changed state since the last frame
  43629. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43630. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43631. * 2) secondary trigger (same)
  43632. * 3) A (right) X (left), touch, pressed = value
  43633. * 4) B / Y
  43634. * 5) thumb rest
  43635. * @param buttonIdx Which button index changed
  43636. * @param state New state of the button
  43637. * @param changes Which properties on the state changed since last frame
  43638. */
  43639. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43640. }
  43641. }
  43642. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43643. import { Scene } from "babylonjs/scene";
  43644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43645. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43646. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43647. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43648. import { Observable } from "babylonjs/Misc/observable";
  43649. /**
  43650. * Vive Controller
  43651. */
  43652. export class ViveController extends WebVRController {
  43653. /**
  43654. * Base Url for the controller model.
  43655. */
  43656. static MODEL_BASE_URL: string;
  43657. /**
  43658. * File name for the controller model.
  43659. */
  43660. static MODEL_FILENAME: string;
  43661. /**
  43662. * Creates a new ViveController from a gamepad
  43663. * @param vrGamepad the gamepad that the controller should be created from
  43664. */
  43665. constructor(vrGamepad: any);
  43666. /**
  43667. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43668. * @param scene scene in which to add meshes
  43669. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43670. */
  43671. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43672. /**
  43673. * Fired when the left button on this controller is modified
  43674. */
  43675. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43676. /**
  43677. * Fired when the right button on this controller is modified
  43678. */
  43679. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43680. /**
  43681. * Fired when the menu button on this controller is modified
  43682. */
  43683. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43684. /**
  43685. * Called once for each button that changed state since the last frame
  43686. * Vive mapping:
  43687. * 0: touchpad
  43688. * 1: trigger
  43689. * 2: left AND right buttons
  43690. * 3: menu button
  43691. * @param buttonIdx Which button index changed
  43692. * @param state New state of the button
  43693. * @param changes Which properties on the state changed since last frame
  43694. */
  43695. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43696. }
  43697. }
  43698. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43699. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43700. /**
  43701. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43702. */
  43703. export class WebXRControllerModelLoader {
  43704. /**
  43705. * Creates the WebXRControllerModelLoader
  43706. * @param input xr input that creates the controllers
  43707. */
  43708. constructor(input: WebXRInput);
  43709. }
  43710. }
  43711. declare module "babylonjs/Cameras/XR/index" {
  43712. export * from "babylonjs/Cameras/XR/webXRCamera";
  43713. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43714. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43715. export * from "babylonjs/Cameras/XR/webXRInput";
  43716. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43717. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43718. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43719. export * from "babylonjs/Cameras/XR/webXRController";
  43720. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43721. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43722. }
  43723. declare module "babylonjs/Cameras/RigModes/index" {
  43724. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43725. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43726. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43727. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43728. }
  43729. declare module "babylonjs/Cameras/index" {
  43730. export * from "babylonjs/Cameras/Inputs/index";
  43731. export * from "babylonjs/Cameras/cameraInputsManager";
  43732. export * from "babylonjs/Cameras/camera";
  43733. export * from "babylonjs/Cameras/targetCamera";
  43734. export * from "babylonjs/Cameras/freeCamera";
  43735. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43736. export * from "babylonjs/Cameras/touchCamera";
  43737. export * from "babylonjs/Cameras/arcRotateCamera";
  43738. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43739. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43740. export * from "babylonjs/Cameras/flyCamera";
  43741. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43742. export * from "babylonjs/Cameras/followCamera";
  43743. export * from "babylonjs/Cameras/followCameraInputsManager";
  43744. export * from "babylonjs/Cameras/gamepadCamera";
  43745. export * from "babylonjs/Cameras/Stereoscopic/index";
  43746. export * from "babylonjs/Cameras/universalCamera";
  43747. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43748. export * from "babylonjs/Cameras/VR/index";
  43749. export * from "babylonjs/Cameras/XR/index";
  43750. export * from "babylonjs/Cameras/RigModes/index";
  43751. }
  43752. declare module "babylonjs/Collisions/index" {
  43753. export * from "babylonjs/Collisions/collider";
  43754. export * from "babylonjs/Collisions/collisionCoordinator";
  43755. export * from "babylonjs/Collisions/pickingInfo";
  43756. export * from "babylonjs/Collisions/intersectionInfo";
  43757. export * from "babylonjs/Collisions/meshCollisionData";
  43758. }
  43759. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43760. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43761. import { Vector3 } from "babylonjs/Maths/math.vector";
  43762. import { Ray } from "babylonjs/Culling/ray";
  43763. import { Plane } from "babylonjs/Maths/math.plane";
  43764. /**
  43765. * Contains an array of blocks representing the octree
  43766. */
  43767. export interface IOctreeContainer<T> {
  43768. /**
  43769. * Blocks within the octree
  43770. */
  43771. blocks: Array<OctreeBlock<T>>;
  43772. }
  43773. /**
  43774. * Class used to store a cell in an octree
  43775. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43776. */
  43777. export class OctreeBlock<T> {
  43778. /**
  43779. * Gets the content of the current block
  43780. */
  43781. entries: T[];
  43782. /**
  43783. * Gets the list of block children
  43784. */
  43785. blocks: Array<OctreeBlock<T>>;
  43786. private _depth;
  43787. private _maxDepth;
  43788. private _capacity;
  43789. private _minPoint;
  43790. private _maxPoint;
  43791. private _boundingVectors;
  43792. private _creationFunc;
  43793. /**
  43794. * Creates a new block
  43795. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43796. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43797. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43798. * @param depth defines the current depth of this block in the octree
  43799. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43800. * @param creationFunc defines a callback to call when an element is added to the block
  43801. */
  43802. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43803. /**
  43804. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43805. */
  43806. readonly capacity: number;
  43807. /**
  43808. * Gets the minimum vector (in world space) of the block's bounding box
  43809. */
  43810. readonly minPoint: Vector3;
  43811. /**
  43812. * Gets the maximum vector (in world space) of the block's bounding box
  43813. */
  43814. readonly maxPoint: Vector3;
  43815. /**
  43816. * Add a new element to this block
  43817. * @param entry defines the element to add
  43818. */
  43819. addEntry(entry: T): void;
  43820. /**
  43821. * Remove an element from this block
  43822. * @param entry defines the element to remove
  43823. */
  43824. removeEntry(entry: T): void;
  43825. /**
  43826. * Add an array of elements to this block
  43827. * @param entries defines the array of elements to add
  43828. */
  43829. addEntries(entries: T[]): void;
  43830. /**
  43831. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43832. * @param frustumPlanes defines the frustum planes to test
  43833. * @param selection defines the array to store current content if selection is positive
  43834. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43835. */
  43836. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43837. /**
  43838. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43839. * @param sphereCenter defines the bounding sphere center
  43840. * @param sphereRadius defines the bounding sphere radius
  43841. * @param selection defines the array to store current content if selection is positive
  43842. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43843. */
  43844. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43845. /**
  43846. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43847. * @param ray defines the ray to test with
  43848. * @param selection defines the array to store current content if selection is positive
  43849. */
  43850. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43851. /**
  43852. * Subdivide the content into child blocks (this block will then be empty)
  43853. */
  43854. createInnerBlocks(): void;
  43855. /**
  43856. * @hidden
  43857. */
  43858. 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;
  43859. }
  43860. }
  43861. declare module "babylonjs/Culling/Octrees/octree" {
  43862. import { SmartArray } from "babylonjs/Misc/smartArray";
  43863. import { Vector3 } from "babylonjs/Maths/math.vector";
  43864. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43866. import { Ray } from "babylonjs/Culling/ray";
  43867. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43868. import { Plane } from "babylonjs/Maths/math.plane";
  43869. /**
  43870. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43871. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43872. */
  43873. export class Octree<T> {
  43874. /** 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.) */
  43875. maxDepth: number;
  43876. /**
  43877. * Blocks within the octree containing objects
  43878. */
  43879. blocks: Array<OctreeBlock<T>>;
  43880. /**
  43881. * Content stored in the octree
  43882. */
  43883. dynamicContent: T[];
  43884. private _maxBlockCapacity;
  43885. private _selectionContent;
  43886. private _creationFunc;
  43887. /**
  43888. * Creates a octree
  43889. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43890. * @param creationFunc function to be used to instatiate the octree
  43891. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43892. * @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.)
  43893. */
  43894. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43895. /** 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.) */
  43896. maxDepth?: number);
  43897. /**
  43898. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43899. * @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);
  43900. * @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);
  43901. * @param entries meshes to be added to the octree blocks
  43902. */
  43903. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43904. /**
  43905. * Adds a mesh to the octree
  43906. * @param entry Mesh to add to the octree
  43907. */
  43908. addMesh(entry: T): void;
  43909. /**
  43910. * Remove an element from the octree
  43911. * @param entry defines the element to remove
  43912. */
  43913. removeMesh(entry: T): void;
  43914. /**
  43915. * Selects an array of meshes within the frustum
  43916. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43917. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43918. * @returns array of meshes within the frustum
  43919. */
  43920. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43921. /**
  43922. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43923. * @param sphereCenter defines the bounding sphere center
  43924. * @param sphereRadius defines the bounding sphere radius
  43925. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43926. * @returns an array of objects that intersect the sphere
  43927. */
  43928. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43929. /**
  43930. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43931. * @param ray defines the ray to test with
  43932. * @returns array of intersected objects
  43933. */
  43934. intersectsRay(ray: Ray): SmartArray<T>;
  43935. /**
  43936. * Adds a mesh into the octree block if it intersects the block
  43937. */
  43938. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43939. /**
  43940. * Adds a submesh into the octree block if it intersects the block
  43941. */
  43942. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43943. }
  43944. }
  43945. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43946. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43947. import { Scene } from "babylonjs/scene";
  43948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43950. import { Ray } from "babylonjs/Culling/ray";
  43951. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43952. import { Collider } from "babylonjs/Collisions/collider";
  43953. module "babylonjs/scene" {
  43954. interface Scene {
  43955. /**
  43956. * @hidden
  43957. * Backing Filed
  43958. */
  43959. _selectionOctree: Octree<AbstractMesh>;
  43960. /**
  43961. * Gets the octree used to boost mesh selection (picking)
  43962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43963. */
  43964. selectionOctree: Octree<AbstractMesh>;
  43965. /**
  43966. * Creates or updates the octree used to boost selection (picking)
  43967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43968. * @param maxCapacity defines the maximum capacity per leaf
  43969. * @param maxDepth defines the maximum depth of the octree
  43970. * @returns an octree of AbstractMesh
  43971. */
  43972. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43973. }
  43974. }
  43975. module "babylonjs/Meshes/abstractMesh" {
  43976. interface AbstractMesh {
  43977. /**
  43978. * @hidden
  43979. * Backing Field
  43980. */
  43981. _submeshesOctree: Octree<SubMesh>;
  43982. /**
  43983. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43984. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43985. * @param maxCapacity defines the maximum size of each block (64 by default)
  43986. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43987. * @returns the new octree
  43988. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43989. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43990. */
  43991. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43992. }
  43993. }
  43994. /**
  43995. * Defines the octree scene component responsible to manage any octrees
  43996. * in a given scene.
  43997. */
  43998. export class OctreeSceneComponent {
  43999. /**
  44000. * The component name help to identify the component in the list of scene components.
  44001. */
  44002. readonly name: string;
  44003. /**
  44004. * The scene the component belongs to.
  44005. */
  44006. scene: Scene;
  44007. /**
  44008. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44009. */
  44010. readonly checksIsEnabled: boolean;
  44011. /**
  44012. * Creates a new instance of the component for the given scene
  44013. * @param scene Defines the scene to register the component in
  44014. */
  44015. constructor(scene: Scene);
  44016. /**
  44017. * Registers the component in a given scene
  44018. */
  44019. register(): void;
  44020. /**
  44021. * Return the list of active meshes
  44022. * @returns the list of active meshes
  44023. */
  44024. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44025. /**
  44026. * Return the list of active sub meshes
  44027. * @param mesh The mesh to get the candidates sub meshes from
  44028. * @returns the list of active sub meshes
  44029. */
  44030. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44031. private _tempRay;
  44032. /**
  44033. * Return the list of sub meshes intersecting with a given local ray
  44034. * @param mesh defines the mesh to find the submesh for
  44035. * @param localRay defines the ray in local space
  44036. * @returns the list of intersecting sub meshes
  44037. */
  44038. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44039. /**
  44040. * Return the list of sub meshes colliding with a collider
  44041. * @param mesh defines the mesh to find the submesh for
  44042. * @param collider defines the collider to evaluate the collision against
  44043. * @returns the list of colliding sub meshes
  44044. */
  44045. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44046. /**
  44047. * Rebuilds the elements related to this component in case of
  44048. * context lost for instance.
  44049. */
  44050. rebuild(): void;
  44051. /**
  44052. * Disposes the component and the associated ressources.
  44053. */
  44054. dispose(): void;
  44055. }
  44056. }
  44057. declare module "babylonjs/Culling/Octrees/index" {
  44058. export * from "babylonjs/Culling/Octrees/octree";
  44059. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44060. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44061. }
  44062. declare module "babylonjs/Culling/index" {
  44063. export * from "babylonjs/Culling/boundingBox";
  44064. export * from "babylonjs/Culling/boundingInfo";
  44065. export * from "babylonjs/Culling/boundingSphere";
  44066. export * from "babylonjs/Culling/Octrees/index";
  44067. export * from "babylonjs/Culling/ray";
  44068. }
  44069. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44070. import { IDisposable, Scene } from "babylonjs/scene";
  44071. import { Nullable } from "babylonjs/types";
  44072. import { Observable } from "babylonjs/Misc/observable";
  44073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44074. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44075. import { Camera } from "babylonjs/Cameras/camera";
  44076. /**
  44077. * Renders a layer on top of an existing scene
  44078. */
  44079. export class UtilityLayerRenderer implements IDisposable {
  44080. /** the original scene that will be rendered on top of */
  44081. originalScene: Scene;
  44082. private _pointerCaptures;
  44083. private _lastPointerEvents;
  44084. private static _DefaultUtilityLayer;
  44085. private static _DefaultKeepDepthUtilityLayer;
  44086. private _sharedGizmoLight;
  44087. private _renderCamera;
  44088. /**
  44089. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44090. * @returns the camera that is used when rendering the utility layer
  44091. */
  44092. getRenderCamera(): Nullable<Camera>;
  44093. /**
  44094. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44095. * @param cam the camera that should be used when rendering the utility layer
  44096. */
  44097. setRenderCamera(cam: Nullable<Camera>): void;
  44098. /**
  44099. * @hidden
  44100. * Light which used by gizmos to get light shading
  44101. */
  44102. _getSharedGizmoLight(): HemisphericLight;
  44103. /**
  44104. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44105. */
  44106. pickUtilitySceneFirst: boolean;
  44107. /**
  44108. * 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)
  44109. */
  44110. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44111. /**
  44112. * 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)
  44113. */
  44114. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44115. /**
  44116. * The scene that is rendered on top of the original scene
  44117. */
  44118. utilityLayerScene: Scene;
  44119. /**
  44120. * If the utility layer should automatically be rendered on top of existing scene
  44121. */
  44122. shouldRender: boolean;
  44123. /**
  44124. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44125. */
  44126. onlyCheckPointerDownEvents: boolean;
  44127. /**
  44128. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44129. */
  44130. processAllEvents: boolean;
  44131. /**
  44132. * Observable raised when the pointer move from the utility layer scene to the main scene
  44133. */
  44134. onPointerOutObservable: Observable<number>;
  44135. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44136. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44137. private _afterRenderObserver;
  44138. private _sceneDisposeObserver;
  44139. private _originalPointerObserver;
  44140. /**
  44141. * Instantiates a UtilityLayerRenderer
  44142. * @param originalScene the original scene that will be rendered on top of
  44143. * @param handleEvents boolean indicating if the utility layer should handle events
  44144. */
  44145. constructor(
  44146. /** the original scene that will be rendered on top of */
  44147. originalScene: Scene, handleEvents?: boolean);
  44148. private _notifyObservers;
  44149. /**
  44150. * Renders the utility layers scene on top of the original scene
  44151. */
  44152. render(): void;
  44153. /**
  44154. * Disposes of the renderer
  44155. */
  44156. dispose(): void;
  44157. private _updateCamera;
  44158. }
  44159. }
  44160. declare module "babylonjs/Gizmos/gizmo" {
  44161. import { Nullable } from "babylonjs/types";
  44162. import { IDisposable } from "babylonjs/scene";
  44163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44164. import { Mesh } from "babylonjs/Meshes/mesh";
  44165. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44166. /**
  44167. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44168. */
  44169. export class Gizmo implements IDisposable {
  44170. /** The utility layer the gizmo will be added to */
  44171. gizmoLayer: UtilityLayerRenderer;
  44172. /**
  44173. * The root mesh of the gizmo
  44174. */
  44175. _rootMesh: Mesh;
  44176. private _attachedMesh;
  44177. /**
  44178. * Ratio for the scale of the gizmo (Default: 1)
  44179. */
  44180. scaleRatio: number;
  44181. /**
  44182. * If a custom mesh has been set (Default: false)
  44183. */
  44184. protected _customMeshSet: boolean;
  44185. /**
  44186. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44187. * * When set, interactions will be enabled
  44188. */
  44189. attachedMesh: Nullable<AbstractMesh>;
  44190. /**
  44191. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44192. * @param mesh The mesh to replace the default mesh of the gizmo
  44193. */
  44194. setCustomMesh(mesh: Mesh): void;
  44195. /**
  44196. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44197. */
  44198. updateGizmoRotationToMatchAttachedMesh: boolean;
  44199. /**
  44200. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44201. */
  44202. updateGizmoPositionToMatchAttachedMesh: boolean;
  44203. /**
  44204. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44205. */
  44206. updateScale: boolean;
  44207. protected _interactionsEnabled: boolean;
  44208. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44209. private _beforeRenderObserver;
  44210. private _tempVector;
  44211. /**
  44212. * Creates a gizmo
  44213. * @param gizmoLayer The utility layer the gizmo will be added to
  44214. */
  44215. constructor(
  44216. /** The utility layer the gizmo will be added to */
  44217. gizmoLayer?: UtilityLayerRenderer);
  44218. /**
  44219. * Updates the gizmo to match the attached mesh's position/rotation
  44220. */
  44221. protected _update(): void;
  44222. /**
  44223. * Disposes of the gizmo
  44224. */
  44225. dispose(): void;
  44226. }
  44227. }
  44228. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44229. import { Observable } from "babylonjs/Misc/observable";
  44230. import { Nullable } from "babylonjs/types";
  44231. import { Vector3 } from "babylonjs/Maths/math.vector";
  44232. import { Color3 } from "babylonjs/Maths/math.color";
  44233. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44235. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44236. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44237. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44238. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44239. import { Scene } from "babylonjs/scene";
  44240. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44241. /**
  44242. * Single plane drag gizmo
  44243. */
  44244. export class PlaneDragGizmo extends Gizmo {
  44245. /**
  44246. * Drag behavior responsible for the gizmos dragging interactions
  44247. */
  44248. dragBehavior: PointerDragBehavior;
  44249. private _pointerObserver;
  44250. /**
  44251. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44252. */
  44253. snapDistance: number;
  44254. /**
  44255. * Event that fires each time the gizmo snaps to a new location.
  44256. * * snapDistance is the the change in distance
  44257. */
  44258. onSnapObservable: Observable<{
  44259. snapDistance: number;
  44260. }>;
  44261. private _plane;
  44262. private _coloredMaterial;
  44263. private _hoverMaterial;
  44264. private _isEnabled;
  44265. private _parent;
  44266. /** @hidden */
  44267. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44268. /** @hidden */
  44269. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44270. /**
  44271. * Creates a PlaneDragGizmo
  44272. * @param gizmoLayer The utility layer the gizmo will be added to
  44273. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44274. * @param color The color of the gizmo
  44275. */
  44276. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44277. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44278. /**
  44279. * If the gizmo is enabled
  44280. */
  44281. isEnabled: boolean;
  44282. /**
  44283. * Disposes of the gizmo
  44284. */
  44285. dispose(): void;
  44286. }
  44287. }
  44288. declare module "babylonjs/Gizmos/positionGizmo" {
  44289. import { Observable } from "babylonjs/Misc/observable";
  44290. import { Nullable } from "babylonjs/types";
  44291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44292. import { Mesh } from "babylonjs/Meshes/mesh";
  44293. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44294. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44295. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44296. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44297. /**
  44298. * Gizmo that enables dragging a mesh along 3 axis
  44299. */
  44300. export class PositionGizmo extends Gizmo {
  44301. /**
  44302. * Internal gizmo used for interactions on the x axis
  44303. */
  44304. xGizmo: AxisDragGizmo;
  44305. /**
  44306. * Internal gizmo used for interactions on the y axis
  44307. */
  44308. yGizmo: AxisDragGizmo;
  44309. /**
  44310. * Internal gizmo used for interactions on the z axis
  44311. */
  44312. zGizmo: AxisDragGizmo;
  44313. /**
  44314. * Internal gizmo used for interactions on the yz plane
  44315. */
  44316. xPlaneGizmo: PlaneDragGizmo;
  44317. /**
  44318. * Internal gizmo used for interactions on the xz plane
  44319. */
  44320. yPlaneGizmo: PlaneDragGizmo;
  44321. /**
  44322. * Internal gizmo used for interactions on the xy plane
  44323. */
  44324. zPlaneGizmo: PlaneDragGizmo;
  44325. /**
  44326. * private variables
  44327. */
  44328. private _meshAttached;
  44329. private _updateGizmoRotationToMatchAttachedMesh;
  44330. private _snapDistance;
  44331. private _scaleRatio;
  44332. /** Fires an event when any of it's sub gizmos are dragged */
  44333. onDragStartObservable: Observable<unknown>;
  44334. /** Fires an event when any of it's sub gizmos are released from dragging */
  44335. onDragEndObservable: Observable<unknown>;
  44336. /**
  44337. * If set to true, planar drag is enabled
  44338. */
  44339. private _planarGizmoEnabled;
  44340. attachedMesh: Nullable<AbstractMesh>;
  44341. /**
  44342. * Creates a PositionGizmo
  44343. * @param gizmoLayer The utility layer the gizmo will be added to
  44344. */
  44345. constructor(gizmoLayer?: UtilityLayerRenderer);
  44346. /**
  44347. * If the planar drag gizmo is enabled
  44348. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44349. */
  44350. planarGizmoEnabled: boolean;
  44351. updateGizmoRotationToMatchAttachedMesh: boolean;
  44352. /**
  44353. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44354. */
  44355. snapDistance: number;
  44356. /**
  44357. * Ratio for the scale of the gizmo (Default: 1)
  44358. */
  44359. scaleRatio: number;
  44360. /**
  44361. * Disposes of the gizmo
  44362. */
  44363. dispose(): void;
  44364. /**
  44365. * CustomMeshes are not supported by this gizmo
  44366. * @param mesh The mesh to replace the default mesh of the gizmo
  44367. */
  44368. setCustomMesh(mesh: Mesh): void;
  44369. }
  44370. }
  44371. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44372. import { Observable } from "babylonjs/Misc/observable";
  44373. import { Nullable } from "babylonjs/types";
  44374. import { Vector3 } from "babylonjs/Maths/math.vector";
  44375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44377. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44378. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44379. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44380. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44381. import { Scene } from "babylonjs/scene";
  44382. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44383. import { Color3 } from "babylonjs/Maths/math.color";
  44384. /**
  44385. * Single axis drag gizmo
  44386. */
  44387. export class AxisDragGizmo extends Gizmo {
  44388. /**
  44389. * Drag behavior responsible for the gizmos dragging interactions
  44390. */
  44391. dragBehavior: PointerDragBehavior;
  44392. private _pointerObserver;
  44393. /**
  44394. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44395. */
  44396. snapDistance: number;
  44397. /**
  44398. * Event that fires each time the gizmo snaps to a new location.
  44399. * * snapDistance is the the change in distance
  44400. */
  44401. onSnapObservable: Observable<{
  44402. snapDistance: number;
  44403. }>;
  44404. private _isEnabled;
  44405. private _parent;
  44406. private _arrow;
  44407. private _coloredMaterial;
  44408. private _hoverMaterial;
  44409. /** @hidden */
  44410. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44411. /** @hidden */
  44412. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44413. /**
  44414. * Creates an AxisDragGizmo
  44415. * @param gizmoLayer The utility layer the gizmo will be added to
  44416. * @param dragAxis The axis which the gizmo will be able to drag on
  44417. * @param color The color of the gizmo
  44418. */
  44419. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44420. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44421. /**
  44422. * If the gizmo is enabled
  44423. */
  44424. isEnabled: boolean;
  44425. /**
  44426. * Disposes of the gizmo
  44427. */
  44428. dispose(): void;
  44429. }
  44430. }
  44431. declare module "babylonjs/Debug/axesViewer" {
  44432. import { Vector3 } from "babylonjs/Maths/math.vector";
  44433. import { Nullable } from "babylonjs/types";
  44434. import { Scene } from "babylonjs/scene";
  44435. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44436. /**
  44437. * The Axes viewer will show 3 axes in a specific point in space
  44438. */
  44439. export class AxesViewer {
  44440. private _xAxis;
  44441. private _yAxis;
  44442. private _zAxis;
  44443. private _scaleLinesFactor;
  44444. private _instanced;
  44445. /**
  44446. * Gets the hosting scene
  44447. */
  44448. scene: Scene;
  44449. /**
  44450. * Gets or sets a number used to scale line length
  44451. */
  44452. scaleLines: number;
  44453. /** Gets the node hierarchy used to render x-axis */
  44454. readonly xAxis: TransformNode;
  44455. /** Gets the node hierarchy used to render y-axis */
  44456. readonly yAxis: TransformNode;
  44457. /** Gets the node hierarchy used to render z-axis */
  44458. readonly zAxis: TransformNode;
  44459. /**
  44460. * Creates a new AxesViewer
  44461. * @param scene defines the hosting scene
  44462. * @param scaleLines defines a number used to scale line length (1 by default)
  44463. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44464. * @param xAxis defines the node hierarchy used to render the x-axis
  44465. * @param yAxis defines the node hierarchy used to render the y-axis
  44466. * @param zAxis defines the node hierarchy used to render the z-axis
  44467. */
  44468. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44469. /**
  44470. * Force the viewer to update
  44471. * @param position defines the position of the viewer
  44472. * @param xaxis defines the x axis of the viewer
  44473. * @param yaxis defines the y axis of the viewer
  44474. * @param zaxis defines the z axis of the viewer
  44475. */
  44476. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44477. /**
  44478. * Creates an instance of this axes viewer.
  44479. * @returns a new axes viewer with instanced meshes
  44480. */
  44481. createInstance(): AxesViewer;
  44482. /** Releases resources */
  44483. dispose(): void;
  44484. private static _SetRenderingGroupId;
  44485. }
  44486. }
  44487. declare module "babylonjs/Debug/boneAxesViewer" {
  44488. import { Nullable } from "babylonjs/types";
  44489. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44490. import { Vector3 } from "babylonjs/Maths/math.vector";
  44491. import { Mesh } from "babylonjs/Meshes/mesh";
  44492. import { Bone } from "babylonjs/Bones/bone";
  44493. import { Scene } from "babylonjs/scene";
  44494. /**
  44495. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44496. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44497. */
  44498. export class BoneAxesViewer extends AxesViewer {
  44499. /**
  44500. * Gets or sets the target mesh where to display the axes viewer
  44501. */
  44502. mesh: Nullable<Mesh>;
  44503. /**
  44504. * Gets or sets the target bone where to display the axes viewer
  44505. */
  44506. bone: Nullable<Bone>;
  44507. /** Gets current position */
  44508. pos: Vector3;
  44509. /** Gets direction of X axis */
  44510. xaxis: Vector3;
  44511. /** Gets direction of Y axis */
  44512. yaxis: Vector3;
  44513. /** Gets direction of Z axis */
  44514. zaxis: Vector3;
  44515. /**
  44516. * Creates a new BoneAxesViewer
  44517. * @param scene defines the hosting scene
  44518. * @param bone defines the target bone
  44519. * @param mesh defines the target mesh
  44520. * @param scaleLines defines a scaling factor for line length (1 by default)
  44521. */
  44522. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44523. /**
  44524. * Force the viewer to update
  44525. */
  44526. update(): void;
  44527. /** Releases resources */
  44528. dispose(): void;
  44529. }
  44530. }
  44531. declare module "babylonjs/Debug/debugLayer" {
  44532. import { Scene } from "babylonjs/scene";
  44533. /**
  44534. * Interface used to define scene explorer extensibility option
  44535. */
  44536. export interface IExplorerExtensibilityOption {
  44537. /**
  44538. * Define the option label
  44539. */
  44540. label: string;
  44541. /**
  44542. * Defines the action to execute on click
  44543. */
  44544. action: (entity: any) => void;
  44545. }
  44546. /**
  44547. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44548. */
  44549. export interface IExplorerExtensibilityGroup {
  44550. /**
  44551. * Defines a predicate to test if a given type mut be extended
  44552. */
  44553. predicate: (entity: any) => boolean;
  44554. /**
  44555. * Gets the list of options added to a type
  44556. */
  44557. entries: IExplorerExtensibilityOption[];
  44558. }
  44559. /**
  44560. * Interface used to define the options to use to create the Inspector
  44561. */
  44562. export interface IInspectorOptions {
  44563. /**
  44564. * Display in overlay mode (default: false)
  44565. */
  44566. overlay?: boolean;
  44567. /**
  44568. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44569. */
  44570. globalRoot?: HTMLElement;
  44571. /**
  44572. * Display the Scene explorer
  44573. */
  44574. showExplorer?: boolean;
  44575. /**
  44576. * Display the property inspector
  44577. */
  44578. showInspector?: boolean;
  44579. /**
  44580. * Display in embed mode (both panes on the right)
  44581. */
  44582. embedMode?: boolean;
  44583. /**
  44584. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44585. */
  44586. handleResize?: boolean;
  44587. /**
  44588. * Allow the panes to popup (default: true)
  44589. */
  44590. enablePopup?: boolean;
  44591. /**
  44592. * Allow the panes to be closed by users (default: true)
  44593. */
  44594. enableClose?: boolean;
  44595. /**
  44596. * Optional list of extensibility entries
  44597. */
  44598. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44599. /**
  44600. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44601. */
  44602. inspectorURL?: string;
  44603. }
  44604. module "babylonjs/scene" {
  44605. interface Scene {
  44606. /**
  44607. * @hidden
  44608. * Backing field
  44609. */
  44610. _debugLayer: DebugLayer;
  44611. /**
  44612. * Gets the debug layer (aka Inspector) associated with the scene
  44613. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44614. */
  44615. debugLayer: DebugLayer;
  44616. }
  44617. }
  44618. /**
  44619. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44620. * what is happening in your scene
  44621. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44622. */
  44623. export class DebugLayer {
  44624. /**
  44625. * Define the url to get the inspector script from.
  44626. * By default it uses the babylonjs CDN.
  44627. * @ignoreNaming
  44628. */
  44629. static InspectorURL: string;
  44630. private _scene;
  44631. private BJSINSPECTOR;
  44632. private _onPropertyChangedObservable?;
  44633. /**
  44634. * Observable triggered when a property is changed through the inspector.
  44635. */
  44636. readonly onPropertyChangedObservable: any;
  44637. /**
  44638. * Instantiates a new debug layer.
  44639. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44640. * what is happening in your scene
  44641. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44642. * @param scene Defines the scene to inspect
  44643. */
  44644. constructor(scene: Scene);
  44645. /** Creates the inspector window. */
  44646. private _createInspector;
  44647. /**
  44648. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44649. * @param entity defines the entity to select
  44650. * @param lineContainerTitle defines the specific block to highlight
  44651. */
  44652. select(entity: any, lineContainerTitle?: string): void;
  44653. /** Get the inspector from bundle or global */
  44654. private _getGlobalInspector;
  44655. /**
  44656. * Get if the inspector is visible or not.
  44657. * @returns true if visible otherwise, false
  44658. */
  44659. isVisible(): boolean;
  44660. /**
  44661. * Hide the inspector and close its window.
  44662. */
  44663. hide(): void;
  44664. /**
  44665. * Launch the debugLayer.
  44666. * @param config Define the configuration of the inspector
  44667. * @return a promise fulfilled when the debug layer is visible
  44668. */
  44669. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44670. }
  44671. }
  44672. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44673. import { Nullable } from "babylonjs/types";
  44674. import { Scene } from "babylonjs/scene";
  44675. import { Vector4 } from "babylonjs/Maths/math.vector";
  44676. import { Color4 } from "babylonjs/Maths/math.color";
  44677. import { Mesh } from "babylonjs/Meshes/mesh";
  44678. /**
  44679. * Class containing static functions to help procedurally build meshes
  44680. */
  44681. export class BoxBuilder {
  44682. /**
  44683. * Creates a box mesh
  44684. * * The parameter `size` sets the size (float) of each box side (default 1)
  44685. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44686. * * 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)
  44687. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44691. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44692. * @param name defines the name of the mesh
  44693. * @param options defines the options used to create the mesh
  44694. * @param scene defines the hosting scene
  44695. * @returns the box mesh
  44696. */
  44697. static CreateBox(name: string, options: {
  44698. size?: number;
  44699. width?: number;
  44700. height?: number;
  44701. depth?: number;
  44702. faceUV?: Vector4[];
  44703. faceColors?: Color4[];
  44704. sideOrientation?: number;
  44705. frontUVs?: Vector4;
  44706. backUVs?: Vector4;
  44707. wrap?: boolean;
  44708. topBaseAt?: number;
  44709. bottomBaseAt?: number;
  44710. updatable?: boolean;
  44711. }, scene?: Nullable<Scene>): Mesh;
  44712. }
  44713. }
  44714. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44715. import { Vector4 } from "babylonjs/Maths/math.vector";
  44716. import { Mesh } from "babylonjs/Meshes/mesh";
  44717. import { Scene } from "babylonjs/scene";
  44718. import { Nullable } from "babylonjs/types";
  44719. /**
  44720. * Class containing static functions to help procedurally build meshes
  44721. */
  44722. export class SphereBuilder {
  44723. /**
  44724. * Creates a sphere mesh
  44725. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44726. * * 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`)
  44727. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44728. * * 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
  44729. * * 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)
  44730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44733. * @param name defines the name of the mesh
  44734. * @param options defines the options used to create the mesh
  44735. * @param scene defines the hosting scene
  44736. * @returns the sphere mesh
  44737. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44738. */
  44739. static CreateSphere(name: string, options: {
  44740. segments?: number;
  44741. diameter?: number;
  44742. diameterX?: number;
  44743. diameterY?: number;
  44744. diameterZ?: number;
  44745. arc?: number;
  44746. slice?: number;
  44747. sideOrientation?: number;
  44748. frontUVs?: Vector4;
  44749. backUVs?: Vector4;
  44750. updatable?: boolean;
  44751. }, scene?: Nullable<Scene>): Mesh;
  44752. }
  44753. }
  44754. declare module "babylonjs/Debug/physicsViewer" {
  44755. import { Nullable } from "babylonjs/types";
  44756. import { Scene } from "babylonjs/scene";
  44757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44758. import { Mesh } from "babylonjs/Meshes/mesh";
  44759. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44760. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44761. /**
  44762. * Used to show the physics impostor around the specific mesh
  44763. */
  44764. export class PhysicsViewer {
  44765. /** @hidden */
  44766. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44767. /** @hidden */
  44768. protected _meshes: Array<Nullable<AbstractMesh>>;
  44769. /** @hidden */
  44770. protected _scene: Nullable<Scene>;
  44771. /** @hidden */
  44772. protected _numMeshes: number;
  44773. /** @hidden */
  44774. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44775. private _renderFunction;
  44776. private _utilityLayer;
  44777. private _debugBoxMesh;
  44778. private _debugSphereMesh;
  44779. private _debugCylinderMesh;
  44780. private _debugMaterial;
  44781. private _debugMeshMeshes;
  44782. /**
  44783. * Creates a new PhysicsViewer
  44784. * @param scene defines the hosting scene
  44785. */
  44786. constructor(scene: Scene);
  44787. /** @hidden */
  44788. protected _updateDebugMeshes(): void;
  44789. /**
  44790. * Renders a specified physic impostor
  44791. * @param impostor defines the impostor to render
  44792. * @param targetMesh defines the mesh represented by the impostor
  44793. * @returns the new debug mesh used to render the impostor
  44794. */
  44795. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44796. /**
  44797. * Hides a specified physic impostor
  44798. * @param impostor defines the impostor to hide
  44799. */
  44800. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44801. private _getDebugMaterial;
  44802. private _getDebugBoxMesh;
  44803. private _getDebugSphereMesh;
  44804. private _getDebugCylinderMesh;
  44805. private _getDebugMeshMesh;
  44806. private _getDebugMesh;
  44807. /** Releases all resources */
  44808. dispose(): void;
  44809. }
  44810. }
  44811. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44812. import { Vector3 } from "babylonjs/Maths/math.vector";
  44813. import { Color4 } from "babylonjs/Maths/math.color";
  44814. import { Nullable } from "babylonjs/types";
  44815. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44816. import { Scene } from "babylonjs/scene";
  44817. /**
  44818. * Class containing static functions to help procedurally build meshes
  44819. */
  44820. export class LinesBuilder {
  44821. /**
  44822. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44823. * * 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
  44824. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44825. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44826. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44827. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44828. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44829. * * 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
  44830. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44833. * @param name defines the name of the new line system
  44834. * @param options defines the options used to create the line system
  44835. * @param scene defines the hosting scene
  44836. * @returns a new line system mesh
  44837. */
  44838. static CreateLineSystem(name: string, options: {
  44839. lines: Vector3[][];
  44840. updatable?: boolean;
  44841. instance?: Nullable<LinesMesh>;
  44842. colors?: Nullable<Color4[][]>;
  44843. useVertexAlpha?: boolean;
  44844. }, scene: Nullable<Scene>): LinesMesh;
  44845. /**
  44846. * Creates a line mesh
  44847. * 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
  44848. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44849. * * The parameter `points` is an array successive Vector3
  44850. * * 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
  44851. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44852. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44853. * * When updating an instance, remember that only point positions can change, not the number of points
  44854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44856. * @param name defines the name of the new line system
  44857. * @param options defines the options used to create the line system
  44858. * @param scene defines the hosting scene
  44859. * @returns a new line mesh
  44860. */
  44861. static CreateLines(name: string, options: {
  44862. points: Vector3[];
  44863. updatable?: boolean;
  44864. instance?: Nullable<LinesMesh>;
  44865. colors?: Color4[];
  44866. useVertexAlpha?: boolean;
  44867. }, scene?: Nullable<Scene>): LinesMesh;
  44868. /**
  44869. * Creates a dashed line mesh
  44870. * * 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
  44871. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44872. * * The parameter `points` is an array successive Vector3
  44873. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44874. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44875. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44876. * * 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
  44877. * * When updating an instance, remember that only point positions can change, not the number of points
  44878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44879. * @param name defines the name of the mesh
  44880. * @param options defines the options used to create the mesh
  44881. * @param scene defines the hosting scene
  44882. * @returns the dashed line mesh
  44883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44884. */
  44885. static CreateDashedLines(name: string, options: {
  44886. points: Vector3[];
  44887. dashSize?: number;
  44888. gapSize?: number;
  44889. dashNb?: number;
  44890. updatable?: boolean;
  44891. instance?: LinesMesh;
  44892. }, scene?: Nullable<Scene>): LinesMesh;
  44893. }
  44894. }
  44895. declare module "babylonjs/Debug/rayHelper" {
  44896. import { Nullable } from "babylonjs/types";
  44897. import { Ray } from "babylonjs/Culling/ray";
  44898. import { Vector3 } from "babylonjs/Maths/math.vector";
  44899. import { Color3 } from "babylonjs/Maths/math.color";
  44900. import { Scene } from "babylonjs/scene";
  44901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44902. import "babylonjs/Meshes/Builders/linesBuilder";
  44903. /**
  44904. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44905. * in order to better appreciate the issue one might have.
  44906. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44907. */
  44908. export class RayHelper {
  44909. /**
  44910. * Defines the ray we are currently tryin to visualize.
  44911. */
  44912. ray: Nullable<Ray>;
  44913. private _renderPoints;
  44914. private _renderLine;
  44915. private _renderFunction;
  44916. private _scene;
  44917. private _updateToMeshFunction;
  44918. private _attachedToMesh;
  44919. private _meshSpaceDirection;
  44920. private _meshSpaceOrigin;
  44921. /**
  44922. * Helper function to create a colored helper in a scene in one line.
  44923. * @param ray Defines the ray we are currently tryin to visualize
  44924. * @param scene Defines the scene the ray is used in
  44925. * @param color Defines the color we want to see the ray in
  44926. * @returns The newly created ray helper.
  44927. */
  44928. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44929. /**
  44930. * Instantiate a new ray helper.
  44931. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44932. * in order to better appreciate the issue one might have.
  44933. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44934. * @param ray Defines the ray we are currently tryin to visualize
  44935. */
  44936. constructor(ray: Ray);
  44937. /**
  44938. * Shows the ray we are willing to debug.
  44939. * @param scene Defines the scene the ray needs to be rendered in
  44940. * @param color Defines the color the ray needs to be rendered in
  44941. */
  44942. show(scene: Scene, color?: Color3): void;
  44943. /**
  44944. * Hides the ray we are debugging.
  44945. */
  44946. hide(): void;
  44947. private _render;
  44948. /**
  44949. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44950. * @param mesh Defines the mesh we want the helper attached to
  44951. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44952. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44953. * @param length Defines the length of the ray
  44954. */
  44955. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44956. /**
  44957. * Detach the ray helper from the mesh it has previously been attached to.
  44958. */
  44959. detachFromMesh(): void;
  44960. private _updateToMesh;
  44961. /**
  44962. * Dispose the helper and release its associated resources.
  44963. */
  44964. dispose(): void;
  44965. }
  44966. }
  44967. declare module "babylonjs/Debug/skeletonViewer" {
  44968. import { Color3 } from "babylonjs/Maths/math.color";
  44969. import { Scene } from "babylonjs/scene";
  44970. import { Nullable } from "babylonjs/types";
  44971. import { Skeleton } from "babylonjs/Bones/skeleton";
  44972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44973. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44974. /**
  44975. * Class used to render a debug view of a given skeleton
  44976. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44977. */
  44978. export class SkeletonViewer {
  44979. /** defines the skeleton to render */
  44980. skeleton: Skeleton;
  44981. /** defines the mesh attached to the skeleton */
  44982. mesh: AbstractMesh;
  44983. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44984. autoUpdateBonesMatrices: boolean;
  44985. /** defines the rendering group id to use with the viewer */
  44986. renderingGroupId: number;
  44987. /** Gets or sets the color used to render the skeleton */
  44988. color: Color3;
  44989. private _scene;
  44990. private _debugLines;
  44991. private _debugMesh;
  44992. private _isEnabled;
  44993. private _renderFunction;
  44994. private _utilityLayer;
  44995. /**
  44996. * Returns the mesh used to render the bones
  44997. */
  44998. readonly debugMesh: Nullable<LinesMesh>;
  44999. /**
  45000. * Creates a new SkeletonViewer
  45001. * @param skeleton defines the skeleton to render
  45002. * @param mesh defines the mesh attached to the skeleton
  45003. * @param scene defines the hosting scene
  45004. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45005. * @param renderingGroupId defines the rendering group id to use with the viewer
  45006. */
  45007. constructor(
  45008. /** defines the skeleton to render */
  45009. skeleton: Skeleton,
  45010. /** defines the mesh attached to the skeleton */
  45011. mesh: AbstractMesh, scene: Scene,
  45012. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45013. autoUpdateBonesMatrices?: boolean,
  45014. /** defines the rendering group id to use with the viewer */
  45015. renderingGroupId?: number);
  45016. /** Gets or sets a boolean indicating if the viewer is enabled */
  45017. isEnabled: boolean;
  45018. private _getBonePosition;
  45019. private _getLinesForBonesWithLength;
  45020. private _getLinesForBonesNoLength;
  45021. /** Update the viewer to sync with current skeleton state */
  45022. update(): void;
  45023. /** Release associated resources */
  45024. dispose(): void;
  45025. }
  45026. }
  45027. declare module "babylonjs/Debug/index" {
  45028. export * from "babylonjs/Debug/axesViewer";
  45029. export * from "babylonjs/Debug/boneAxesViewer";
  45030. export * from "babylonjs/Debug/debugLayer";
  45031. export * from "babylonjs/Debug/physicsViewer";
  45032. export * from "babylonjs/Debug/rayHelper";
  45033. export * from "babylonjs/Debug/skeletonViewer";
  45034. }
  45035. declare module "babylonjs/Engines/nullEngine" {
  45036. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45037. import { Scene } from "babylonjs/scene";
  45038. import { Engine } from "babylonjs/Engines/engine";
  45039. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45040. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45041. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45042. import { Effect } from "babylonjs/Materials/effect";
  45043. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45044. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45045. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45046. /**
  45047. * Options to create the null engine
  45048. */
  45049. export class NullEngineOptions {
  45050. /**
  45051. * Render width (Default: 512)
  45052. */
  45053. renderWidth: number;
  45054. /**
  45055. * Render height (Default: 256)
  45056. */
  45057. renderHeight: number;
  45058. /**
  45059. * Texture size (Default: 512)
  45060. */
  45061. textureSize: number;
  45062. /**
  45063. * If delta time between frames should be constant
  45064. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45065. */
  45066. deterministicLockstep: boolean;
  45067. /**
  45068. * Maximum about of steps between frames (Default: 4)
  45069. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45070. */
  45071. lockstepMaxSteps: number;
  45072. }
  45073. /**
  45074. * The null engine class provides support for headless version of babylon.js.
  45075. * This can be used in server side scenario or for testing purposes
  45076. */
  45077. export class NullEngine extends Engine {
  45078. private _options;
  45079. /**
  45080. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45081. */
  45082. isDeterministicLockStep(): boolean;
  45083. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45084. getLockstepMaxSteps(): number;
  45085. /**
  45086. * Sets hardware scaling, used to save performance if needed
  45087. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45088. */
  45089. getHardwareScalingLevel(): number;
  45090. constructor(options?: NullEngineOptions);
  45091. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45092. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45093. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45094. getRenderWidth(useScreen?: boolean): number;
  45095. getRenderHeight(useScreen?: boolean): number;
  45096. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45097. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45098. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45099. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45100. bindSamplers(effect: Effect): void;
  45101. enableEffect(effect: Effect): void;
  45102. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45103. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45104. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45105. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45106. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45107. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45108. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45109. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45110. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45111. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45112. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45113. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45114. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45115. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45116. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45117. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45118. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45119. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45120. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45121. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45122. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45123. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45124. bindBuffers(vertexBuffers: {
  45125. [key: string]: VertexBuffer;
  45126. }, indexBuffer: DataBuffer, effect: Effect): void;
  45127. wipeCaches(bruteForce?: boolean): void;
  45128. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45129. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45130. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45131. /** @hidden */
  45132. _createTexture(): WebGLTexture;
  45133. /** @hidden */
  45134. _releaseTexture(texture: InternalTexture): void;
  45135. 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;
  45136. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45137. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45138. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45139. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45140. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45141. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45142. areAllEffectsReady(): boolean;
  45143. /**
  45144. * @hidden
  45145. * Get the current error code of the webGL context
  45146. * @returns the error code
  45147. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45148. */
  45149. getError(): number;
  45150. /** @hidden */
  45151. _getUnpackAlignement(): number;
  45152. /** @hidden */
  45153. _unpackFlipY(value: boolean): void;
  45154. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45155. /**
  45156. * Updates a dynamic vertex buffer.
  45157. * @param vertexBuffer the vertex buffer to update
  45158. * @param data the data used to update the vertex buffer
  45159. * @param byteOffset the byte offset of the data (optional)
  45160. * @param byteLength the byte length of the data (optional)
  45161. */
  45162. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45163. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45164. /** @hidden */
  45165. _bindTexture(channel: number, texture: InternalTexture): void;
  45166. /** @hidden */
  45167. _releaseBuffer(buffer: DataBuffer): boolean;
  45168. releaseEffects(): void;
  45169. displayLoadingUI(): void;
  45170. hideLoadingUI(): void;
  45171. /** @hidden */
  45172. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45173. /** @hidden */
  45174. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45175. /** @hidden */
  45176. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45177. /** @hidden */
  45178. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45179. }
  45180. }
  45181. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45182. import { Nullable, int } from "babylonjs/types";
  45183. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45184. /** @hidden */
  45185. export class _OcclusionDataStorage {
  45186. /** @hidden */
  45187. occlusionInternalRetryCounter: number;
  45188. /** @hidden */
  45189. isOcclusionQueryInProgress: boolean;
  45190. /** @hidden */
  45191. isOccluded: boolean;
  45192. /** @hidden */
  45193. occlusionRetryCount: number;
  45194. /** @hidden */
  45195. occlusionType: number;
  45196. /** @hidden */
  45197. occlusionQueryAlgorithmType: number;
  45198. }
  45199. module "babylonjs/Engines/engine" {
  45200. interface Engine {
  45201. /**
  45202. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45203. * @return the new query
  45204. */
  45205. createQuery(): WebGLQuery;
  45206. /**
  45207. * Delete and release a webGL query
  45208. * @param query defines the query to delete
  45209. * @return the current engine
  45210. */
  45211. deleteQuery(query: WebGLQuery): Engine;
  45212. /**
  45213. * Check if a given query has resolved and got its value
  45214. * @param query defines the query to check
  45215. * @returns true if the query got its value
  45216. */
  45217. isQueryResultAvailable(query: WebGLQuery): boolean;
  45218. /**
  45219. * Gets the value of a given query
  45220. * @param query defines the query to check
  45221. * @returns the value of the query
  45222. */
  45223. getQueryResult(query: WebGLQuery): number;
  45224. /**
  45225. * Initiates an occlusion query
  45226. * @param algorithmType defines the algorithm to use
  45227. * @param query defines the query to use
  45228. * @returns the current engine
  45229. * @see http://doc.babylonjs.com/features/occlusionquery
  45230. */
  45231. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45232. /**
  45233. * Ends an occlusion query
  45234. * @see http://doc.babylonjs.com/features/occlusionquery
  45235. * @param algorithmType defines the algorithm to use
  45236. * @returns the current engine
  45237. */
  45238. endOcclusionQuery(algorithmType: number): Engine;
  45239. /**
  45240. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45241. * Please note that only one query can be issued at a time
  45242. * @returns a time token used to track the time span
  45243. */
  45244. startTimeQuery(): Nullable<_TimeToken>;
  45245. /**
  45246. * Ends a time query
  45247. * @param token defines the token used to measure the time span
  45248. * @returns the time spent (in ns)
  45249. */
  45250. endTimeQuery(token: _TimeToken): int;
  45251. /** @hidden */
  45252. _currentNonTimestampToken: Nullable<_TimeToken>;
  45253. /** @hidden */
  45254. _createTimeQuery(): WebGLQuery;
  45255. /** @hidden */
  45256. _deleteTimeQuery(query: WebGLQuery): void;
  45257. /** @hidden */
  45258. _getGlAlgorithmType(algorithmType: number): number;
  45259. /** @hidden */
  45260. _getTimeQueryResult(query: WebGLQuery): any;
  45261. /** @hidden */
  45262. _getTimeQueryAvailability(query: WebGLQuery): any;
  45263. }
  45264. }
  45265. module "babylonjs/Meshes/abstractMesh" {
  45266. interface AbstractMesh {
  45267. /**
  45268. * Backing filed
  45269. * @hidden
  45270. */
  45271. __occlusionDataStorage: _OcclusionDataStorage;
  45272. /**
  45273. * Access property
  45274. * @hidden
  45275. */
  45276. _occlusionDataStorage: _OcclusionDataStorage;
  45277. /**
  45278. * 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.
  45279. * The default value is -1 which means don't break the query and wait till the result
  45280. * @see http://doc.babylonjs.com/features/occlusionquery
  45281. */
  45282. occlusionRetryCount: number;
  45283. /**
  45284. * 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:
  45285. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45286. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45287. * * 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.
  45288. * @see http://doc.babylonjs.com/features/occlusionquery
  45289. */
  45290. occlusionType: number;
  45291. /**
  45292. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45293. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45294. * * 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.
  45295. * @see http://doc.babylonjs.com/features/occlusionquery
  45296. */
  45297. occlusionQueryAlgorithmType: number;
  45298. /**
  45299. * 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
  45300. * @see http://doc.babylonjs.com/features/occlusionquery
  45301. */
  45302. isOccluded: boolean;
  45303. /**
  45304. * Flag to check the progress status of the query
  45305. * @see http://doc.babylonjs.com/features/occlusionquery
  45306. */
  45307. isOcclusionQueryInProgress: boolean;
  45308. }
  45309. }
  45310. }
  45311. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45312. import { Nullable } from "babylonjs/types";
  45313. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45314. /** @hidden */
  45315. export var _forceTransformFeedbackToBundle: boolean;
  45316. module "babylonjs/Engines/engine" {
  45317. interface Engine {
  45318. /**
  45319. * Creates a webGL transform feedback object
  45320. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45321. * @returns the webGL transform feedback object
  45322. */
  45323. createTransformFeedback(): WebGLTransformFeedback;
  45324. /**
  45325. * Delete a webGL transform feedback object
  45326. * @param value defines the webGL transform feedback object to delete
  45327. */
  45328. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45329. /**
  45330. * Bind a webGL transform feedback object to the webgl context
  45331. * @param value defines the webGL transform feedback object to bind
  45332. */
  45333. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45334. /**
  45335. * Begins a transform feedback operation
  45336. * @param usePoints defines if points or triangles must be used
  45337. */
  45338. beginTransformFeedback(usePoints: boolean): void;
  45339. /**
  45340. * Ends a transform feedback operation
  45341. */
  45342. endTransformFeedback(): void;
  45343. /**
  45344. * Specify the varyings to use with transform feedback
  45345. * @param program defines the associated webGL program
  45346. * @param value defines the list of strings representing the varying names
  45347. */
  45348. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45349. /**
  45350. * Bind a webGL buffer for a transform feedback operation
  45351. * @param value defines the webGL buffer to bind
  45352. */
  45353. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45354. }
  45355. }
  45356. }
  45357. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45358. import { Scene } from "babylonjs/scene";
  45359. import { Engine } from "babylonjs/Engines/engine";
  45360. import { Texture } from "babylonjs/Materials/Textures/texture";
  45361. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45362. import "babylonjs/Engines/Extensions/engine.multiRender";
  45363. /**
  45364. * Creation options of the multi render target texture.
  45365. */
  45366. export interface IMultiRenderTargetOptions {
  45367. /**
  45368. * Define if the texture needs to create mip maps after render.
  45369. */
  45370. generateMipMaps?: boolean;
  45371. /**
  45372. * Define the types of all the draw buffers we want to create
  45373. */
  45374. types?: number[];
  45375. /**
  45376. * Define the sampling modes of all the draw buffers we want to create
  45377. */
  45378. samplingModes?: number[];
  45379. /**
  45380. * Define if a depth buffer is required
  45381. */
  45382. generateDepthBuffer?: boolean;
  45383. /**
  45384. * Define if a stencil buffer is required
  45385. */
  45386. generateStencilBuffer?: boolean;
  45387. /**
  45388. * Define if a depth texture is required instead of a depth buffer
  45389. */
  45390. generateDepthTexture?: boolean;
  45391. /**
  45392. * Define the number of desired draw buffers
  45393. */
  45394. textureCount?: number;
  45395. /**
  45396. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45397. */
  45398. doNotChangeAspectRatio?: boolean;
  45399. /**
  45400. * Define the default type of the buffers we are creating
  45401. */
  45402. defaultType?: number;
  45403. }
  45404. /**
  45405. * A multi render target, like a render target provides the ability to render to a texture.
  45406. * Unlike the render target, it can render to several draw buffers in one draw.
  45407. * This is specially interesting in deferred rendering or for any effects requiring more than
  45408. * just one color from a single pass.
  45409. */
  45410. export class MultiRenderTarget extends RenderTargetTexture {
  45411. private _internalTextures;
  45412. private _textures;
  45413. private _multiRenderTargetOptions;
  45414. /**
  45415. * Get if draw buffers are currently supported by the used hardware and browser.
  45416. */
  45417. readonly isSupported: boolean;
  45418. /**
  45419. * Get the list of textures generated by the multi render target.
  45420. */
  45421. readonly textures: Texture[];
  45422. /**
  45423. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45424. */
  45425. readonly depthTexture: Texture;
  45426. /**
  45427. * Set the wrapping mode on U of all the textures we are rendering to.
  45428. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45429. */
  45430. wrapU: number;
  45431. /**
  45432. * Set the wrapping mode on V of all the textures we are rendering to.
  45433. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45434. */
  45435. wrapV: number;
  45436. /**
  45437. * Instantiate a new multi render target texture.
  45438. * A multi render target, like a render target provides the ability to render to a texture.
  45439. * Unlike the render target, it can render to several draw buffers in one draw.
  45440. * This is specially interesting in deferred rendering or for any effects requiring more than
  45441. * just one color from a single pass.
  45442. * @param name Define the name of the texture
  45443. * @param size Define the size of the buffers to render to
  45444. * @param count Define the number of target we are rendering into
  45445. * @param scene Define the scene the texture belongs to
  45446. * @param options Define the options used to create the multi render target
  45447. */
  45448. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45449. /** @hidden */
  45450. _rebuild(): void;
  45451. private _createInternalTextures;
  45452. private _createTextures;
  45453. /**
  45454. * Define the number of samples used if MSAA is enabled.
  45455. */
  45456. samples: number;
  45457. /**
  45458. * Resize all the textures in the multi render target.
  45459. * Be carrefull as it will recreate all the data in the new texture.
  45460. * @param size Define the new size
  45461. */
  45462. resize(size: any): void;
  45463. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45464. /**
  45465. * Dispose the render targets and their associated resources
  45466. */
  45467. dispose(): void;
  45468. /**
  45469. * Release all the underlying texture used as draw buffers.
  45470. */
  45471. releaseInternalTextures(): void;
  45472. }
  45473. }
  45474. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45475. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45476. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45477. import { Nullable } from "babylonjs/types";
  45478. module "babylonjs/Engines/engine" {
  45479. interface Engine {
  45480. /**
  45481. * Unbind a list of render target textures from the webGL context
  45482. * This is used only when drawBuffer extension or webGL2 are active
  45483. * @param textures defines the render target textures to unbind
  45484. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45485. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45486. */
  45487. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45488. /**
  45489. * Create a multi render target texture
  45490. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45491. * @param size defines the size of the texture
  45492. * @param options defines the creation options
  45493. * @returns the cube texture as an InternalTexture
  45494. */
  45495. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45496. /**
  45497. * Update the sample count for a given multiple render target texture
  45498. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45499. * @param textures defines the textures to update
  45500. * @param samples defines the sample count to set
  45501. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45502. */
  45503. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45504. }
  45505. }
  45506. }
  45507. declare module "babylonjs/Engines/Extensions/index" {
  45508. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45509. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45510. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45511. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45512. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45513. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45514. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45515. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45516. }
  45517. declare module "babylonjs/Engines/index" {
  45518. export * from "babylonjs/Engines/constants";
  45519. export * from "babylonjs/Engines/engine";
  45520. export * from "babylonjs/Engines/engineStore";
  45521. export * from "babylonjs/Engines/nullEngine";
  45522. export * from "babylonjs/Engines/Extensions/index";
  45523. export * from "babylonjs/Engines/IPipelineContext";
  45524. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45525. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45526. }
  45527. declare module "babylonjs/Events/clipboardEvents" {
  45528. /**
  45529. * Gather the list of clipboard event types as constants.
  45530. */
  45531. export class ClipboardEventTypes {
  45532. /**
  45533. * The clipboard event is fired when a copy command is active (pressed).
  45534. */
  45535. static readonly COPY: number;
  45536. /**
  45537. * The clipboard event is fired when a cut command is active (pressed).
  45538. */
  45539. static readonly CUT: number;
  45540. /**
  45541. * The clipboard event is fired when a paste command is active (pressed).
  45542. */
  45543. static readonly PASTE: number;
  45544. }
  45545. /**
  45546. * This class is used to store clipboard related info for the onClipboardObservable event.
  45547. */
  45548. export class ClipboardInfo {
  45549. /**
  45550. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45551. */
  45552. type: number;
  45553. /**
  45554. * Defines the related dom event
  45555. */
  45556. event: ClipboardEvent;
  45557. /**
  45558. *Creates an instance of ClipboardInfo.
  45559. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45560. * @param event Defines the related dom event
  45561. */
  45562. constructor(
  45563. /**
  45564. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45565. */
  45566. type: number,
  45567. /**
  45568. * Defines the related dom event
  45569. */
  45570. event: ClipboardEvent);
  45571. /**
  45572. * Get the clipboard event's type from the keycode.
  45573. * @param keyCode Defines the keyCode for the current keyboard event.
  45574. * @return {number}
  45575. */
  45576. static GetTypeFromCharacter(keyCode: number): number;
  45577. }
  45578. }
  45579. declare module "babylonjs/Events/index" {
  45580. export * from "babylonjs/Events/keyboardEvents";
  45581. export * from "babylonjs/Events/pointerEvents";
  45582. export * from "babylonjs/Events/clipboardEvents";
  45583. }
  45584. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45585. import { Scene } from "babylonjs/scene";
  45586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45587. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45588. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45589. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45590. /**
  45591. * Google Daydream controller
  45592. */
  45593. export class DaydreamController extends WebVRController {
  45594. /**
  45595. * Base Url for the controller model.
  45596. */
  45597. static MODEL_BASE_URL: string;
  45598. /**
  45599. * File name for the controller model.
  45600. */
  45601. static MODEL_FILENAME: string;
  45602. /**
  45603. * Gamepad Id prefix used to identify Daydream Controller.
  45604. */
  45605. static readonly GAMEPAD_ID_PREFIX: string;
  45606. /**
  45607. * Creates a new DaydreamController from a gamepad
  45608. * @param vrGamepad the gamepad that the controller should be created from
  45609. */
  45610. constructor(vrGamepad: any);
  45611. /**
  45612. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45613. * @param scene scene in which to add meshes
  45614. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45615. */
  45616. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45617. /**
  45618. * Called once for each button that changed state since the last frame
  45619. * @param buttonIdx Which button index changed
  45620. * @param state New state of the button
  45621. * @param changes Which properties on the state changed since last frame
  45622. */
  45623. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45624. }
  45625. }
  45626. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45627. import { Scene } from "babylonjs/scene";
  45628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45629. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45630. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45631. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45632. /**
  45633. * Gear VR Controller
  45634. */
  45635. export class GearVRController extends WebVRController {
  45636. /**
  45637. * Base Url for the controller model.
  45638. */
  45639. static MODEL_BASE_URL: string;
  45640. /**
  45641. * File name for the controller model.
  45642. */
  45643. static MODEL_FILENAME: string;
  45644. /**
  45645. * Gamepad Id prefix used to identify this controller.
  45646. */
  45647. static readonly GAMEPAD_ID_PREFIX: string;
  45648. private readonly _buttonIndexToObservableNameMap;
  45649. /**
  45650. * Creates a new GearVRController from a gamepad
  45651. * @param vrGamepad the gamepad that the controller should be created from
  45652. */
  45653. constructor(vrGamepad: any);
  45654. /**
  45655. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45656. * @param scene scene in which to add meshes
  45657. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45658. */
  45659. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45660. /**
  45661. * Called once for each button that changed state since the last frame
  45662. * @param buttonIdx Which button index changed
  45663. * @param state New state of the button
  45664. * @param changes Which properties on the state changed since last frame
  45665. */
  45666. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45667. }
  45668. }
  45669. declare module "babylonjs/Gamepads/Controllers/index" {
  45670. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45671. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45672. export * from "babylonjs/Gamepads/Controllers/genericController";
  45673. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45674. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45675. export * from "babylonjs/Gamepads/Controllers/viveController";
  45676. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45677. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45678. }
  45679. declare module "babylonjs/Gamepads/index" {
  45680. export * from "babylonjs/Gamepads/Controllers/index";
  45681. export * from "babylonjs/Gamepads/gamepad";
  45682. export * from "babylonjs/Gamepads/gamepadManager";
  45683. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45684. export * from "babylonjs/Gamepads/xboxGamepad";
  45685. export * from "babylonjs/Gamepads/dualShockGamepad";
  45686. }
  45687. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45688. import { Scene } from "babylonjs/scene";
  45689. import { Vector4 } from "babylonjs/Maths/math.vector";
  45690. import { Color4 } from "babylonjs/Maths/math.color";
  45691. import { Mesh } from "babylonjs/Meshes/mesh";
  45692. import { Nullable } from "babylonjs/types";
  45693. /**
  45694. * Class containing static functions to help procedurally build meshes
  45695. */
  45696. export class PolyhedronBuilder {
  45697. /**
  45698. * Creates a polyhedron mesh
  45699. * * 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
  45700. * * The parameter `size` (positive float, default 1) sets the polygon size
  45701. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45702. * * 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`
  45703. * * 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
  45704. * * 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)`)
  45705. * * 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
  45706. * * 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
  45707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45710. * @param name defines the name of the mesh
  45711. * @param options defines the options used to create the mesh
  45712. * @param scene defines the hosting scene
  45713. * @returns the polyhedron mesh
  45714. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45715. */
  45716. static CreatePolyhedron(name: string, options: {
  45717. type?: number;
  45718. size?: number;
  45719. sizeX?: number;
  45720. sizeY?: number;
  45721. sizeZ?: number;
  45722. custom?: any;
  45723. faceUV?: Vector4[];
  45724. faceColors?: Color4[];
  45725. flat?: boolean;
  45726. updatable?: boolean;
  45727. sideOrientation?: number;
  45728. frontUVs?: Vector4;
  45729. backUVs?: Vector4;
  45730. }, scene?: Nullable<Scene>): Mesh;
  45731. }
  45732. }
  45733. declare module "babylonjs/Gizmos/scaleGizmo" {
  45734. import { Observable } from "babylonjs/Misc/observable";
  45735. import { Nullable } from "babylonjs/types";
  45736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45737. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45738. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45739. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45740. /**
  45741. * Gizmo that enables scaling a mesh along 3 axis
  45742. */
  45743. export class ScaleGizmo extends Gizmo {
  45744. /**
  45745. * Internal gizmo used for interactions on the x axis
  45746. */
  45747. xGizmo: AxisScaleGizmo;
  45748. /**
  45749. * Internal gizmo used for interactions on the y axis
  45750. */
  45751. yGizmo: AxisScaleGizmo;
  45752. /**
  45753. * Internal gizmo used for interactions on the z axis
  45754. */
  45755. zGizmo: AxisScaleGizmo;
  45756. /**
  45757. * Internal gizmo used to scale all axis equally
  45758. */
  45759. uniformScaleGizmo: AxisScaleGizmo;
  45760. private _meshAttached;
  45761. private _updateGizmoRotationToMatchAttachedMesh;
  45762. private _snapDistance;
  45763. private _scaleRatio;
  45764. private _uniformScalingMesh;
  45765. private _octahedron;
  45766. /** Fires an event when any of it's sub gizmos are dragged */
  45767. onDragStartObservable: Observable<unknown>;
  45768. /** Fires an event when any of it's sub gizmos are released from dragging */
  45769. onDragEndObservable: Observable<unknown>;
  45770. attachedMesh: Nullable<AbstractMesh>;
  45771. /**
  45772. * Creates a ScaleGizmo
  45773. * @param gizmoLayer The utility layer the gizmo will be added to
  45774. */
  45775. constructor(gizmoLayer?: UtilityLayerRenderer);
  45776. updateGizmoRotationToMatchAttachedMesh: boolean;
  45777. /**
  45778. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45779. */
  45780. snapDistance: number;
  45781. /**
  45782. * Ratio for the scale of the gizmo (Default: 1)
  45783. */
  45784. scaleRatio: number;
  45785. /**
  45786. * Disposes of the gizmo
  45787. */
  45788. dispose(): void;
  45789. }
  45790. }
  45791. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45792. import { Observable } from "babylonjs/Misc/observable";
  45793. import { Nullable } from "babylonjs/types";
  45794. import { Vector3 } from "babylonjs/Maths/math.vector";
  45795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45796. import { Mesh } from "babylonjs/Meshes/mesh";
  45797. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45798. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45799. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45800. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45801. import { Color3 } from "babylonjs/Maths/math.color";
  45802. /**
  45803. * Single axis scale gizmo
  45804. */
  45805. export class AxisScaleGizmo extends Gizmo {
  45806. /**
  45807. * Drag behavior responsible for the gizmos dragging interactions
  45808. */
  45809. dragBehavior: PointerDragBehavior;
  45810. private _pointerObserver;
  45811. /**
  45812. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45813. */
  45814. snapDistance: number;
  45815. /**
  45816. * Event that fires each time the gizmo snaps to a new location.
  45817. * * snapDistance is the the change in distance
  45818. */
  45819. onSnapObservable: Observable<{
  45820. snapDistance: number;
  45821. }>;
  45822. /**
  45823. * If the scaling operation should be done on all axis (default: false)
  45824. */
  45825. uniformScaling: boolean;
  45826. private _isEnabled;
  45827. private _parent;
  45828. private _arrow;
  45829. private _coloredMaterial;
  45830. private _hoverMaterial;
  45831. /**
  45832. * Creates an AxisScaleGizmo
  45833. * @param gizmoLayer The utility layer the gizmo will be added to
  45834. * @param dragAxis The axis which the gizmo will be able to scale on
  45835. * @param color The color of the gizmo
  45836. */
  45837. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45838. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45839. /**
  45840. * If the gizmo is enabled
  45841. */
  45842. isEnabled: boolean;
  45843. /**
  45844. * Disposes of the gizmo
  45845. */
  45846. dispose(): void;
  45847. /**
  45848. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45849. * @param mesh The mesh to replace the default mesh of the gizmo
  45850. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45851. */
  45852. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45853. }
  45854. }
  45855. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45856. import { Observable } from "babylonjs/Misc/observable";
  45857. import { Nullable } from "babylonjs/types";
  45858. import { Vector3 } from "babylonjs/Maths/math.vector";
  45859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45860. import { Mesh } from "babylonjs/Meshes/mesh";
  45861. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45862. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45863. import { Color3 } from "babylonjs/Maths/math.color";
  45864. import "babylonjs/Meshes/Builders/boxBuilder";
  45865. /**
  45866. * Bounding box gizmo
  45867. */
  45868. export class BoundingBoxGizmo extends Gizmo {
  45869. private _lineBoundingBox;
  45870. private _rotateSpheresParent;
  45871. private _scaleBoxesParent;
  45872. private _boundingDimensions;
  45873. private _renderObserver;
  45874. private _pointerObserver;
  45875. private _scaleDragSpeed;
  45876. private _tmpQuaternion;
  45877. private _tmpVector;
  45878. private _tmpRotationMatrix;
  45879. /**
  45880. * 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)
  45881. */
  45882. ignoreChildren: boolean;
  45883. /**
  45884. * 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)
  45885. */
  45886. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45887. /**
  45888. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45889. */
  45890. rotationSphereSize: number;
  45891. /**
  45892. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45893. */
  45894. scaleBoxSize: number;
  45895. /**
  45896. * 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)
  45897. */
  45898. fixedDragMeshScreenSize: boolean;
  45899. /**
  45900. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45901. */
  45902. fixedDragMeshScreenSizeDistanceFactor: number;
  45903. /**
  45904. * Fired when a rotation sphere or scale box is dragged
  45905. */
  45906. onDragStartObservable: Observable<{}>;
  45907. /**
  45908. * Fired when a scale box is dragged
  45909. */
  45910. onScaleBoxDragObservable: Observable<{}>;
  45911. /**
  45912. * Fired when a scale box drag is ended
  45913. */
  45914. onScaleBoxDragEndObservable: Observable<{}>;
  45915. /**
  45916. * Fired when a rotation sphere is dragged
  45917. */
  45918. onRotationSphereDragObservable: Observable<{}>;
  45919. /**
  45920. * Fired when a rotation sphere drag is ended
  45921. */
  45922. onRotationSphereDragEndObservable: Observable<{}>;
  45923. /**
  45924. * 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)
  45925. */
  45926. scalePivot: Nullable<Vector3>;
  45927. /**
  45928. * Mesh used as a pivot to rotate the attached mesh
  45929. */
  45930. private _anchorMesh;
  45931. private _existingMeshScale;
  45932. private _dragMesh;
  45933. private pointerDragBehavior;
  45934. private coloredMaterial;
  45935. private hoverColoredMaterial;
  45936. /**
  45937. * Sets the color of the bounding box gizmo
  45938. * @param color the color to set
  45939. */
  45940. setColor(color: Color3): void;
  45941. /**
  45942. * Creates an BoundingBoxGizmo
  45943. * @param gizmoLayer The utility layer the gizmo will be added to
  45944. * @param color The color of the gizmo
  45945. */
  45946. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45947. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45948. private _selectNode;
  45949. /**
  45950. * Updates the bounding box information for the Gizmo
  45951. */
  45952. updateBoundingBox(): void;
  45953. private _updateRotationSpheres;
  45954. private _updateScaleBoxes;
  45955. /**
  45956. * Enables rotation on the specified axis and disables rotation on the others
  45957. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45958. */
  45959. setEnabledRotationAxis(axis: string): void;
  45960. /**
  45961. * Enables/disables scaling
  45962. * @param enable if scaling should be enabled
  45963. */
  45964. setEnabledScaling(enable: boolean): void;
  45965. private _updateDummy;
  45966. /**
  45967. * Enables a pointer drag behavior on the bounding box of the gizmo
  45968. */
  45969. enableDragBehavior(): void;
  45970. /**
  45971. * Disposes of the gizmo
  45972. */
  45973. dispose(): void;
  45974. /**
  45975. * 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)
  45976. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45977. * @returns the bounding box mesh with the passed in mesh as a child
  45978. */
  45979. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45980. /**
  45981. * CustomMeshes are not supported by this gizmo
  45982. * @param mesh The mesh to replace the default mesh of the gizmo
  45983. */
  45984. setCustomMesh(mesh: Mesh): void;
  45985. }
  45986. }
  45987. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45988. import { Observable } from "babylonjs/Misc/observable";
  45989. import { Nullable } from "babylonjs/types";
  45990. import { Vector3 } from "babylonjs/Maths/math.vector";
  45991. import { Color3 } from "babylonjs/Maths/math.color";
  45992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45993. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45994. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45995. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45996. import "babylonjs/Meshes/Builders/linesBuilder";
  45997. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45998. /**
  45999. * Single plane rotation gizmo
  46000. */
  46001. export class PlaneRotationGizmo extends Gizmo {
  46002. /**
  46003. * Drag behavior responsible for the gizmos dragging interactions
  46004. */
  46005. dragBehavior: PointerDragBehavior;
  46006. private _pointerObserver;
  46007. /**
  46008. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46009. */
  46010. snapDistance: number;
  46011. /**
  46012. * Event that fires each time the gizmo snaps to a new location.
  46013. * * snapDistance is the the change in distance
  46014. */
  46015. onSnapObservable: Observable<{
  46016. snapDistance: number;
  46017. }>;
  46018. private _isEnabled;
  46019. private _parent;
  46020. /**
  46021. * Creates a PlaneRotationGizmo
  46022. * @param gizmoLayer The utility layer the gizmo will be added to
  46023. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46024. * @param color The color of the gizmo
  46025. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46026. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46027. */
  46028. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46029. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46030. /**
  46031. * If the gizmo is enabled
  46032. */
  46033. isEnabled: boolean;
  46034. /**
  46035. * Disposes of the gizmo
  46036. */
  46037. dispose(): void;
  46038. }
  46039. }
  46040. declare module "babylonjs/Gizmos/rotationGizmo" {
  46041. import { Observable } from "babylonjs/Misc/observable";
  46042. import { Nullable } from "babylonjs/types";
  46043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46044. import { Mesh } from "babylonjs/Meshes/mesh";
  46045. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46046. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46047. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46048. /**
  46049. * Gizmo that enables rotating a mesh along 3 axis
  46050. */
  46051. export class RotationGizmo extends Gizmo {
  46052. /**
  46053. * Internal gizmo used for interactions on the x axis
  46054. */
  46055. xGizmo: PlaneRotationGizmo;
  46056. /**
  46057. * Internal gizmo used for interactions on the y axis
  46058. */
  46059. yGizmo: PlaneRotationGizmo;
  46060. /**
  46061. * Internal gizmo used for interactions on the z axis
  46062. */
  46063. zGizmo: PlaneRotationGizmo;
  46064. /** Fires an event when any of it's sub gizmos are dragged */
  46065. onDragStartObservable: Observable<unknown>;
  46066. /** Fires an event when any of it's sub gizmos are released from dragging */
  46067. onDragEndObservable: Observable<unknown>;
  46068. private _meshAttached;
  46069. attachedMesh: Nullable<AbstractMesh>;
  46070. /**
  46071. * Creates a RotationGizmo
  46072. * @param gizmoLayer The utility layer the gizmo will be added to
  46073. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46074. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46075. */
  46076. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46077. updateGizmoRotationToMatchAttachedMesh: boolean;
  46078. /**
  46079. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46080. */
  46081. snapDistance: number;
  46082. /**
  46083. * Ratio for the scale of the gizmo (Default: 1)
  46084. */
  46085. scaleRatio: number;
  46086. /**
  46087. * Disposes of the gizmo
  46088. */
  46089. dispose(): void;
  46090. /**
  46091. * CustomMeshes are not supported by this gizmo
  46092. * @param mesh The mesh to replace the default mesh of the gizmo
  46093. */
  46094. setCustomMesh(mesh: Mesh): void;
  46095. }
  46096. }
  46097. declare module "babylonjs/Gizmos/gizmoManager" {
  46098. import { Observable } from "babylonjs/Misc/observable";
  46099. import { Nullable } from "babylonjs/types";
  46100. import { Scene, IDisposable } from "babylonjs/scene";
  46101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46102. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46103. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46104. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46105. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46106. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46107. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46108. /**
  46109. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46110. */
  46111. export class GizmoManager implements IDisposable {
  46112. private scene;
  46113. /**
  46114. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46115. */
  46116. gizmos: {
  46117. positionGizmo: Nullable<PositionGizmo>;
  46118. rotationGizmo: Nullable<RotationGizmo>;
  46119. scaleGizmo: Nullable<ScaleGizmo>;
  46120. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46121. };
  46122. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46123. clearGizmoOnEmptyPointerEvent: boolean;
  46124. /** Fires an event when the manager is attached to a mesh */
  46125. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46126. private _gizmosEnabled;
  46127. private _pointerObserver;
  46128. private _attachedMesh;
  46129. private _boundingBoxColor;
  46130. private _defaultUtilityLayer;
  46131. private _defaultKeepDepthUtilityLayer;
  46132. /**
  46133. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46134. */
  46135. boundingBoxDragBehavior: SixDofDragBehavior;
  46136. /**
  46137. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46138. */
  46139. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46140. /**
  46141. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46142. */
  46143. usePointerToAttachGizmos: boolean;
  46144. /**
  46145. * Utility layer that the bounding box gizmo belongs to
  46146. */
  46147. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46148. /**
  46149. * Utility layer that all gizmos besides bounding box belong to
  46150. */
  46151. readonly utilityLayer: UtilityLayerRenderer;
  46152. /**
  46153. * Instatiates a gizmo manager
  46154. * @param scene the scene to overlay the gizmos on top of
  46155. */
  46156. constructor(scene: Scene);
  46157. /**
  46158. * Attaches a set of gizmos to the specified mesh
  46159. * @param mesh The mesh the gizmo's should be attached to
  46160. */
  46161. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46162. /**
  46163. * If the position gizmo is enabled
  46164. */
  46165. positionGizmoEnabled: boolean;
  46166. /**
  46167. * If the rotation gizmo is enabled
  46168. */
  46169. rotationGizmoEnabled: boolean;
  46170. /**
  46171. * If the scale gizmo is enabled
  46172. */
  46173. scaleGizmoEnabled: boolean;
  46174. /**
  46175. * If the boundingBox gizmo is enabled
  46176. */
  46177. boundingBoxGizmoEnabled: boolean;
  46178. /**
  46179. * Disposes of the gizmo manager
  46180. */
  46181. dispose(): void;
  46182. }
  46183. }
  46184. declare module "babylonjs/Lights/directionalLight" {
  46185. import { Camera } from "babylonjs/Cameras/camera";
  46186. import { Scene } from "babylonjs/scene";
  46187. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46189. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46190. import { Effect } from "babylonjs/Materials/effect";
  46191. /**
  46192. * A directional light is defined by a direction (what a surprise!).
  46193. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46194. * 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.
  46195. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46196. */
  46197. export class DirectionalLight extends ShadowLight {
  46198. private _shadowFrustumSize;
  46199. /**
  46200. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46201. */
  46202. /**
  46203. * Specifies a fix frustum size for the shadow generation.
  46204. */
  46205. shadowFrustumSize: number;
  46206. private _shadowOrthoScale;
  46207. /**
  46208. * Gets the shadow projection scale against the optimal computed one.
  46209. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46210. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46211. */
  46212. /**
  46213. * Sets the shadow projection scale against the optimal computed one.
  46214. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46215. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46216. */
  46217. shadowOrthoScale: number;
  46218. /**
  46219. * Automatically compute the projection matrix to best fit (including all the casters)
  46220. * on each frame.
  46221. */
  46222. autoUpdateExtends: boolean;
  46223. private _orthoLeft;
  46224. private _orthoRight;
  46225. private _orthoTop;
  46226. private _orthoBottom;
  46227. /**
  46228. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46229. * The directional light is emitted from everywhere in the given direction.
  46230. * It can cast shadows.
  46231. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46232. * @param name The friendly name of the light
  46233. * @param direction The direction of the light
  46234. * @param scene The scene the light belongs to
  46235. */
  46236. constructor(name: string, direction: Vector3, scene: Scene);
  46237. /**
  46238. * Returns the string "DirectionalLight".
  46239. * @return The class name
  46240. */
  46241. getClassName(): string;
  46242. /**
  46243. * Returns the integer 1.
  46244. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46245. */
  46246. getTypeID(): number;
  46247. /**
  46248. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46249. * Returns the DirectionalLight Shadow projection matrix.
  46250. */
  46251. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46252. /**
  46253. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46254. * Returns the DirectionalLight Shadow projection matrix.
  46255. */
  46256. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46257. /**
  46258. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46259. * Returns the DirectionalLight Shadow projection matrix.
  46260. */
  46261. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46262. protected _buildUniformLayout(): void;
  46263. /**
  46264. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46265. * @param effect The effect to update
  46266. * @param lightIndex The index of the light in the effect to update
  46267. * @returns The directional light
  46268. */
  46269. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46270. /**
  46271. * Gets the minZ used for shadow according to both the scene and the light.
  46272. *
  46273. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46274. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46275. * @param activeCamera The camera we are returning the min for
  46276. * @returns the depth min z
  46277. */
  46278. getDepthMinZ(activeCamera: Camera): number;
  46279. /**
  46280. * Gets the maxZ used for shadow according to both the scene and the light.
  46281. *
  46282. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46283. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46284. * @param activeCamera The camera we are returning the max for
  46285. * @returns the depth max z
  46286. */
  46287. getDepthMaxZ(activeCamera: Camera): number;
  46288. /**
  46289. * Prepares the list of defines specific to the light type.
  46290. * @param defines the list of defines
  46291. * @param lightIndex defines the index of the light for the effect
  46292. */
  46293. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46294. }
  46295. }
  46296. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46297. import { Mesh } from "babylonjs/Meshes/mesh";
  46298. /**
  46299. * Class containing static functions to help procedurally build meshes
  46300. */
  46301. export class HemisphereBuilder {
  46302. /**
  46303. * Creates a hemisphere mesh
  46304. * @param name defines the name of the mesh
  46305. * @param options defines the options used to create the mesh
  46306. * @param scene defines the hosting scene
  46307. * @returns the hemisphere mesh
  46308. */
  46309. static CreateHemisphere(name: string, options: {
  46310. segments?: number;
  46311. diameter?: number;
  46312. sideOrientation?: number;
  46313. }, scene: any): Mesh;
  46314. }
  46315. }
  46316. declare module "babylonjs/Lights/spotLight" {
  46317. import { Nullable } from "babylonjs/types";
  46318. import { Scene } from "babylonjs/scene";
  46319. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46321. import { Effect } from "babylonjs/Materials/effect";
  46322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46323. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46324. /**
  46325. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46326. * These values define a cone of light starting from the position, emitting toward the direction.
  46327. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46328. * and the exponent defines the speed of the decay of the light with distance (reach).
  46329. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46330. */
  46331. export class SpotLight extends ShadowLight {
  46332. private _angle;
  46333. private _innerAngle;
  46334. private _cosHalfAngle;
  46335. private _lightAngleScale;
  46336. private _lightAngleOffset;
  46337. /**
  46338. * Gets the cone angle of the spot light in Radians.
  46339. */
  46340. /**
  46341. * Sets the cone angle of the spot light in Radians.
  46342. */
  46343. angle: number;
  46344. /**
  46345. * Only used in gltf falloff mode, this defines the angle where
  46346. * the directional falloff will start before cutting at angle which could be seen
  46347. * as outer angle.
  46348. */
  46349. /**
  46350. * Only used in gltf falloff mode, this defines the angle where
  46351. * the directional falloff will start before cutting at angle which could be seen
  46352. * as outer angle.
  46353. */
  46354. innerAngle: number;
  46355. private _shadowAngleScale;
  46356. /**
  46357. * Allows scaling the angle of the light for shadow generation only.
  46358. */
  46359. /**
  46360. * Allows scaling the angle of the light for shadow generation only.
  46361. */
  46362. shadowAngleScale: number;
  46363. /**
  46364. * The light decay speed with the distance from the emission spot.
  46365. */
  46366. exponent: number;
  46367. private _projectionTextureMatrix;
  46368. /**
  46369. * Allows reading the projecton texture
  46370. */
  46371. readonly projectionTextureMatrix: Matrix;
  46372. protected _projectionTextureLightNear: number;
  46373. /**
  46374. * Gets the near clip of the Spotlight for texture projection.
  46375. */
  46376. /**
  46377. * Sets the near clip of the Spotlight for texture projection.
  46378. */
  46379. projectionTextureLightNear: number;
  46380. protected _projectionTextureLightFar: number;
  46381. /**
  46382. * Gets the far clip of the Spotlight for texture projection.
  46383. */
  46384. /**
  46385. * Sets the far clip of the Spotlight for texture projection.
  46386. */
  46387. projectionTextureLightFar: number;
  46388. protected _projectionTextureUpDirection: Vector3;
  46389. /**
  46390. * Gets the Up vector of the Spotlight for texture projection.
  46391. */
  46392. /**
  46393. * Sets the Up vector of the Spotlight for texture projection.
  46394. */
  46395. projectionTextureUpDirection: Vector3;
  46396. private _projectionTexture;
  46397. /**
  46398. * Gets the projection texture of the light.
  46399. */
  46400. /**
  46401. * Sets the projection texture of the light.
  46402. */
  46403. projectionTexture: Nullable<BaseTexture>;
  46404. private _projectionTextureViewLightDirty;
  46405. private _projectionTextureProjectionLightDirty;
  46406. private _projectionTextureDirty;
  46407. private _projectionTextureViewTargetVector;
  46408. private _projectionTextureViewLightMatrix;
  46409. private _projectionTextureProjectionLightMatrix;
  46410. private _projectionTextureScalingMatrix;
  46411. /**
  46412. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46413. * It can cast shadows.
  46414. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46415. * @param name The light friendly name
  46416. * @param position The position of the spot light in the scene
  46417. * @param direction The direction of the light in the scene
  46418. * @param angle The cone angle of the light in Radians
  46419. * @param exponent The light decay speed with the distance from the emission spot
  46420. * @param scene The scene the lights belongs to
  46421. */
  46422. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46423. /**
  46424. * Returns the string "SpotLight".
  46425. * @returns the class name
  46426. */
  46427. getClassName(): string;
  46428. /**
  46429. * Returns the integer 2.
  46430. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46431. */
  46432. getTypeID(): number;
  46433. /**
  46434. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46435. */
  46436. protected _setDirection(value: Vector3): void;
  46437. /**
  46438. * Overrides the position setter to recompute the projection texture view light Matrix.
  46439. */
  46440. protected _setPosition(value: Vector3): void;
  46441. /**
  46442. * 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.
  46443. * Returns the SpotLight.
  46444. */
  46445. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46446. protected _computeProjectionTextureViewLightMatrix(): void;
  46447. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46448. /**
  46449. * Main function for light texture projection matrix computing.
  46450. */
  46451. protected _computeProjectionTextureMatrix(): void;
  46452. protected _buildUniformLayout(): void;
  46453. private _computeAngleValues;
  46454. /**
  46455. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46456. * @param effect The effect to update
  46457. * @param lightIndex The index of the light in the effect to update
  46458. * @returns The spot light
  46459. */
  46460. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46461. /**
  46462. * Disposes the light and the associated resources.
  46463. */
  46464. dispose(): void;
  46465. /**
  46466. * Prepares the list of defines specific to the light type.
  46467. * @param defines the list of defines
  46468. * @param lightIndex defines the index of the light for the effect
  46469. */
  46470. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46471. }
  46472. }
  46473. declare module "babylonjs/Gizmos/lightGizmo" {
  46474. import { Nullable } from "babylonjs/types";
  46475. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46476. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46477. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46478. import { Light } from "babylonjs/Lights/light";
  46479. /**
  46480. * Gizmo that enables viewing a light
  46481. */
  46482. export class LightGizmo extends Gizmo {
  46483. private _lightMesh;
  46484. private _material;
  46485. private cachedPosition;
  46486. private cachedForward;
  46487. /**
  46488. * Creates a LightGizmo
  46489. * @param gizmoLayer The utility layer the gizmo will be added to
  46490. */
  46491. constructor(gizmoLayer?: UtilityLayerRenderer);
  46492. private _light;
  46493. /**
  46494. * The light that the gizmo is attached to
  46495. */
  46496. light: Nullable<Light>;
  46497. /**
  46498. * Gets the material used to render the light gizmo
  46499. */
  46500. readonly material: StandardMaterial;
  46501. /**
  46502. * @hidden
  46503. * Updates the gizmo to match the attached mesh's position/rotation
  46504. */
  46505. protected _update(): void;
  46506. private static _Scale;
  46507. /**
  46508. * Creates the lines for a light mesh
  46509. */
  46510. private static _createLightLines;
  46511. /**
  46512. * Disposes of the light gizmo
  46513. */
  46514. dispose(): void;
  46515. private static _CreateHemisphericLightMesh;
  46516. private static _CreatePointLightMesh;
  46517. private static _CreateSpotLightMesh;
  46518. private static _CreateDirectionalLightMesh;
  46519. }
  46520. }
  46521. declare module "babylonjs/Gizmos/index" {
  46522. export * from "babylonjs/Gizmos/axisDragGizmo";
  46523. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46524. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46525. export * from "babylonjs/Gizmos/gizmo";
  46526. export * from "babylonjs/Gizmos/gizmoManager";
  46527. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46528. export * from "babylonjs/Gizmos/positionGizmo";
  46529. export * from "babylonjs/Gizmos/rotationGizmo";
  46530. export * from "babylonjs/Gizmos/scaleGizmo";
  46531. export * from "babylonjs/Gizmos/lightGizmo";
  46532. export * from "babylonjs/Gizmos/planeDragGizmo";
  46533. }
  46534. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46535. /** @hidden */
  46536. export var backgroundFragmentDeclaration: {
  46537. name: string;
  46538. shader: string;
  46539. };
  46540. }
  46541. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46542. /** @hidden */
  46543. export var backgroundUboDeclaration: {
  46544. name: string;
  46545. shader: string;
  46546. };
  46547. }
  46548. declare module "babylonjs/Shaders/background.fragment" {
  46549. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46550. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46551. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46552. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46553. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46554. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46555. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46556. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46557. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46558. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46559. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46560. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46561. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46562. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46563. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46564. /** @hidden */
  46565. export var backgroundPixelShader: {
  46566. name: string;
  46567. shader: string;
  46568. };
  46569. }
  46570. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46571. /** @hidden */
  46572. export var backgroundVertexDeclaration: {
  46573. name: string;
  46574. shader: string;
  46575. };
  46576. }
  46577. declare module "babylonjs/Shaders/background.vertex" {
  46578. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46579. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46580. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46581. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46582. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46583. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46584. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46585. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46586. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46587. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46588. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46589. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46590. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46591. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46592. /** @hidden */
  46593. export var backgroundVertexShader: {
  46594. name: string;
  46595. shader: string;
  46596. };
  46597. }
  46598. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46599. import { Nullable, int, float } from "babylonjs/types";
  46600. import { Scene } from "babylonjs/scene";
  46601. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46602. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46604. import { Mesh } from "babylonjs/Meshes/mesh";
  46605. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46606. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46607. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46608. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46609. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46610. import { Color3 } from "babylonjs/Maths/math.color";
  46611. import "babylonjs/Shaders/background.fragment";
  46612. import "babylonjs/Shaders/background.vertex";
  46613. /**
  46614. * Background material used to create an efficient environement around your scene.
  46615. */
  46616. export class BackgroundMaterial extends PushMaterial {
  46617. /**
  46618. * Standard reflectance value at parallel view angle.
  46619. */
  46620. static StandardReflectance0: number;
  46621. /**
  46622. * Standard reflectance value at grazing angle.
  46623. */
  46624. static StandardReflectance90: number;
  46625. protected _primaryColor: Color3;
  46626. /**
  46627. * Key light Color (multiply against the environement texture)
  46628. */
  46629. primaryColor: Color3;
  46630. protected __perceptualColor: Nullable<Color3>;
  46631. /**
  46632. * Experimental Internal Use Only.
  46633. *
  46634. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46635. * This acts as a helper to set the primary color to a more "human friendly" value.
  46636. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46637. * output color as close as possible from the chosen value.
  46638. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46639. * part of lighting setup.)
  46640. */
  46641. _perceptualColor: Nullable<Color3>;
  46642. protected _primaryColorShadowLevel: float;
  46643. /**
  46644. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46645. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46646. */
  46647. primaryColorShadowLevel: float;
  46648. protected _primaryColorHighlightLevel: float;
  46649. /**
  46650. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46651. * The primary color is used at the level chosen to define what the white area would look.
  46652. */
  46653. primaryColorHighlightLevel: float;
  46654. protected _reflectionTexture: Nullable<BaseTexture>;
  46655. /**
  46656. * Reflection Texture used in the material.
  46657. * Should be author in a specific way for the best result (refer to the documentation).
  46658. */
  46659. reflectionTexture: Nullable<BaseTexture>;
  46660. protected _reflectionBlur: float;
  46661. /**
  46662. * Reflection Texture level of blur.
  46663. *
  46664. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46665. * texture twice.
  46666. */
  46667. reflectionBlur: float;
  46668. protected _diffuseTexture: Nullable<BaseTexture>;
  46669. /**
  46670. * Diffuse Texture used in the material.
  46671. * Should be author in a specific way for the best result (refer to the documentation).
  46672. */
  46673. diffuseTexture: Nullable<BaseTexture>;
  46674. protected _shadowLights: Nullable<IShadowLight[]>;
  46675. /**
  46676. * Specify the list of lights casting shadow on the material.
  46677. * All scene shadow lights will be included if null.
  46678. */
  46679. shadowLights: Nullable<IShadowLight[]>;
  46680. protected _shadowLevel: float;
  46681. /**
  46682. * Helps adjusting the shadow to a softer level if required.
  46683. * 0 means black shadows and 1 means no shadows.
  46684. */
  46685. shadowLevel: float;
  46686. protected _sceneCenter: Vector3;
  46687. /**
  46688. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46689. * It is usually zero but might be interesting to modify according to your setup.
  46690. */
  46691. sceneCenter: Vector3;
  46692. protected _opacityFresnel: boolean;
  46693. /**
  46694. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46695. * This helps ensuring a nice transition when the camera goes under the ground.
  46696. */
  46697. opacityFresnel: boolean;
  46698. protected _reflectionFresnel: boolean;
  46699. /**
  46700. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46701. * This helps adding a mirror texture on the ground.
  46702. */
  46703. reflectionFresnel: boolean;
  46704. protected _reflectionFalloffDistance: number;
  46705. /**
  46706. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46707. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46708. */
  46709. reflectionFalloffDistance: number;
  46710. protected _reflectionAmount: number;
  46711. /**
  46712. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46713. */
  46714. reflectionAmount: number;
  46715. protected _reflectionReflectance0: number;
  46716. /**
  46717. * This specifies the weight of the reflection at grazing angle.
  46718. */
  46719. reflectionReflectance0: number;
  46720. protected _reflectionReflectance90: number;
  46721. /**
  46722. * This specifies the weight of the reflection at a perpendicular point of view.
  46723. */
  46724. reflectionReflectance90: number;
  46725. /**
  46726. * Sets the reflection reflectance fresnel values according to the default standard
  46727. * empirically know to work well :-)
  46728. */
  46729. reflectionStandardFresnelWeight: number;
  46730. protected _useRGBColor: boolean;
  46731. /**
  46732. * Helps to directly use the maps channels instead of their level.
  46733. */
  46734. useRGBColor: boolean;
  46735. protected _enableNoise: boolean;
  46736. /**
  46737. * This helps reducing the banding effect that could occur on the background.
  46738. */
  46739. enableNoise: boolean;
  46740. /**
  46741. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46742. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46743. * Recommended to be keep at 1.0 except for special cases.
  46744. */
  46745. fovMultiplier: number;
  46746. private _fovMultiplier;
  46747. /**
  46748. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46749. */
  46750. useEquirectangularFOV: boolean;
  46751. private _maxSimultaneousLights;
  46752. /**
  46753. * Number of Simultaneous lights allowed on the material.
  46754. */
  46755. maxSimultaneousLights: int;
  46756. /**
  46757. * Default configuration related to image processing available in the Background Material.
  46758. */
  46759. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46760. /**
  46761. * Keep track of the image processing observer to allow dispose and replace.
  46762. */
  46763. private _imageProcessingObserver;
  46764. /**
  46765. * Attaches a new image processing configuration to the PBR Material.
  46766. * @param configuration (if null the scene configuration will be use)
  46767. */
  46768. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46769. /**
  46770. * Gets the image processing configuration used either in this material.
  46771. */
  46772. /**
  46773. * Sets the Default image processing configuration used either in the this material.
  46774. *
  46775. * If sets to null, the scene one is in use.
  46776. */
  46777. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46778. /**
  46779. * Gets wether the color curves effect is enabled.
  46780. */
  46781. /**
  46782. * Sets wether the color curves effect is enabled.
  46783. */
  46784. cameraColorCurvesEnabled: boolean;
  46785. /**
  46786. * Gets wether the color grading effect is enabled.
  46787. */
  46788. /**
  46789. * Gets wether the color grading effect is enabled.
  46790. */
  46791. cameraColorGradingEnabled: boolean;
  46792. /**
  46793. * Gets wether tonemapping is enabled or not.
  46794. */
  46795. /**
  46796. * Sets wether tonemapping is enabled or not
  46797. */
  46798. cameraToneMappingEnabled: boolean;
  46799. /**
  46800. * The camera exposure used on this material.
  46801. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46802. * This corresponds to a photographic exposure.
  46803. */
  46804. /**
  46805. * The camera exposure used on this material.
  46806. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46807. * This corresponds to a photographic exposure.
  46808. */
  46809. cameraExposure: float;
  46810. /**
  46811. * Gets The camera contrast used on this material.
  46812. */
  46813. /**
  46814. * Sets The camera contrast used on this material.
  46815. */
  46816. cameraContrast: float;
  46817. /**
  46818. * Gets the Color Grading 2D Lookup Texture.
  46819. */
  46820. /**
  46821. * Sets the Color Grading 2D Lookup Texture.
  46822. */
  46823. cameraColorGradingTexture: Nullable<BaseTexture>;
  46824. /**
  46825. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46826. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46827. * 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;
  46828. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46829. */
  46830. /**
  46831. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46832. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46833. * 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;
  46834. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46835. */
  46836. cameraColorCurves: Nullable<ColorCurves>;
  46837. /**
  46838. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46839. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46840. */
  46841. switchToBGR: boolean;
  46842. private _renderTargets;
  46843. private _reflectionControls;
  46844. private _white;
  46845. private _primaryShadowColor;
  46846. private _primaryHighlightColor;
  46847. /**
  46848. * Instantiates a Background Material in the given scene
  46849. * @param name The friendly name of the material
  46850. * @param scene The scene to add the material to
  46851. */
  46852. constructor(name: string, scene: Scene);
  46853. /**
  46854. * Gets a boolean indicating that current material needs to register RTT
  46855. */
  46856. readonly hasRenderTargetTextures: boolean;
  46857. /**
  46858. * The entire material has been created in order to prevent overdraw.
  46859. * @returns false
  46860. */
  46861. needAlphaTesting(): boolean;
  46862. /**
  46863. * The entire material has been created in order to prevent overdraw.
  46864. * @returns true if blending is enable
  46865. */
  46866. needAlphaBlending(): boolean;
  46867. /**
  46868. * Checks wether the material is ready to be rendered for a given mesh.
  46869. * @param mesh The mesh to render
  46870. * @param subMesh The submesh to check against
  46871. * @param useInstances Specify wether or not the material is used with instances
  46872. * @returns true if all the dependencies are ready (Textures, Effects...)
  46873. */
  46874. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46875. /**
  46876. * Compute the primary color according to the chosen perceptual color.
  46877. */
  46878. private _computePrimaryColorFromPerceptualColor;
  46879. /**
  46880. * Compute the highlights and shadow colors according to their chosen levels.
  46881. */
  46882. private _computePrimaryColors;
  46883. /**
  46884. * Build the uniform buffer used in the material.
  46885. */
  46886. buildUniformLayout(): void;
  46887. /**
  46888. * Unbind the material.
  46889. */
  46890. unbind(): void;
  46891. /**
  46892. * Bind only the world matrix to the material.
  46893. * @param world The world matrix to bind.
  46894. */
  46895. bindOnlyWorldMatrix(world: Matrix): void;
  46896. /**
  46897. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46898. * @param world The world matrix to bind.
  46899. * @param subMesh The submesh to bind for.
  46900. */
  46901. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46902. /**
  46903. * Checks to see if a texture is used in the material.
  46904. * @param texture - Base texture to use.
  46905. * @returns - Boolean specifying if a texture is used in the material.
  46906. */
  46907. hasTexture(texture: BaseTexture): boolean;
  46908. /**
  46909. * Dispose the material.
  46910. * @param forceDisposeEffect Force disposal of the associated effect.
  46911. * @param forceDisposeTextures Force disposal of the associated textures.
  46912. */
  46913. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46914. /**
  46915. * Clones the material.
  46916. * @param name The cloned name.
  46917. * @returns The cloned material.
  46918. */
  46919. clone(name: string): BackgroundMaterial;
  46920. /**
  46921. * Serializes the current material to its JSON representation.
  46922. * @returns The JSON representation.
  46923. */
  46924. serialize(): any;
  46925. /**
  46926. * Gets the class name of the material
  46927. * @returns "BackgroundMaterial"
  46928. */
  46929. getClassName(): string;
  46930. /**
  46931. * Parse a JSON input to create back a background material.
  46932. * @param source The JSON data to parse
  46933. * @param scene The scene to create the parsed material in
  46934. * @param rootUrl The root url of the assets the material depends upon
  46935. * @returns the instantiated BackgroundMaterial.
  46936. */
  46937. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46938. }
  46939. }
  46940. declare module "babylonjs/Helpers/environmentHelper" {
  46941. import { Observable } from "babylonjs/Misc/observable";
  46942. import { Nullable } from "babylonjs/types";
  46943. import { Scene } from "babylonjs/scene";
  46944. import { Vector3 } from "babylonjs/Maths/math.vector";
  46945. import { Color3 } from "babylonjs/Maths/math.color";
  46946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46947. import { Mesh } from "babylonjs/Meshes/mesh";
  46948. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46949. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46950. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46951. import "babylonjs/Meshes/Builders/planeBuilder";
  46952. import "babylonjs/Meshes/Builders/boxBuilder";
  46953. /**
  46954. * Represents the different options available during the creation of
  46955. * a Environment helper.
  46956. *
  46957. * This can control the default ground, skybox and image processing setup of your scene.
  46958. */
  46959. export interface IEnvironmentHelperOptions {
  46960. /**
  46961. * Specifies wether or not to create a ground.
  46962. * True by default.
  46963. */
  46964. createGround: boolean;
  46965. /**
  46966. * Specifies the ground size.
  46967. * 15 by default.
  46968. */
  46969. groundSize: number;
  46970. /**
  46971. * The texture used on the ground for the main color.
  46972. * Comes from the BabylonJS CDN by default.
  46973. *
  46974. * Remarks: Can be either a texture or a url.
  46975. */
  46976. groundTexture: string | BaseTexture;
  46977. /**
  46978. * The color mixed in the ground texture by default.
  46979. * BabylonJS clearColor by default.
  46980. */
  46981. groundColor: Color3;
  46982. /**
  46983. * Specifies the ground opacity.
  46984. * 1 by default.
  46985. */
  46986. groundOpacity: number;
  46987. /**
  46988. * Enables the ground to receive shadows.
  46989. * True by default.
  46990. */
  46991. enableGroundShadow: boolean;
  46992. /**
  46993. * Helps preventing the shadow to be fully black on the ground.
  46994. * 0.5 by default.
  46995. */
  46996. groundShadowLevel: number;
  46997. /**
  46998. * Creates a mirror texture attach to the ground.
  46999. * false by default.
  47000. */
  47001. enableGroundMirror: boolean;
  47002. /**
  47003. * Specifies the ground mirror size ratio.
  47004. * 0.3 by default as the default kernel is 64.
  47005. */
  47006. groundMirrorSizeRatio: number;
  47007. /**
  47008. * Specifies the ground mirror blur kernel size.
  47009. * 64 by default.
  47010. */
  47011. groundMirrorBlurKernel: number;
  47012. /**
  47013. * Specifies the ground mirror visibility amount.
  47014. * 1 by default
  47015. */
  47016. groundMirrorAmount: number;
  47017. /**
  47018. * Specifies the ground mirror reflectance weight.
  47019. * This uses the standard weight of the background material to setup the fresnel effect
  47020. * of the mirror.
  47021. * 1 by default.
  47022. */
  47023. groundMirrorFresnelWeight: number;
  47024. /**
  47025. * Specifies the ground mirror Falloff distance.
  47026. * This can helps reducing the size of the reflection.
  47027. * 0 by Default.
  47028. */
  47029. groundMirrorFallOffDistance: number;
  47030. /**
  47031. * Specifies the ground mirror texture type.
  47032. * Unsigned Int by Default.
  47033. */
  47034. groundMirrorTextureType: number;
  47035. /**
  47036. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47037. * the shown objects.
  47038. */
  47039. groundYBias: number;
  47040. /**
  47041. * Specifies wether or not to create a skybox.
  47042. * True by default.
  47043. */
  47044. createSkybox: boolean;
  47045. /**
  47046. * Specifies the skybox size.
  47047. * 20 by default.
  47048. */
  47049. skyboxSize: number;
  47050. /**
  47051. * The texture used on the skybox for the main color.
  47052. * Comes from the BabylonJS CDN by default.
  47053. *
  47054. * Remarks: Can be either a texture or a url.
  47055. */
  47056. skyboxTexture: string | BaseTexture;
  47057. /**
  47058. * The color mixed in the skybox texture by default.
  47059. * BabylonJS clearColor by default.
  47060. */
  47061. skyboxColor: Color3;
  47062. /**
  47063. * The background rotation around the Y axis of the scene.
  47064. * This helps aligning the key lights of your scene with the background.
  47065. * 0 by default.
  47066. */
  47067. backgroundYRotation: number;
  47068. /**
  47069. * Compute automatically the size of the elements to best fit with the scene.
  47070. */
  47071. sizeAuto: boolean;
  47072. /**
  47073. * Default position of the rootMesh if autoSize is not true.
  47074. */
  47075. rootPosition: Vector3;
  47076. /**
  47077. * Sets up the image processing in the scene.
  47078. * true by default.
  47079. */
  47080. setupImageProcessing: boolean;
  47081. /**
  47082. * The texture used as your environment texture in the scene.
  47083. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47084. *
  47085. * Remarks: Can be either a texture or a url.
  47086. */
  47087. environmentTexture: string | BaseTexture;
  47088. /**
  47089. * The value of the exposure to apply to the scene.
  47090. * 0.6 by default if setupImageProcessing is true.
  47091. */
  47092. cameraExposure: number;
  47093. /**
  47094. * The value of the contrast to apply to the scene.
  47095. * 1.6 by default if setupImageProcessing is true.
  47096. */
  47097. cameraContrast: number;
  47098. /**
  47099. * Specifies wether or not tonemapping should be enabled in the scene.
  47100. * true by default if setupImageProcessing is true.
  47101. */
  47102. toneMappingEnabled: boolean;
  47103. }
  47104. /**
  47105. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47106. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47107. * It also helps with the default setup of your imageProcessing configuration.
  47108. */
  47109. export class EnvironmentHelper {
  47110. /**
  47111. * Default ground texture URL.
  47112. */
  47113. private static _groundTextureCDNUrl;
  47114. /**
  47115. * Default skybox texture URL.
  47116. */
  47117. private static _skyboxTextureCDNUrl;
  47118. /**
  47119. * Default environment texture URL.
  47120. */
  47121. private static _environmentTextureCDNUrl;
  47122. /**
  47123. * Creates the default options for the helper.
  47124. */
  47125. private static _getDefaultOptions;
  47126. private _rootMesh;
  47127. /**
  47128. * Gets the root mesh created by the helper.
  47129. */
  47130. readonly rootMesh: Mesh;
  47131. private _skybox;
  47132. /**
  47133. * Gets the skybox created by the helper.
  47134. */
  47135. readonly skybox: Nullable<Mesh>;
  47136. private _skyboxTexture;
  47137. /**
  47138. * Gets the skybox texture created by the helper.
  47139. */
  47140. readonly skyboxTexture: Nullable<BaseTexture>;
  47141. private _skyboxMaterial;
  47142. /**
  47143. * Gets the skybox material created by the helper.
  47144. */
  47145. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47146. private _ground;
  47147. /**
  47148. * Gets the ground mesh created by the helper.
  47149. */
  47150. readonly ground: Nullable<Mesh>;
  47151. private _groundTexture;
  47152. /**
  47153. * Gets the ground texture created by the helper.
  47154. */
  47155. readonly groundTexture: Nullable<BaseTexture>;
  47156. private _groundMirror;
  47157. /**
  47158. * Gets the ground mirror created by the helper.
  47159. */
  47160. readonly groundMirror: Nullable<MirrorTexture>;
  47161. /**
  47162. * Gets the ground mirror render list to helps pushing the meshes
  47163. * you wish in the ground reflection.
  47164. */
  47165. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47166. private _groundMaterial;
  47167. /**
  47168. * Gets the ground material created by the helper.
  47169. */
  47170. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47171. /**
  47172. * Stores the creation options.
  47173. */
  47174. private readonly _scene;
  47175. private _options;
  47176. /**
  47177. * This observable will be notified with any error during the creation of the environment,
  47178. * mainly texture creation errors.
  47179. */
  47180. onErrorObservable: Observable<{
  47181. message?: string;
  47182. exception?: any;
  47183. }>;
  47184. /**
  47185. * constructor
  47186. * @param options Defines the options we want to customize the helper
  47187. * @param scene The scene to add the material to
  47188. */
  47189. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47190. /**
  47191. * Updates the background according to the new options
  47192. * @param options
  47193. */
  47194. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47195. /**
  47196. * Sets the primary color of all the available elements.
  47197. * @param color the main color to affect to the ground and the background
  47198. */
  47199. setMainColor(color: Color3): void;
  47200. /**
  47201. * Setup the image processing according to the specified options.
  47202. */
  47203. private _setupImageProcessing;
  47204. /**
  47205. * Setup the environment texture according to the specified options.
  47206. */
  47207. private _setupEnvironmentTexture;
  47208. /**
  47209. * Setup the background according to the specified options.
  47210. */
  47211. private _setupBackground;
  47212. /**
  47213. * Get the scene sizes according to the setup.
  47214. */
  47215. private _getSceneSize;
  47216. /**
  47217. * Setup the ground according to the specified options.
  47218. */
  47219. private _setupGround;
  47220. /**
  47221. * Setup the ground material according to the specified options.
  47222. */
  47223. private _setupGroundMaterial;
  47224. /**
  47225. * Setup the ground diffuse texture according to the specified options.
  47226. */
  47227. private _setupGroundDiffuseTexture;
  47228. /**
  47229. * Setup the ground mirror texture according to the specified options.
  47230. */
  47231. private _setupGroundMirrorTexture;
  47232. /**
  47233. * Setup the ground to receive the mirror texture.
  47234. */
  47235. private _setupMirrorInGroundMaterial;
  47236. /**
  47237. * Setup the skybox according to the specified options.
  47238. */
  47239. private _setupSkybox;
  47240. /**
  47241. * Setup the skybox material according to the specified options.
  47242. */
  47243. private _setupSkyboxMaterial;
  47244. /**
  47245. * Setup the skybox reflection texture according to the specified options.
  47246. */
  47247. private _setupSkyboxReflectionTexture;
  47248. private _errorHandler;
  47249. /**
  47250. * Dispose all the elements created by the Helper.
  47251. */
  47252. dispose(): void;
  47253. }
  47254. }
  47255. declare module "babylonjs/Helpers/photoDome" {
  47256. import { Observable } from "babylonjs/Misc/observable";
  47257. import { Nullable } from "babylonjs/types";
  47258. import { Scene } from "babylonjs/scene";
  47259. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47260. import { Mesh } from "babylonjs/Meshes/mesh";
  47261. import { Texture } from "babylonjs/Materials/Textures/texture";
  47262. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47263. import "babylonjs/Meshes/Builders/sphereBuilder";
  47264. /**
  47265. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47266. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47267. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47268. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47269. */
  47270. export class PhotoDome extends TransformNode {
  47271. /**
  47272. * Define the image as a Monoscopic panoramic 360 image.
  47273. */
  47274. static readonly MODE_MONOSCOPIC: number;
  47275. /**
  47276. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47277. */
  47278. static readonly MODE_TOPBOTTOM: number;
  47279. /**
  47280. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47281. */
  47282. static readonly MODE_SIDEBYSIDE: number;
  47283. private _useDirectMapping;
  47284. /**
  47285. * The texture being displayed on the sphere
  47286. */
  47287. protected _photoTexture: Texture;
  47288. /**
  47289. * Gets or sets the texture being displayed on the sphere
  47290. */
  47291. photoTexture: Texture;
  47292. /**
  47293. * Observable raised when an error occured while loading the 360 image
  47294. */
  47295. onLoadErrorObservable: Observable<string>;
  47296. /**
  47297. * The skybox material
  47298. */
  47299. protected _material: BackgroundMaterial;
  47300. /**
  47301. * The surface used for the skybox
  47302. */
  47303. protected _mesh: Mesh;
  47304. /**
  47305. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47306. * Also see the options.resolution property.
  47307. */
  47308. fovMultiplier: number;
  47309. private _imageMode;
  47310. /**
  47311. * Gets or set the current video mode for the video. It can be:
  47312. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47313. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47314. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47315. */
  47316. imageMode: number;
  47317. /**
  47318. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47319. * @param name Element's name, child elements will append suffixes for their own names.
  47320. * @param urlsOfPhoto defines the url of the photo to display
  47321. * @param options defines an object containing optional or exposed sub element properties
  47322. * @param onError defines a callback called when an error occured while loading the texture
  47323. */
  47324. constructor(name: string, urlOfPhoto: string, options: {
  47325. resolution?: number;
  47326. size?: number;
  47327. useDirectMapping?: boolean;
  47328. faceForward?: boolean;
  47329. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47330. private _onBeforeCameraRenderObserver;
  47331. private _changeImageMode;
  47332. /**
  47333. * Releases resources associated with this node.
  47334. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47335. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47336. */
  47337. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47338. }
  47339. }
  47340. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47341. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47342. /** @hidden */
  47343. export var rgbdDecodePixelShader: {
  47344. name: string;
  47345. shader: string;
  47346. };
  47347. }
  47348. declare module "babylonjs/Misc/brdfTextureTools" {
  47349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47350. import { Scene } from "babylonjs/scene";
  47351. import "babylonjs/Shaders/rgbdDecode.fragment";
  47352. /**
  47353. * Class used to host texture specific utilities
  47354. */
  47355. export class BRDFTextureTools {
  47356. /**
  47357. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47358. * @param texture the texture to expand.
  47359. */
  47360. private static _ExpandDefaultBRDFTexture;
  47361. /**
  47362. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47363. * @param scene defines the hosting scene
  47364. * @returns the environment BRDF texture
  47365. */
  47366. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47367. private static _environmentBRDFBase64Texture;
  47368. }
  47369. }
  47370. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47371. import { Nullable } from "babylonjs/types";
  47372. import { Color3 } from "babylonjs/Maths/math.color";
  47373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47374. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47375. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47376. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47377. import { Engine } from "babylonjs/Engines/engine";
  47378. import { Scene } from "babylonjs/scene";
  47379. /**
  47380. * @hidden
  47381. */
  47382. export interface IMaterialClearCoatDefines {
  47383. CLEARCOAT: boolean;
  47384. CLEARCOAT_DEFAULTIOR: boolean;
  47385. CLEARCOAT_TEXTURE: boolean;
  47386. CLEARCOAT_TEXTUREDIRECTUV: number;
  47387. CLEARCOAT_BUMP: boolean;
  47388. CLEARCOAT_BUMPDIRECTUV: number;
  47389. CLEARCOAT_TINT: boolean;
  47390. CLEARCOAT_TINT_TEXTURE: boolean;
  47391. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47392. /** @hidden */
  47393. _areTexturesDirty: boolean;
  47394. }
  47395. /**
  47396. * Define the code related to the clear coat parameters of the pbr material.
  47397. */
  47398. export class PBRClearCoatConfiguration {
  47399. /**
  47400. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47401. * The default fits with a polyurethane material.
  47402. */
  47403. private static readonly _DefaultIndexOfRefraction;
  47404. private _isEnabled;
  47405. /**
  47406. * Defines if the clear coat is enabled in the material.
  47407. */
  47408. isEnabled: boolean;
  47409. /**
  47410. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47411. */
  47412. intensity: number;
  47413. /**
  47414. * Defines the clear coat layer roughness.
  47415. */
  47416. roughness: number;
  47417. private _indexOfRefraction;
  47418. /**
  47419. * Defines the index of refraction of the clear coat.
  47420. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47421. * The default fits with a polyurethane material.
  47422. * Changing the default value is more performance intensive.
  47423. */
  47424. indexOfRefraction: number;
  47425. private _texture;
  47426. /**
  47427. * Stores the clear coat values in a texture.
  47428. */
  47429. texture: Nullable<BaseTexture>;
  47430. private _bumpTexture;
  47431. /**
  47432. * Define the clear coat specific bump texture.
  47433. */
  47434. bumpTexture: Nullable<BaseTexture>;
  47435. private _isTintEnabled;
  47436. /**
  47437. * Defines if the clear coat tint is enabled in the material.
  47438. */
  47439. isTintEnabled: boolean;
  47440. /**
  47441. * Defines the clear coat tint of the material.
  47442. * This is only use if tint is enabled
  47443. */
  47444. tintColor: Color3;
  47445. /**
  47446. * Defines the distance at which the tint color should be found in the
  47447. * clear coat media.
  47448. * This is only use if tint is enabled
  47449. */
  47450. tintColorAtDistance: number;
  47451. /**
  47452. * Defines the clear coat layer thickness.
  47453. * This is only use if tint is enabled
  47454. */
  47455. tintThickness: number;
  47456. private _tintTexture;
  47457. /**
  47458. * Stores the clear tint values in a texture.
  47459. * rgb is tint
  47460. * a is a thickness factor
  47461. */
  47462. tintTexture: Nullable<BaseTexture>;
  47463. /** @hidden */
  47464. private _internalMarkAllSubMeshesAsTexturesDirty;
  47465. /** @hidden */
  47466. _markAllSubMeshesAsTexturesDirty(): void;
  47467. /**
  47468. * Instantiate a new istance of clear coat configuration.
  47469. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47470. */
  47471. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47472. /**
  47473. * Gets wehter the submesh is ready to be used or not.
  47474. * @param defines the list of "defines" to update.
  47475. * @param scene defines the scene the material belongs to.
  47476. * @param engine defines the engine the material belongs to.
  47477. * @param disableBumpMap defines wether the material disables bump or not.
  47478. * @returns - boolean indicating that the submesh is ready or not.
  47479. */
  47480. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47481. /**
  47482. * Checks to see if a texture is used in the material.
  47483. * @param defines the list of "defines" to update.
  47484. * @param scene defines the scene to the material belongs to.
  47485. */
  47486. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47487. /**
  47488. * Binds the material data.
  47489. * @param uniformBuffer defines the Uniform buffer to fill in.
  47490. * @param scene defines the scene the material belongs to.
  47491. * @param engine defines the engine the material belongs to.
  47492. * @param disableBumpMap defines wether the material disables bump or not.
  47493. * @param isFrozen defines wether the material is frozen or not.
  47494. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47495. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47496. */
  47497. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47498. /**
  47499. * Checks to see if a texture is used in the material.
  47500. * @param texture - Base texture to use.
  47501. * @returns - Boolean specifying if a texture is used in the material.
  47502. */
  47503. hasTexture(texture: BaseTexture): boolean;
  47504. /**
  47505. * Returns an array of the actively used textures.
  47506. * @param activeTextures Array of BaseTextures
  47507. */
  47508. getActiveTextures(activeTextures: BaseTexture[]): void;
  47509. /**
  47510. * Returns the animatable textures.
  47511. * @param animatables Array of animatable textures.
  47512. */
  47513. getAnimatables(animatables: IAnimatable[]): void;
  47514. /**
  47515. * Disposes the resources of the material.
  47516. * @param forceDisposeTextures - Forces the disposal of all textures.
  47517. */
  47518. dispose(forceDisposeTextures?: boolean): void;
  47519. /**
  47520. * Get the current class name of the texture useful for serialization or dynamic coding.
  47521. * @returns "PBRClearCoatConfiguration"
  47522. */
  47523. getClassName(): string;
  47524. /**
  47525. * Add fallbacks to the effect fallbacks list.
  47526. * @param defines defines the Base texture to use.
  47527. * @param fallbacks defines the current fallback list.
  47528. * @param currentRank defines the current fallback rank.
  47529. * @returns the new fallback rank.
  47530. */
  47531. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47532. /**
  47533. * Add the required uniforms to the current list.
  47534. * @param uniforms defines the current uniform list.
  47535. */
  47536. static AddUniforms(uniforms: string[]): void;
  47537. /**
  47538. * Add the required samplers to the current list.
  47539. * @param samplers defines the current sampler list.
  47540. */
  47541. static AddSamplers(samplers: string[]): void;
  47542. /**
  47543. * Add the required uniforms to the current buffer.
  47544. * @param uniformBuffer defines the current uniform buffer.
  47545. */
  47546. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47547. /**
  47548. * Makes a duplicate of the current configuration into another one.
  47549. * @param clearCoatConfiguration define the config where to copy the info
  47550. */
  47551. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47552. /**
  47553. * Serializes this clear coat configuration.
  47554. * @returns - An object with the serialized config.
  47555. */
  47556. serialize(): any;
  47557. /**
  47558. * Parses a anisotropy Configuration from a serialized object.
  47559. * @param source - Serialized object.
  47560. * @param scene Defines the scene we are parsing for
  47561. * @param rootUrl Defines the rootUrl to load from
  47562. */
  47563. parse(source: any, scene: Scene, rootUrl: string): void;
  47564. }
  47565. }
  47566. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47567. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47568. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47570. import { Vector2 } from "babylonjs/Maths/math.vector";
  47571. import { Scene } from "babylonjs/scene";
  47572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47573. import { Nullable } from "babylonjs/types";
  47574. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47575. /**
  47576. * @hidden
  47577. */
  47578. export interface IMaterialAnisotropicDefines {
  47579. ANISOTROPIC: boolean;
  47580. ANISOTROPIC_TEXTURE: boolean;
  47581. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47582. MAINUV1: boolean;
  47583. _areTexturesDirty: boolean;
  47584. _needUVs: boolean;
  47585. }
  47586. /**
  47587. * Define the code related to the anisotropic parameters of the pbr material.
  47588. */
  47589. export class PBRAnisotropicConfiguration {
  47590. private _isEnabled;
  47591. /**
  47592. * Defines if the anisotropy is enabled in the material.
  47593. */
  47594. isEnabled: boolean;
  47595. /**
  47596. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47597. */
  47598. intensity: number;
  47599. /**
  47600. * Defines if the effect is along the tangents, bitangents or in between.
  47601. * By default, the effect is "strectching" the highlights along the tangents.
  47602. */
  47603. direction: Vector2;
  47604. private _texture;
  47605. /**
  47606. * Stores the anisotropy values in a texture.
  47607. * rg is direction (like normal from -1 to 1)
  47608. * b is a intensity
  47609. */
  47610. texture: Nullable<BaseTexture>;
  47611. /** @hidden */
  47612. private _internalMarkAllSubMeshesAsTexturesDirty;
  47613. /** @hidden */
  47614. _markAllSubMeshesAsTexturesDirty(): void;
  47615. /**
  47616. * Instantiate a new istance of anisotropy configuration.
  47617. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47618. */
  47619. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47620. /**
  47621. * Specifies that the submesh is ready to be used.
  47622. * @param defines the list of "defines" to update.
  47623. * @param scene defines the scene the material belongs to.
  47624. * @returns - boolean indicating that the submesh is ready or not.
  47625. */
  47626. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47627. /**
  47628. * Checks to see if a texture is used in the material.
  47629. * @param defines the list of "defines" to update.
  47630. * @param mesh the mesh we are preparing the defines for.
  47631. * @param scene defines the scene the material belongs to.
  47632. */
  47633. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47634. /**
  47635. * Binds the material data.
  47636. * @param uniformBuffer defines the Uniform buffer to fill in.
  47637. * @param scene defines the scene the material belongs to.
  47638. * @param isFrozen defines wether the material is frozen or not.
  47639. */
  47640. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47641. /**
  47642. * Checks to see if a texture is used in the material.
  47643. * @param texture - Base texture to use.
  47644. * @returns - Boolean specifying if a texture is used in the material.
  47645. */
  47646. hasTexture(texture: BaseTexture): boolean;
  47647. /**
  47648. * Returns an array of the actively used textures.
  47649. * @param activeTextures Array of BaseTextures
  47650. */
  47651. getActiveTextures(activeTextures: BaseTexture[]): void;
  47652. /**
  47653. * Returns the animatable textures.
  47654. * @param animatables Array of animatable textures.
  47655. */
  47656. getAnimatables(animatables: IAnimatable[]): void;
  47657. /**
  47658. * Disposes the resources of the material.
  47659. * @param forceDisposeTextures - Forces the disposal of all textures.
  47660. */
  47661. dispose(forceDisposeTextures?: boolean): void;
  47662. /**
  47663. * Get the current class name of the texture useful for serialization or dynamic coding.
  47664. * @returns "PBRAnisotropicConfiguration"
  47665. */
  47666. getClassName(): string;
  47667. /**
  47668. * Add fallbacks to the effect fallbacks list.
  47669. * @param defines defines the Base texture to use.
  47670. * @param fallbacks defines the current fallback list.
  47671. * @param currentRank defines the current fallback rank.
  47672. * @returns the new fallback rank.
  47673. */
  47674. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47675. /**
  47676. * Add the required uniforms to the current list.
  47677. * @param uniforms defines the current uniform list.
  47678. */
  47679. static AddUniforms(uniforms: string[]): void;
  47680. /**
  47681. * Add the required uniforms to the current buffer.
  47682. * @param uniformBuffer defines the current uniform buffer.
  47683. */
  47684. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47685. /**
  47686. * Add the required samplers to the current list.
  47687. * @param samplers defines the current sampler list.
  47688. */
  47689. static AddSamplers(samplers: string[]): void;
  47690. /**
  47691. * Makes a duplicate of the current configuration into another one.
  47692. * @param anisotropicConfiguration define the config where to copy the info
  47693. */
  47694. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47695. /**
  47696. * Serializes this anisotropy configuration.
  47697. * @returns - An object with the serialized config.
  47698. */
  47699. serialize(): any;
  47700. /**
  47701. * Parses a anisotropy Configuration from a serialized object.
  47702. * @param source - Serialized object.
  47703. * @param scene Defines the scene we are parsing for
  47704. * @param rootUrl Defines the rootUrl to load from
  47705. */
  47706. parse(source: any, scene: Scene, rootUrl: string): void;
  47707. }
  47708. }
  47709. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47710. import { Scene } from "babylonjs/scene";
  47711. /**
  47712. * @hidden
  47713. */
  47714. export interface IMaterialBRDFDefines {
  47715. BRDF_V_HEIGHT_CORRELATED: boolean;
  47716. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47717. SPHERICAL_HARMONICS: boolean;
  47718. /** @hidden */
  47719. _areMiscDirty: boolean;
  47720. }
  47721. /**
  47722. * Define the code related to the BRDF parameters of the pbr material.
  47723. */
  47724. export class PBRBRDFConfiguration {
  47725. /**
  47726. * Default value used for the energy conservation.
  47727. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47728. */
  47729. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47730. /**
  47731. * Default value used for the Smith Visibility Height Correlated mode.
  47732. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47733. */
  47734. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47735. /**
  47736. * Default value used for the IBL diffuse part.
  47737. * This can help switching back to the polynomials mode globally which is a tiny bit
  47738. * less GPU intensive at the drawback of a lower quality.
  47739. */
  47740. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47741. private _useEnergyConservation;
  47742. /**
  47743. * Defines if the material uses energy conservation.
  47744. */
  47745. useEnergyConservation: boolean;
  47746. private _useSmithVisibilityHeightCorrelated;
  47747. /**
  47748. * LEGACY Mode set to false
  47749. * Defines if the material uses height smith correlated visibility term.
  47750. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47751. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47752. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47753. * Not relying on height correlated will also disable energy conservation.
  47754. */
  47755. useSmithVisibilityHeightCorrelated: boolean;
  47756. private _useSphericalHarmonics;
  47757. /**
  47758. * LEGACY Mode set to false
  47759. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47760. * diffuse part of the IBL.
  47761. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47762. * to the ground truth.
  47763. */
  47764. useSphericalHarmonics: boolean;
  47765. /** @hidden */
  47766. private _internalMarkAllSubMeshesAsMiscDirty;
  47767. /** @hidden */
  47768. _markAllSubMeshesAsMiscDirty(): void;
  47769. /**
  47770. * Instantiate a new istance of clear coat configuration.
  47771. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47772. */
  47773. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47774. /**
  47775. * Checks to see if a texture is used in the material.
  47776. * @param defines the list of "defines" to update.
  47777. */
  47778. prepareDefines(defines: IMaterialBRDFDefines): void;
  47779. /**
  47780. * Get the current class name of the texture useful for serialization or dynamic coding.
  47781. * @returns "PBRClearCoatConfiguration"
  47782. */
  47783. getClassName(): string;
  47784. /**
  47785. * Makes a duplicate of the current configuration into another one.
  47786. * @param brdfConfiguration define the config where to copy the info
  47787. */
  47788. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47789. /**
  47790. * Serializes this BRDF configuration.
  47791. * @returns - An object with the serialized config.
  47792. */
  47793. serialize(): any;
  47794. /**
  47795. * Parses a anisotropy Configuration from a serialized object.
  47796. * @param source - Serialized object.
  47797. * @param scene Defines the scene we are parsing for
  47798. * @param rootUrl Defines the rootUrl to load from
  47799. */
  47800. parse(source: any, scene: Scene, rootUrl: string): void;
  47801. }
  47802. }
  47803. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47804. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47805. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47806. import { Color3 } from "babylonjs/Maths/math.color";
  47807. import { Scene } from "babylonjs/scene";
  47808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47809. import { Nullable } from "babylonjs/types";
  47810. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47811. /**
  47812. * @hidden
  47813. */
  47814. export interface IMaterialSheenDefines {
  47815. SHEEN: boolean;
  47816. SHEEN_TEXTURE: boolean;
  47817. SHEEN_TEXTUREDIRECTUV: number;
  47818. SHEEN_LINKWITHALBEDO: boolean;
  47819. /** @hidden */
  47820. _areTexturesDirty: boolean;
  47821. }
  47822. /**
  47823. * Define the code related to the Sheen parameters of the pbr material.
  47824. */
  47825. export class PBRSheenConfiguration {
  47826. private _isEnabled;
  47827. /**
  47828. * Defines if the material uses sheen.
  47829. */
  47830. isEnabled: boolean;
  47831. private _linkSheenWithAlbedo;
  47832. /**
  47833. * Defines if the sheen is linked to the sheen color.
  47834. */
  47835. linkSheenWithAlbedo: boolean;
  47836. /**
  47837. * Defines the sheen intensity.
  47838. */
  47839. intensity: number;
  47840. /**
  47841. * Defines the sheen color.
  47842. */
  47843. color: Color3;
  47844. private _texture;
  47845. /**
  47846. * Stores the sheen tint values in a texture.
  47847. * rgb is tint
  47848. * a is a intensity
  47849. */
  47850. texture: Nullable<BaseTexture>;
  47851. /** @hidden */
  47852. private _internalMarkAllSubMeshesAsTexturesDirty;
  47853. /** @hidden */
  47854. _markAllSubMeshesAsTexturesDirty(): void;
  47855. /**
  47856. * Instantiate a new istance of clear coat configuration.
  47857. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47858. */
  47859. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47860. /**
  47861. * Specifies that the submesh is ready to be used.
  47862. * @param defines the list of "defines" to update.
  47863. * @param scene defines the scene the material belongs to.
  47864. * @returns - boolean indicating that the submesh is ready or not.
  47865. */
  47866. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47867. /**
  47868. * Checks to see if a texture is used in the material.
  47869. * @param defines the list of "defines" to update.
  47870. * @param scene defines the scene the material belongs to.
  47871. */
  47872. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47873. /**
  47874. * Binds the material data.
  47875. * @param uniformBuffer defines the Uniform buffer to fill in.
  47876. * @param scene defines the scene the material belongs to.
  47877. * @param isFrozen defines wether the material is frozen or not.
  47878. */
  47879. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47880. /**
  47881. * Checks to see if a texture is used in the material.
  47882. * @param texture - Base texture to use.
  47883. * @returns - Boolean specifying if a texture is used in the material.
  47884. */
  47885. hasTexture(texture: BaseTexture): boolean;
  47886. /**
  47887. * Returns an array of the actively used textures.
  47888. * @param activeTextures Array of BaseTextures
  47889. */
  47890. getActiveTextures(activeTextures: BaseTexture[]): void;
  47891. /**
  47892. * Returns the animatable textures.
  47893. * @param animatables Array of animatable textures.
  47894. */
  47895. getAnimatables(animatables: IAnimatable[]): void;
  47896. /**
  47897. * Disposes the resources of the material.
  47898. * @param forceDisposeTextures - Forces the disposal of all textures.
  47899. */
  47900. dispose(forceDisposeTextures?: boolean): void;
  47901. /**
  47902. * Get the current class name of the texture useful for serialization or dynamic coding.
  47903. * @returns "PBRSheenConfiguration"
  47904. */
  47905. getClassName(): string;
  47906. /**
  47907. * Add fallbacks to the effect fallbacks list.
  47908. * @param defines defines the Base texture to use.
  47909. * @param fallbacks defines the current fallback list.
  47910. * @param currentRank defines the current fallback rank.
  47911. * @returns the new fallback rank.
  47912. */
  47913. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47914. /**
  47915. * Add the required uniforms to the current list.
  47916. * @param uniforms defines the current uniform list.
  47917. */
  47918. static AddUniforms(uniforms: string[]): void;
  47919. /**
  47920. * Add the required uniforms to the current buffer.
  47921. * @param uniformBuffer defines the current uniform buffer.
  47922. */
  47923. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47924. /**
  47925. * Add the required samplers to the current list.
  47926. * @param samplers defines the current sampler list.
  47927. */
  47928. static AddSamplers(samplers: string[]): void;
  47929. /**
  47930. * Makes a duplicate of the current configuration into another one.
  47931. * @param sheenConfiguration define the config where to copy the info
  47932. */
  47933. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47934. /**
  47935. * Serializes this BRDF configuration.
  47936. * @returns - An object with the serialized config.
  47937. */
  47938. serialize(): any;
  47939. /**
  47940. * Parses a anisotropy Configuration from a serialized object.
  47941. * @param source - Serialized object.
  47942. * @param scene Defines the scene we are parsing for
  47943. * @param rootUrl Defines the rootUrl to load from
  47944. */
  47945. parse(source: any, scene: Scene, rootUrl: string): void;
  47946. }
  47947. }
  47948. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47949. import { Nullable } from "babylonjs/types";
  47950. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47951. import { Color3 } from "babylonjs/Maths/math.color";
  47952. import { SmartArray } from "babylonjs/Misc/smartArray";
  47953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47954. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47955. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47956. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47957. import { Engine } from "babylonjs/Engines/engine";
  47958. import { Scene } from "babylonjs/scene";
  47959. /**
  47960. * @hidden
  47961. */
  47962. export interface IMaterialSubSurfaceDefines {
  47963. SUBSURFACE: boolean;
  47964. SS_REFRACTION: boolean;
  47965. SS_TRANSLUCENCY: boolean;
  47966. SS_SCATERRING: boolean;
  47967. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47968. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47969. SS_REFRACTIONMAP_3D: boolean;
  47970. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47971. SS_LODINREFRACTIONALPHA: boolean;
  47972. SS_GAMMAREFRACTION: boolean;
  47973. SS_RGBDREFRACTION: boolean;
  47974. SS_LINEARSPECULARREFRACTION: boolean;
  47975. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47976. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47977. /** @hidden */
  47978. _areTexturesDirty: boolean;
  47979. }
  47980. /**
  47981. * Define the code related to the sub surface parameters of the pbr material.
  47982. */
  47983. export class PBRSubSurfaceConfiguration {
  47984. private _isRefractionEnabled;
  47985. /**
  47986. * Defines if the refraction is enabled in the material.
  47987. */
  47988. isRefractionEnabled: boolean;
  47989. private _isTranslucencyEnabled;
  47990. /**
  47991. * Defines if the translucency is enabled in the material.
  47992. */
  47993. isTranslucencyEnabled: boolean;
  47994. private _isScatteringEnabled;
  47995. /**
  47996. * Defines the refraction intensity of the material.
  47997. * The refraction when enabled replaces the Diffuse part of the material.
  47998. * The intensity helps transitionning between diffuse and refraction.
  47999. */
  48000. refractionIntensity: number;
  48001. /**
  48002. * Defines the translucency intensity of the material.
  48003. * When translucency has been enabled, this defines how much of the "translucency"
  48004. * is addded to the diffuse part of the material.
  48005. */
  48006. translucencyIntensity: number;
  48007. /**
  48008. * Defines the scattering intensity of the material.
  48009. * When scattering has been enabled, this defines how much of the "scattered light"
  48010. * is addded to the diffuse part of the material.
  48011. */
  48012. scatteringIntensity: number;
  48013. private _thicknessTexture;
  48014. /**
  48015. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48016. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48017. * 0 would mean minimumThickness
  48018. * 1 would mean maximumThickness
  48019. * The other channels might be use as a mask to vary the different effects intensity.
  48020. */
  48021. thicknessTexture: Nullable<BaseTexture>;
  48022. private _refractionTexture;
  48023. /**
  48024. * Defines the texture to use for refraction.
  48025. */
  48026. refractionTexture: Nullable<BaseTexture>;
  48027. private _indexOfRefraction;
  48028. /**
  48029. * Defines the index of refraction used in the material.
  48030. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48031. */
  48032. indexOfRefraction: number;
  48033. private _invertRefractionY;
  48034. /**
  48035. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48036. */
  48037. invertRefractionY: boolean;
  48038. private _linkRefractionWithTransparency;
  48039. /**
  48040. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48041. * Materials half opaque for instance using refraction could benefit from this control.
  48042. */
  48043. linkRefractionWithTransparency: boolean;
  48044. /**
  48045. * Defines the minimum thickness stored in the thickness map.
  48046. * If no thickness map is defined, this value will be used to simulate thickness.
  48047. */
  48048. minimumThickness: number;
  48049. /**
  48050. * Defines the maximum thickness stored in the thickness map.
  48051. */
  48052. maximumThickness: number;
  48053. /**
  48054. * Defines the volume tint of the material.
  48055. * This is used for both translucency and scattering.
  48056. */
  48057. tintColor: Color3;
  48058. /**
  48059. * Defines the distance at which the tint color should be found in the media.
  48060. * This is used for refraction only.
  48061. */
  48062. tintColorAtDistance: number;
  48063. /**
  48064. * Defines how far each channel transmit through the media.
  48065. * It is defined as a color to simplify it selection.
  48066. */
  48067. diffusionDistance: Color3;
  48068. private _useMaskFromThicknessTexture;
  48069. /**
  48070. * Stores the intensity of the different subsurface effects in the thickness texture.
  48071. * * the green channel is the translucency intensity.
  48072. * * the blue channel is the scattering intensity.
  48073. * * the alpha channel is the refraction intensity.
  48074. */
  48075. useMaskFromThicknessTexture: boolean;
  48076. /** @hidden */
  48077. private _internalMarkAllSubMeshesAsTexturesDirty;
  48078. /** @hidden */
  48079. _markAllSubMeshesAsTexturesDirty(): void;
  48080. /**
  48081. * Instantiate a new istance of sub surface configuration.
  48082. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48083. */
  48084. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48085. /**
  48086. * Gets wehter the submesh is ready to be used or not.
  48087. * @param defines the list of "defines" to update.
  48088. * @param scene defines the scene the material belongs to.
  48089. * @returns - boolean indicating that the submesh is ready or not.
  48090. */
  48091. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48092. /**
  48093. * Checks to see if a texture is used in the material.
  48094. * @param defines the list of "defines" to update.
  48095. * @param scene defines the scene to the material belongs to.
  48096. */
  48097. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48098. /**
  48099. * Binds the material data.
  48100. * @param uniformBuffer defines the Uniform buffer to fill in.
  48101. * @param scene defines the scene the material belongs to.
  48102. * @param engine defines the engine the material belongs to.
  48103. * @param isFrozen defines wether the material is frozen or not.
  48104. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48105. */
  48106. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48107. /**
  48108. * Unbinds the material from the mesh.
  48109. * @param activeEffect defines the effect that should be unbound from.
  48110. * @returns true if unbound, otherwise false
  48111. */
  48112. unbind(activeEffect: Effect): boolean;
  48113. /**
  48114. * Returns the texture used for refraction or null if none is used.
  48115. * @param scene defines the scene the material belongs to.
  48116. * @returns - Refraction texture if present. If no refraction texture and refraction
  48117. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48118. */
  48119. private _getRefractionTexture;
  48120. /**
  48121. * Returns true if alpha blending should be disabled.
  48122. */
  48123. readonly disableAlphaBlending: boolean;
  48124. /**
  48125. * Fills the list of render target textures.
  48126. * @param renderTargets the list of render targets to update
  48127. */
  48128. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48129. /**
  48130. * Checks to see if a texture is used in the material.
  48131. * @param texture - Base texture to use.
  48132. * @returns - Boolean specifying if a texture is used in the material.
  48133. */
  48134. hasTexture(texture: BaseTexture): boolean;
  48135. /**
  48136. * Gets a boolean indicating that current material needs to register RTT
  48137. * @returns true if this uses a render target otherwise false.
  48138. */
  48139. hasRenderTargetTextures(): boolean;
  48140. /**
  48141. * Returns an array of the actively used textures.
  48142. * @param activeTextures Array of BaseTextures
  48143. */
  48144. getActiveTextures(activeTextures: BaseTexture[]): void;
  48145. /**
  48146. * Returns the animatable textures.
  48147. * @param animatables Array of animatable textures.
  48148. */
  48149. getAnimatables(animatables: IAnimatable[]): void;
  48150. /**
  48151. * Disposes the resources of the material.
  48152. * @param forceDisposeTextures - Forces the disposal of all textures.
  48153. */
  48154. dispose(forceDisposeTextures?: boolean): void;
  48155. /**
  48156. * Get the current class name of the texture useful for serialization or dynamic coding.
  48157. * @returns "PBRSubSurfaceConfiguration"
  48158. */
  48159. getClassName(): string;
  48160. /**
  48161. * Add fallbacks to the effect fallbacks list.
  48162. * @param defines defines the Base texture to use.
  48163. * @param fallbacks defines the current fallback list.
  48164. * @param currentRank defines the current fallback rank.
  48165. * @returns the new fallback rank.
  48166. */
  48167. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48168. /**
  48169. * Add the required uniforms to the current list.
  48170. * @param uniforms defines the current uniform list.
  48171. */
  48172. static AddUniforms(uniforms: string[]): void;
  48173. /**
  48174. * Add the required samplers to the current list.
  48175. * @param samplers defines the current sampler list.
  48176. */
  48177. static AddSamplers(samplers: string[]): void;
  48178. /**
  48179. * Add the required uniforms to the current buffer.
  48180. * @param uniformBuffer defines the current uniform buffer.
  48181. */
  48182. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48183. /**
  48184. * Makes a duplicate of the current configuration into another one.
  48185. * @param configuration define the config where to copy the info
  48186. */
  48187. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48188. /**
  48189. * Serializes this Sub Surface configuration.
  48190. * @returns - An object with the serialized config.
  48191. */
  48192. serialize(): any;
  48193. /**
  48194. * Parses a anisotropy Configuration from a serialized object.
  48195. * @param source - Serialized object.
  48196. * @param scene Defines the scene we are parsing for
  48197. * @param rootUrl Defines the rootUrl to load from
  48198. */
  48199. parse(source: any, scene: Scene, rootUrl: string): void;
  48200. }
  48201. }
  48202. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48203. /** @hidden */
  48204. export var pbrFragmentDeclaration: {
  48205. name: string;
  48206. shader: string;
  48207. };
  48208. }
  48209. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48210. /** @hidden */
  48211. export var pbrUboDeclaration: {
  48212. name: string;
  48213. shader: string;
  48214. };
  48215. }
  48216. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48217. /** @hidden */
  48218. export var pbrFragmentExtraDeclaration: {
  48219. name: string;
  48220. shader: string;
  48221. };
  48222. }
  48223. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48224. /** @hidden */
  48225. export var pbrFragmentSamplersDeclaration: {
  48226. name: string;
  48227. shader: string;
  48228. };
  48229. }
  48230. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48231. /** @hidden */
  48232. export var pbrHelperFunctions: {
  48233. name: string;
  48234. shader: string;
  48235. };
  48236. }
  48237. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48238. /** @hidden */
  48239. export var harmonicsFunctions: {
  48240. name: string;
  48241. shader: string;
  48242. };
  48243. }
  48244. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48245. /** @hidden */
  48246. export var pbrDirectLightingSetupFunctions: {
  48247. name: string;
  48248. shader: string;
  48249. };
  48250. }
  48251. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48252. /** @hidden */
  48253. export var pbrDirectLightingFalloffFunctions: {
  48254. name: string;
  48255. shader: string;
  48256. };
  48257. }
  48258. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48259. /** @hidden */
  48260. export var pbrBRDFFunctions: {
  48261. name: string;
  48262. shader: string;
  48263. };
  48264. }
  48265. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48266. /** @hidden */
  48267. export var pbrDirectLightingFunctions: {
  48268. name: string;
  48269. shader: string;
  48270. };
  48271. }
  48272. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48273. /** @hidden */
  48274. export var pbrIBLFunctions: {
  48275. name: string;
  48276. shader: string;
  48277. };
  48278. }
  48279. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48280. /** @hidden */
  48281. export var pbrDebug: {
  48282. name: string;
  48283. shader: string;
  48284. };
  48285. }
  48286. declare module "babylonjs/Shaders/pbr.fragment" {
  48287. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48288. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48289. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48290. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48291. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48292. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48293. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48294. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48295. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48296. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48297. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48298. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48299. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48300. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48301. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48302. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48303. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48304. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48305. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48306. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48307. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48308. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48309. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48310. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48311. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48312. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48313. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48314. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48315. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48316. /** @hidden */
  48317. export var pbrPixelShader: {
  48318. name: string;
  48319. shader: string;
  48320. };
  48321. }
  48322. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48323. /** @hidden */
  48324. export var pbrVertexDeclaration: {
  48325. name: string;
  48326. shader: string;
  48327. };
  48328. }
  48329. declare module "babylonjs/Shaders/pbr.vertex" {
  48330. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48331. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48333. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48334. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48335. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48336. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48337. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48338. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48339. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48340. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48341. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48343. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48344. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48345. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48346. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48347. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48348. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48349. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48350. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48351. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48352. /** @hidden */
  48353. export var pbrVertexShader: {
  48354. name: string;
  48355. shader: string;
  48356. };
  48357. }
  48358. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48359. import { Nullable } from "babylonjs/types";
  48360. import { Scene } from "babylonjs/scene";
  48361. import { Matrix } from "babylonjs/Maths/math.vector";
  48362. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48364. import { Mesh } from "babylonjs/Meshes/mesh";
  48365. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48366. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48367. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48368. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48369. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48370. import { Color3 } from "babylonjs/Maths/math.color";
  48371. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48372. import { Material } from "babylonjs/Materials/material";
  48373. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48374. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48376. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48377. import "babylonjs/Shaders/pbr.fragment";
  48378. import "babylonjs/Shaders/pbr.vertex";
  48379. /**
  48380. * Manages the defines for the PBR Material.
  48381. * @hidden
  48382. */
  48383. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48384. PBR: boolean;
  48385. MAINUV1: boolean;
  48386. MAINUV2: boolean;
  48387. UV1: boolean;
  48388. UV2: boolean;
  48389. ALBEDO: boolean;
  48390. ALBEDODIRECTUV: number;
  48391. VERTEXCOLOR: boolean;
  48392. AMBIENT: boolean;
  48393. AMBIENTDIRECTUV: number;
  48394. AMBIENTINGRAYSCALE: boolean;
  48395. OPACITY: boolean;
  48396. VERTEXALPHA: boolean;
  48397. OPACITYDIRECTUV: number;
  48398. OPACITYRGB: boolean;
  48399. ALPHATEST: boolean;
  48400. DEPTHPREPASS: boolean;
  48401. ALPHABLEND: boolean;
  48402. ALPHAFROMALBEDO: boolean;
  48403. ALPHATESTVALUE: string;
  48404. SPECULAROVERALPHA: boolean;
  48405. RADIANCEOVERALPHA: boolean;
  48406. ALPHAFRESNEL: boolean;
  48407. LINEARALPHAFRESNEL: boolean;
  48408. PREMULTIPLYALPHA: boolean;
  48409. EMISSIVE: boolean;
  48410. EMISSIVEDIRECTUV: number;
  48411. REFLECTIVITY: boolean;
  48412. REFLECTIVITYDIRECTUV: number;
  48413. SPECULARTERM: boolean;
  48414. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48415. MICROSURFACEAUTOMATIC: boolean;
  48416. LODBASEDMICROSFURACE: boolean;
  48417. MICROSURFACEMAP: boolean;
  48418. MICROSURFACEMAPDIRECTUV: number;
  48419. METALLICWORKFLOW: boolean;
  48420. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48421. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48422. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48423. AOSTOREINMETALMAPRED: boolean;
  48424. ENVIRONMENTBRDF: boolean;
  48425. ENVIRONMENTBRDF_RGBD: boolean;
  48426. NORMAL: boolean;
  48427. TANGENT: boolean;
  48428. BUMP: boolean;
  48429. BUMPDIRECTUV: number;
  48430. OBJECTSPACE_NORMALMAP: boolean;
  48431. PARALLAX: boolean;
  48432. PARALLAXOCCLUSION: boolean;
  48433. NORMALXYSCALE: boolean;
  48434. LIGHTMAP: boolean;
  48435. LIGHTMAPDIRECTUV: number;
  48436. USELIGHTMAPASSHADOWMAP: boolean;
  48437. GAMMALIGHTMAP: boolean;
  48438. REFLECTION: boolean;
  48439. REFLECTIONMAP_3D: boolean;
  48440. REFLECTIONMAP_SPHERICAL: boolean;
  48441. REFLECTIONMAP_PLANAR: boolean;
  48442. REFLECTIONMAP_CUBIC: boolean;
  48443. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48444. REFLECTIONMAP_PROJECTION: boolean;
  48445. REFLECTIONMAP_SKYBOX: boolean;
  48446. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48447. REFLECTIONMAP_EXPLICIT: boolean;
  48448. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48449. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48450. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48451. INVERTCUBICMAP: boolean;
  48452. USESPHERICALFROMREFLECTIONMAP: boolean;
  48453. USEIRRADIANCEMAP: boolean;
  48454. SPHERICAL_HARMONICS: boolean;
  48455. USESPHERICALINVERTEX: boolean;
  48456. REFLECTIONMAP_OPPOSITEZ: boolean;
  48457. LODINREFLECTIONALPHA: boolean;
  48458. GAMMAREFLECTION: boolean;
  48459. RGBDREFLECTION: boolean;
  48460. LINEARSPECULARREFLECTION: boolean;
  48461. RADIANCEOCCLUSION: boolean;
  48462. HORIZONOCCLUSION: boolean;
  48463. INSTANCES: boolean;
  48464. NUM_BONE_INFLUENCERS: number;
  48465. BonesPerMesh: number;
  48466. BONETEXTURE: boolean;
  48467. NONUNIFORMSCALING: boolean;
  48468. MORPHTARGETS: boolean;
  48469. MORPHTARGETS_NORMAL: boolean;
  48470. MORPHTARGETS_TANGENT: boolean;
  48471. MORPHTARGETS_UV: boolean;
  48472. NUM_MORPH_INFLUENCERS: number;
  48473. IMAGEPROCESSING: boolean;
  48474. VIGNETTE: boolean;
  48475. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48476. VIGNETTEBLENDMODEOPAQUE: boolean;
  48477. TONEMAPPING: boolean;
  48478. TONEMAPPING_ACES: boolean;
  48479. CONTRAST: boolean;
  48480. COLORCURVES: boolean;
  48481. COLORGRADING: boolean;
  48482. COLORGRADING3D: boolean;
  48483. SAMPLER3DGREENDEPTH: boolean;
  48484. SAMPLER3DBGRMAP: boolean;
  48485. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48486. EXPOSURE: boolean;
  48487. MULTIVIEW: boolean;
  48488. USEPHYSICALLIGHTFALLOFF: boolean;
  48489. USEGLTFLIGHTFALLOFF: boolean;
  48490. TWOSIDEDLIGHTING: boolean;
  48491. SHADOWFLOAT: boolean;
  48492. CLIPPLANE: boolean;
  48493. CLIPPLANE2: boolean;
  48494. CLIPPLANE3: boolean;
  48495. CLIPPLANE4: boolean;
  48496. POINTSIZE: boolean;
  48497. FOG: boolean;
  48498. LOGARITHMICDEPTH: boolean;
  48499. FORCENORMALFORWARD: boolean;
  48500. SPECULARAA: boolean;
  48501. CLEARCOAT: boolean;
  48502. CLEARCOAT_DEFAULTIOR: boolean;
  48503. CLEARCOAT_TEXTURE: boolean;
  48504. CLEARCOAT_TEXTUREDIRECTUV: number;
  48505. CLEARCOAT_BUMP: boolean;
  48506. CLEARCOAT_BUMPDIRECTUV: number;
  48507. CLEARCOAT_TINT: boolean;
  48508. CLEARCOAT_TINT_TEXTURE: boolean;
  48509. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48510. ANISOTROPIC: boolean;
  48511. ANISOTROPIC_TEXTURE: boolean;
  48512. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48513. BRDF_V_HEIGHT_CORRELATED: boolean;
  48514. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48515. SHEEN: boolean;
  48516. SHEEN_TEXTURE: boolean;
  48517. SHEEN_TEXTUREDIRECTUV: number;
  48518. SHEEN_LINKWITHALBEDO: boolean;
  48519. SUBSURFACE: boolean;
  48520. SS_REFRACTION: boolean;
  48521. SS_TRANSLUCENCY: boolean;
  48522. SS_SCATERRING: boolean;
  48523. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48524. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48525. SS_REFRACTIONMAP_3D: boolean;
  48526. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48527. SS_LODINREFRACTIONALPHA: boolean;
  48528. SS_GAMMAREFRACTION: boolean;
  48529. SS_RGBDREFRACTION: boolean;
  48530. SS_LINEARSPECULARREFRACTION: boolean;
  48531. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48532. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48533. UNLIT: boolean;
  48534. DEBUGMODE: number;
  48535. /**
  48536. * Initializes the PBR Material defines.
  48537. */
  48538. constructor();
  48539. /**
  48540. * Resets the PBR Material defines.
  48541. */
  48542. reset(): void;
  48543. }
  48544. /**
  48545. * The Physically based material base class of BJS.
  48546. *
  48547. * This offers the main features of a standard PBR material.
  48548. * For more information, please refer to the documentation :
  48549. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48550. */
  48551. export abstract class PBRBaseMaterial extends PushMaterial {
  48552. /**
  48553. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48554. */
  48555. static readonly PBRMATERIAL_OPAQUE: number;
  48556. /**
  48557. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48558. */
  48559. static readonly PBRMATERIAL_ALPHATEST: number;
  48560. /**
  48561. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48562. */
  48563. static readonly PBRMATERIAL_ALPHABLEND: number;
  48564. /**
  48565. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48566. * They are also discarded below the alpha cutoff threshold to improve performances.
  48567. */
  48568. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48569. /**
  48570. * Defines the default value of how much AO map is occluding the analytical lights
  48571. * (point spot...).
  48572. */
  48573. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48574. /**
  48575. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48576. */
  48577. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48578. /**
  48579. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48580. * to enhance interoperability with other engines.
  48581. */
  48582. static readonly LIGHTFALLOFF_GLTF: number;
  48583. /**
  48584. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48585. * to enhance interoperability with other materials.
  48586. */
  48587. static readonly LIGHTFALLOFF_STANDARD: number;
  48588. /**
  48589. * Intensity of the direct lights e.g. the four lights available in your scene.
  48590. * This impacts both the direct diffuse and specular highlights.
  48591. */
  48592. protected _directIntensity: number;
  48593. /**
  48594. * Intensity of the emissive part of the material.
  48595. * This helps controlling the emissive effect without modifying the emissive color.
  48596. */
  48597. protected _emissiveIntensity: number;
  48598. /**
  48599. * Intensity of the environment e.g. how much the environment will light the object
  48600. * either through harmonics for rough material or through the refelction for shiny ones.
  48601. */
  48602. protected _environmentIntensity: number;
  48603. /**
  48604. * This is a special control allowing the reduction of the specular highlights coming from the
  48605. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48606. */
  48607. protected _specularIntensity: number;
  48608. /**
  48609. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48610. */
  48611. private _lightingInfos;
  48612. /**
  48613. * Debug Control allowing disabling the bump map on this material.
  48614. */
  48615. protected _disableBumpMap: boolean;
  48616. /**
  48617. * AKA Diffuse Texture in standard nomenclature.
  48618. */
  48619. protected _albedoTexture: Nullable<BaseTexture>;
  48620. /**
  48621. * AKA Occlusion Texture in other nomenclature.
  48622. */
  48623. protected _ambientTexture: Nullable<BaseTexture>;
  48624. /**
  48625. * AKA Occlusion Texture Intensity in other nomenclature.
  48626. */
  48627. protected _ambientTextureStrength: number;
  48628. /**
  48629. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48630. * 1 means it completely occludes it
  48631. * 0 mean it has no impact
  48632. */
  48633. protected _ambientTextureImpactOnAnalyticalLights: number;
  48634. /**
  48635. * Stores the alpha values in a texture.
  48636. */
  48637. protected _opacityTexture: Nullable<BaseTexture>;
  48638. /**
  48639. * Stores the reflection values in a texture.
  48640. */
  48641. protected _reflectionTexture: Nullable<BaseTexture>;
  48642. /**
  48643. * Stores the emissive values in a texture.
  48644. */
  48645. protected _emissiveTexture: Nullable<BaseTexture>;
  48646. /**
  48647. * AKA Specular texture in other nomenclature.
  48648. */
  48649. protected _reflectivityTexture: Nullable<BaseTexture>;
  48650. /**
  48651. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48652. */
  48653. protected _metallicTexture: Nullable<BaseTexture>;
  48654. /**
  48655. * Specifies the metallic scalar of the metallic/roughness workflow.
  48656. * Can also be used to scale the metalness values of the metallic texture.
  48657. */
  48658. protected _metallic: Nullable<number>;
  48659. /**
  48660. * Specifies the roughness scalar of the metallic/roughness workflow.
  48661. * Can also be used to scale the roughness values of the metallic texture.
  48662. */
  48663. protected _roughness: Nullable<number>;
  48664. /**
  48665. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48666. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48667. */
  48668. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48669. /**
  48670. * Stores surface normal data used to displace a mesh in a texture.
  48671. */
  48672. protected _bumpTexture: Nullable<BaseTexture>;
  48673. /**
  48674. * Stores the pre-calculated light information of a mesh in a texture.
  48675. */
  48676. protected _lightmapTexture: Nullable<BaseTexture>;
  48677. /**
  48678. * The color of a material in ambient lighting.
  48679. */
  48680. protected _ambientColor: Color3;
  48681. /**
  48682. * AKA Diffuse Color in other nomenclature.
  48683. */
  48684. protected _albedoColor: Color3;
  48685. /**
  48686. * AKA Specular Color in other nomenclature.
  48687. */
  48688. protected _reflectivityColor: Color3;
  48689. /**
  48690. * The color applied when light is reflected from a material.
  48691. */
  48692. protected _reflectionColor: Color3;
  48693. /**
  48694. * The color applied when light is emitted from a material.
  48695. */
  48696. protected _emissiveColor: Color3;
  48697. /**
  48698. * AKA Glossiness in other nomenclature.
  48699. */
  48700. protected _microSurface: number;
  48701. /**
  48702. * Specifies that the material will use the light map as a show map.
  48703. */
  48704. protected _useLightmapAsShadowmap: boolean;
  48705. /**
  48706. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48707. * makes the reflect vector face the model (under horizon).
  48708. */
  48709. protected _useHorizonOcclusion: boolean;
  48710. /**
  48711. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48712. * too much the area relying on ambient texture to define their ambient occlusion.
  48713. */
  48714. protected _useRadianceOcclusion: boolean;
  48715. /**
  48716. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48717. */
  48718. protected _useAlphaFromAlbedoTexture: boolean;
  48719. /**
  48720. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48721. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48722. */
  48723. protected _useSpecularOverAlpha: boolean;
  48724. /**
  48725. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48726. */
  48727. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48728. /**
  48729. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48730. */
  48731. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48732. /**
  48733. * Specifies if the metallic texture contains the roughness information in its green channel.
  48734. */
  48735. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48736. /**
  48737. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48738. */
  48739. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48740. /**
  48741. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48742. */
  48743. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48744. /**
  48745. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48746. */
  48747. protected _useAmbientInGrayScale: boolean;
  48748. /**
  48749. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48750. * The material will try to infer what glossiness each pixel should be.
  48751. */
  48752. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48753. /**
  48754. * Defines the falloff type used in this material.
  48755. * It by default is Physical.
  48756. */
  48757. protected _lightFalloff: number;
  48758. /**
  48759. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48760. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48761. */
  48762. protected _useRadianceOverAlpha: boolean;
  48763. /**
  48764. * Allows using an object space normal map (instead of tangent space).
  48765. */
  48766. protected _useObjectSpaceNormalMap: boolean;
  48767. /**
  48768. * Allows using the bump map in parallax mode.
  48769. */
  48770. protected _useParallax: boolean;
  48771. /**
  48772. * Allows using the bump map in parallax occlusion mode.
  48773. */
  48774. protected _useParallaxOcclusion: boolean;
  48775. /**
  48776. * Controls the scale bias of the parallax mode.
  48777. */
  48778. protected _parallaxScaleBias: number;
  48779. /**
  48780. * If sets to true, disables all the lights affecting the material.
  48781. */
  48782. protected _disableLighting: boolean;
  48783. /**
  48784. * Number of Simultaneous lights allowed on the material.
  48785. */
  48786. protected _maxSimultaneousLights: number;
  48787. /**
  48788. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48789. */
  48790. protected _invertNormalMapX: boolean;
  48791. /**
  48792. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48793. */
  48794. protected _invertNormalMapY: boolean;
  48795. /**
  48796. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48797. */
  48798. protected _twoSidedLighting: boolean;
  48799. /**
  48800. * Defines the alpha limits in alpha test mode.
  48801. */
  48802. protected _alphaCutOff: number;
  48803. /**
  48804. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48805. */
  48806. protected _forceAlphaTest: boolean;
  48807. /**
  48808. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48809. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48810. */
  48811. protected _useAlphaFresnel: boolean;
  48812. /**
  48813. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48814. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48815. */
  48816. protected _useLinearAlphaFresnel: boolean;
  48817. /**
  48818. * The transparency mode of the material.
  48819. */
  48820. protected _transparencyMode: Nullable<number>;
  48821. /**
  48822. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48823. * from cos thetav and roughness:
  48824. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48825. */
  48826. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48827. /**
  48828. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48829. */
  48830. protected _forceIrradianceInFragment: boolean;
  48831. /**
  48832. * Force normal to face away from face.
  48833. */
  48834. protected _forceNormalForward: boolean;
  48835. /**
  48836. * Enables specular anti aliasing in the PBR shader.
  48837. * It will both interacts on the Geometry for analytical and IBL lighting.
  48838. * It also prefilter the roughness map based on the bump values.
  48839. */
  48840. protected _enableSpecularAntiAliasing: boolean;
  48841. /**
  48842. * Default configuration related to image processing available in the PBR Material.
  48843. */
  48844. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48845. /**
  48846. * Keep track of the image processing observer to allow dispose and replace.
  48847. */
  48848. private _imageProcessingObserver;
  48849. /**
  48850. * Attaches a new image processing configuration to the PBR Material.
  48851. * @param configuration
  48852. */
  48853. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48854. /**
  48855. * Stores the available render targets.
  48856. */
  48857. private _renderTargets;
  48858. /**
  48859. * Sets the global ambient color for the material used in lighting calculations.
  48860. */
  48861. private _globalAmbientColor;
  48862. /**
  48863. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48864. */
  48865. private _useLogarithmicDepth;
  48866. /**
  48867. * If set to true, no lighting calculations will be applied.
  48868. */
  48869. private _unlit;
  48870. private _debugMode;
  48871. /**
  48872. * @hidden
  48873. * This is reserved for the inspector.
  48874. * Defines the material debug mode.
  48875. * It helps seeing only some components of the material while troubleshooting.
  48876. */
  48877. debugMode: number;
  48878. /**
  48879. * @hidden
  48880. * This is reserved for the inspector.
  48881. * Specify from where on screen the debug mode should start.
  48882. * The value goes from -1 (full screen) to 1 (not visible)
  48883. * It helps with side by side comparison against the final render
  48884. * This defaults to -1
  48885. */
  48886. private debugLimit;
  48887. /**
  48888. * @hidden
  48889. * This is reserved for the inspector.
  48890. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48891. * You can use the factor to better multiply the final value.
  48892. */
  48893. private debugFactor;
  48894. /**
  48895. * Defines the clear coat layer parameters for the material.
  48896. */
  48897. readonly clearCoat: PBRClearCoatConfiguration;
  48898. /**
  48899. * Defines the anisotropic parameters for the material.
  48900. */
  48901. readonly anisotropy: PBRAnisotropicConfiguration;
  48902. /**
  48903. * Defines the BRDF parameters for the material.
  48904. */
  48905. readonly brdf: PBRBRDFConfiguration;
  48906. /**
  48907. * Defines the Sheen parameters for the material.
  48908. */
  48909. readonly sheen: PBRSheenConfiguration;
  48910. /**
  48911. * Defines the SubSurface parameters for the material.
  48912. */
  48913. readonly subSurface: PBRSubSurfaceConfiguration;
  48914. /**
  48915. * Custom callback helping to override the default shader used in the material.
  48916. */
  48917. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48918. protected _rebuildInParallel: boolean;
  48919. /**
  48920. * Instantiates a new PBRMaterial instance.
  48921. *
  48922. * @param name The material name
  48923. * @param scene The scene the material will be use in.
  48924. */
  48925. constructor(name: string, scene: Scene);
  48926. /**
  48927. * Gets a boolean indicating that current material needs to register RTT
  48928. */
  48929. readonly hasRenderTargetTextures: boolean;
  48930. /**
  48931. * Gets the name of the material class.
  48932. */
  48933. getClassName(): string;
  48934. /**
  48935. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48936. */
  48937. /**
  48938. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48939. */
  48940. useLogarithmicDepth: boolean;
  48941. /**
  48942. * Gets the current transparency mode.
  48943. */
  48944. /**
  48945. * Sets the transparency mode of the material.
  48946. *
  48947. * | Value | Type | Description |
  48948. * | ----- | ----------------------------------- | ----------- |
  48949. * | 0 | OPAQUE | |
  48950. * | 1 | ALPHATEST | |
  48951. * | 2 | ALPHABLEND | |
  48952. * | 3 | ALPHATESTANDBLEND | |
  48953. *
  48954. */
  48955. transparencyMode: Nullable<number>;
  48956. /**
  48957. * Returns true if alpha blending should be disabled.
  48958. */
  48959. private readonly _disableAlphaBlending;
  48960. /**
  48961. * Specifies whether or not this material should be rendered in alpha blend mode.
  48962. */
  48963. needAlphaBlending(): boolean;
  48964. /**
  48965. * Specifies if the mesh will require alpha blending.
  48966. * @param mesh - BJS mesh.
  48967. */
  48968. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48969. /**
  48970. * Specifies whether or not this material should be rendered in alpha test mode.
  48971. */
  48972. needAlphaTesting(): boolean;
  48973. /**
  48974. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48975. */
  48976. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48977. /**
  48978. * Gets the texture used for the alpha test.
  48979. */
  48980. getAlphaTestTexture(): Nullable<BaseTexture>;
  48981. /**
  48982. * Specifies that the submesh is ready to be used.
  48983. * @param mesh - BJS mesh.
  48984. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48985. * @param useInstances - Specifies that instances should be used.
  48986. * @returns - boolean indicating that the submesh is ready or not.
  48987. */
  48988. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48989. /**
  48990. * Specifies if the material uses metallic roughness workflow.
  48991. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48992. */
  48993. isMetallicWorkflow(): boolean;
  48994. private _prepareEffect;
  48995. private _prepareDefines;
  48996. /**
  48997. * Force shader compilation
  48998. */
  48999. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49000. clipPlane: boolean;
  49001. }>): void;
  49002. /**
  49003. * Initializes the uniform buffer layout for the shader.
  49004. */
  49005. buildUniformLayout(): void;
  49006. /**
  49007. * Unbinds the material from the mesh
  49008. */
  49009. unbind(): void;
  49010. /**
  49011. * Binds the submesh data.
  49012. * @param world - The world matrix.
  49013. * @param mesh - The BJS mesh.
  49014. * @param subMesh - A submesh of the BJS mesh.
  49015. */
  49016. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49017. /**
  49018. * Returns the animatable textures.
  49019. * @returns - Array of animatable textures.
  49020. */
  49021. getAnimatables(): IAnimatable[];
  49022. /**
  49023. * Returns the texture used for reflections.
  49024. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49025. */
  49026. private _getReflectionTexture;
  49027. /**
  49028. * Returns an array of the actively used textures.
  49029. * @returns - Array of BaseTextures
  49030. */
  49031. getActiveTextures(): BaseTexture[];
  49032. /**
  49033. * Checks to see if a texture is used in the material.
  49034. * @param texture - Base texture to use.
  49035. * @returns - Boolean specifying if a texture is used in the material.
  49036. */
  49037. hasTexture(texture: BaseTexture): boolean;
  49038. /**
  49039. * Disposes the resources of the material.
  49040. * @param forceDisposeEffect - Forces the disposal of effects.
  49041. * @param forceDisposeTextures - Forces the disposal of all textures.
  49042. */
  49043. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49044. }
  49045. }
  49046. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49047. import { Nullable } from "babylonjs/types";
  49048. import { Scene } from "babylonjs/scene";
  49049. import { Color3 } from "babylonjs/Maths/math.color";
  49050. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49051. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49053. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49054. /**
  49055. * The Physically based material of BJS.
  49056. *
  49057. * This offers the main features of a standard PBR material.
  49058. * For more information, please refer to the documentation :
  49059. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49060. */
  49061. export class PBRMaterial extends PBRBaseMaterial {
  49062. /**
  49063. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49064. */
  49065. static readonly PBRMATERIAL_OPAQUE: number;
  49066. /**
  49067. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49068. */
  49069. static readonly PBRMATERIAL_ALPHATEST: number;
  49070. /**
  49071. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49072. */
  49073. static readonly PBRMATERIAL_ALPHABLEND: number;
  49074. /**
  49075. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49076. * They are also discarded below the alpha cutoff threshold to improve performances.
  49077. */
  49078. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49079. /**
  49080. * Defines the default value of how much AO map is occluding the analytical lights
  49081. * (point spot...).
  49082. */
  49083. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49084. /**
  49085. * Intensity of the direct lights e.g. the four lights available in your scene.
  49086. * This impacts both the direct diffuse and specular highlights.
  49087. */
  49088. directIntensity: number;
  49089. /**
  49090. * Intensity of the emissive part of the material.
  49091. * This helps controlling the emissive effect without modifying the emissive color.
  49092. */
  49093. emissiveIntensity: number;
  49094. /**
  49095. * Intensity of the environment e.g. how much the environment will light the object
  49096. * either through harmonics for rough material or through the refelction for shiny ones.
  49097. */
  49098. environmentIntensity: number;
  49099. /**
  49100. * This is a special control allowing the reduction of the specular highlights coming from the
  49101. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49102. */
  49103. specularIntensity: number;
  49104. /**
  49105. * Debug Control allowing disabling the bump map on this material.
  49106. */
  49107. disableBumpMap: boolean;
  49108. /**
  49109. * AKA Diffuse Texture in standard nomenclature.
  49110. */
  49111. albedoTexture: BaseTexture;
  49112. /**
  49113. * AKA Occlusion Texture in other nomenclature.
  49114. */
  49115. ambientTexture: BaseTexture;
  49116. /**
  49117. * AKA Occlusion Texture Intensity in other nomenclature.
  49118. */
  49119. ambientTextureStrength: number;
  49120. /**
  49121. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49122. * 1 means it completely occludes it
  49123. * 0 mean it has no impact
  49124. */
  49125. ambientTextureImpactOnAnalyticalLights: number;
  49126. /**
  49127. * Stores the alpha values in a texture.
  49128. */
  49129. opacityTexture: BaseTexture;
  49130. /**
  49131. * Stores the reflection values in a texture.
  49132. */
  49133. reflectionTexture: Nullable<BaseTexture>;
  49134. /**
  49135. * Stores the emissive values in a texture.
  49136. */
  49137. emissiveTexture: BaseTexture;
  49138. /**
  49139. * AKA Specular texture in other nomenclature.
  49140. */
  49141. reflectivityTexture: BaseTexture;
  49142. /**
  49143. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49144. */
  49145. metallicTexture: BaseTexture;
  49146. /**
  49147. * Specifies the metallic scalar of the metallic/roughness workflow.
  49148. * Can also be used to scale the metalness values of the metallic texture.
  49149. */
  49150. metallic: Nullable<number>;
  49151. /**
  49152. * Specifies the roughness scalar of the metallic/roughness workflow.
  49153. * Can also be used to scale the roughness values of the metallic texture.
  49154. */
  49155. roughness: Nullable<number>;
  49156. /**
  49157. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49158. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49159. */
  49160. microSurfaceTexture: BaseTexture;
  49161. /**
  49162. * Stores surface normal data used to displace a mesh in a texture.
  49163. */
  49164. bumpTexture: BaseTexture;
  49165. /**
  49166. * Stores the pre-calculated light information of a mesh in a texture.
  49167. */
  49168. lightmapTexture: BaseTexture;
  49169. /**
  49170. * Stores the refracted light information in a texture.
  49171. */
  49172. refractionTexture: Nullable<BaseTexture>;
  49173. /**
  49174. * The color of a material in ambient lighting.
  49175. */
  49176. ambientColor: Color3;
  49177. /**
  49178. * AKA Diffuse Color in other nomenclature.
  49179. */
  49180. albedoColor: Color3;
  49181. /**
  49182. * AKA Specular Color in other nomenclature.
  49183. */
  49184. reflectivityColor: Color3;
  49185. /**
  49186. * The color reflected from the material.
  49187. */
  49188. reflectionColor: Color3;
  49189. /**
  49190. * The color emitted from the material.
  49191. */
  49192. emissiveColor: Color3;
  49193. /**
  49194. * AKA Glossiness in other nomenclature.
  49195. */
  49196. microSurface: number;
  49197. /**
  49198. * source material index of refraction (IOR)' / 'destination material IOR.
  49199. */
  49200. indexOfRefraction: number;
  49201. /**
  49202. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49203. */
  49204. invertRefractionY: boolean;
  49205. /**
  49206. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49207. * Materials half opaque for instance using refraction could benefit from this control.
  49208. */
  49209. linkRefractionWithTransparency: boolean;
  49210. /**
  49211. * If true, the light map contains occlusion information instead of lighting info.
  49212. */
  49213. useLightmapAsShadowmap: boolean;
  49214. /**
  49215. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49216. */
  49217. useAlphaFromAlbedoTexture: boolean;
  49218. /**
  49219. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49220. */
  49221. forceAlphaTest: boolean;
  49222. /**
  49223. * Defines the alpha limits in alpha test mode.
  49224. */
  49225. alphaCutOff: number;
  49226. /**
  49227. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49228. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49229. */
  49230. useSpecularOverAlpha: boolean;
  49231. /**
  49232. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49233. */
  49234. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49235. /**
  49236. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49237. */
  49238. useRoughnessFromMetallicTextureAlpha: boolean;
  49239. /**
  49240. * Specifies if the metallic texture contains the roughness information in its green channel.
  49241. */
  49242. useRoughnessFromMetallicTextureGreen: boolean;
  49243. /**
  49244. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49245. */
  49246. useMetallnessFromMetallicTextureBlue: boolean;
  49247. /**
  49248. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49249. */
  49250. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49251. /**
  49252. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49253. */
  49254. useAmbientInGrayScale: boolean;
  49255. /**
  49256. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49257. * The material will try to infer what glossiness each pixel should be.
  49258. */
  49259. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49260. /**
  49261. * BJS is using an harcoded light falloff based on a manually sets up range.
  49262. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49263. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49264. */
  49265. /**
  49266. * BJS is using an harcoded light falloff based on a manually sets up range.
  49267. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49268. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49269. */
  49270. usePhysicalLightFalloff: boolean;
  49271. /**
  49272. * In order to support the falloff compatibility with gltf, a special mode has been added
  49273. * to reproduce the gltf light falloff.
  49274. */
  49275. /**
  49276. * In order to support the falloff compatibility with gltf, a special mode has been added
  49277. * to reproduce the gltf light falloff.
  49278. */
  49279. useGLTFLightFalloff: boolean;
  49280. /**
  49281. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49282. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49283. */
  49284. useRadianceOverAlpha: boolean;
  49285. /**
  49286. * Allows using an object space normal map (instead of tangent space).
  49287. */
  49288. useObjectSpaceNormalMap: boolean;
  49289. /**
  49290. * Allows using the bump map in parallax mode.
  49291. */
  49292. useParallax: boolean;
  49293. /**
  49294. * Allows using the bump map in parallax occlusion mode.
  49295. */
  49296. useParallaxOcclusion: boolean;
  49297. /**
  49298. * Controls the scale bias of the parallax mode.
  49299. */
  49300. parallaxScaleBias: number;
  49301. /**
  49302. * If sets to true, disables all the lights affecting the material.
  49303. */
  49304. disableLighting: boolean;
  49305. /**
  49306. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49307. */
  49308. forceIrradianceInFragment: boolean;
  49309. /**
  49310. * Number of Simultaneous lights allowed on the material.
  49311. */
  49312. maxSimultaneousLights: number;
  49313. /**
  49314. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49315. */
  49316. invertNormalMapX: boolean;
  49317. /**
  49318. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49319. */
  49320. invertNormalMapY: boolean;
  49321. /**
  49322. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49323. */
  49324. twoSidedLighting: boolean;
  49325. /**
  49326. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49327. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49328. */
  49329. useAlphaFresnel: boolean;
  49330. /**
  49331. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49332. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49333. */
  49334. useLinearAlphaFresnel: boolean;
  49335. /**
  49336. * Let user defines the brdf lookup texture used for IBL.
  49337. * A default 8bit version is embedded but you could point at :
  49338. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49339. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49340. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49341. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49342. */
  49343. environmentBRDFTexture: Nullable<BaseTexture>;
  49344. /**
  49345. * Force normal to face away from face.
  49346. */
  49347. forceNormalForward: boolean;
  49348. /**
  49349. * Enables specular anti aliasing in the PBR shader.
  49350. * It will both interacts on the Geometry for analytical and IBL lighting.
  49351. * It also prefilter the roughness map based on the bump values.
  49352. */
  49353. enableSpecularAntiAliasing: boolean;
  49354. /**
  49355. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49356. * makes the reflect vector face the model (under horizon).
  49357. */
  49358. useHorizonOcclusion: boolean;
  49359. /**
  49360. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49361. * too much the area relying on ambient texture to define their ambient occlusion.
  49362. */
  49363. useRadianceOcclusion: boolean;
  49364. /**
  49365. * If set to true, no lighting calculations will be applied.
  49366. */
  49367. unlit: boolean;
  49368. /**
  49369. * Gets the image processing configuration used either in this material.
  49370. */
  49371. /**
  49372. * Sets the Default image processing configuration used either in the this material.
  49373. *
  49374. * If sets to null, the scene one is in use.
  49375. */
  49376. imageProcessingConfiguration: ImageProcessingConfiguration;
  49377. /**
  49378. * Gets wether the color curves effect is enabled.
  49379. */
  49380. /**
  49381. * Sets wether the color curves effect is enabled.
  49382. */
  49383. cameraColorCurvesEnabled: boolean;
  49384. /**
  49385. * Gets wether the color grading effect is enabled.
  49386. */
  49387. /**
  49388. * Gets wether the color grading effect is enabled.
  49389. */
  49390. cameraColorGradingEnabled: boolean;
  49391. /**
  49392. * Gets wether tonemapping is enabled or not.
  49393. */
  49394. /**
  49395. * Sets wether tonemapping is enabled or not
  49396. */
  49397. cameraToneMappingEnabled: boolean;
  49398. /**
  49399. * The camera exposure used on this material.
  49400. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49401. * This corresponds to a photographic exposure.
  49402. */
  49403. /**
  49404. * The camera exposure used on this material.
  49405. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49406. * This corresponds to a photographic exposure.
  49407. */
  49408. cameraExposure: number;
  49409. /**
  49410. * Gets The camera contrast used on this material.
  49411. */
  49412. /**
  49413. * Sets The camera contrast used on this material.
  49414. */
  49415. cameraContrast: number;
  49416. /**
  49417. * Gets the Color Grading 2D Lookup Texture.
  49418. */
  49419. /**
  49420. * Sets the Color Grading 2D Lookup Texture.
  49421. */
  49422. cameraColorGradingTexture: Nullable<BaseTexture>;
  49423. /**
  49424. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49425. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49426. * 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;
  49427. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49428. */
  49429. /**
  49430. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49431. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49432. * 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;
  49433. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49434. */
  49435. cameraColorCurves: Nullable<ColorCurves>;
  49436. /**
  49437. * Instantiates a new PBRMaterial instance.
  49438. *
  49439. * @param name The material name
  49440. * @param scene The scene the material will be use in.
  49441. */
  49442. constructor(name: string, scene: Scene);
  49443. /**
  49444. * Returns the name of this material class.
  49445. */
  49446. getClassName(): string;
  49447. /**
  49448. * Makes a duplicate of the current material.
  49449. * @param name - name to use for the new material.
  49450. */
  49451. clone(name: string): PBRMaterial;
  49452. /**
  49453. * Serializes this PBR Material.
  49454. * @returns - An object with the serialized material.
  49455. */
  49456. serialize(): any;
  49457. /**
  49458. * Parses a PBR Material from a serialized object.
  49459. * @param source - Serialized object.
  49460. * @param scene - BJS scene instance.
  49461. * @param rootUrl - url for the scene object
  49462. * @returns - PBRMaterial
  49463. */
  49464. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49465. }
  49466. }
  49467. declare module "babylonjs/Misc/dds" {
  49468. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49469. import { Engine } from "babylonjs/Engines/engine";
  49470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49471. import { Nullable } from "babylonjs/types";
  49472. import { Scene } from "babylonjs/scene";
  49473. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49474. /**
  49475. * Direct draw surface info
  49476. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49477. */
  49478. export interface DDSInfo {
  49479. /**
  49480. * Width of the texture
  49481. */
  49482. width: number;
  49483. /**
  49484. * Width of the texture
  49485. */
  49486. height: number;
  49487. /**
  49488. * Number of Mipmaps for the texture
  49489. * @see https://en.wikipedia.org/wiki/Mipmap
  49490. */
  49491. mipmapCount: number;
  49492. /**
  49493. * If the textures format is a known fourCC format
  49494. * @see https://www.fourcc.org/
  49495. */
  49496. isFourCC: boolean;
  49497. /**
  49498. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49499. */
  49500. isRGB: boolean;
  49501. /**
  49502. * If the texture is a lumincance format
  49503. */
  49504. isLuminance: boolean;
  49505. /**
  49506. * If this is a cube texture
  49507. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49508. */
  49509. isCube: boolean;
  49510. /**
  49511. * If the texture is a compressed format eg. FOURCC_DXT1
  49512. */
  49513. isCompressed: boolean;
  49514. /**
  49515. * The dxgiFormat of the texture
  49516. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49517. */
  49518. dxgiFormat: number;
  49519. /**
  49520. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49521. */
  49522. textureType: number;
  49523. /**
  49524. * Sphericle polynomial created for the dds texture
  49525. */
  49526. sphericalPolynomial?: SphericalPolynomial;
  49527. }
  49528. /**
  49529. * Class used to provide DDS decompression tools
  49530. */
  49531. export class DDSTools {
  49532. /**
  49533. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49534. */
  49535. static StoreLODInAlphaChannel: boolean;
  49536. /**
  49537. * Gets DDS information from an array buffer
  49538. * @param arrayBuffer defines the array buffer to read data from
  49539. * @returns the DDS information
  49540. */
  49541. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49542. private static _FloatView;
  49543. private static _Int32View;
  49544. private static _ToHalfFloat;
  49545. private static _FromHalfFloat;
  49546. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49547. private static _GetHalfFloatRGBAArrayBuffer;
  49548. private static _GetFloatRGBAArrayBuffer;
  49549. private static _GetFloatAsUIntRGBAArrayBuffer;
  49550. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49551. private static _GetRGBAArrayBuffer;
  49552. private static _ExtractLongWordOrder;
  49553. private static _GetRGBArrayBuffer;
  49554. private static _GetLuminanceArrayBuffer;
  49555. /**
  49556. * Uploads DDS Levels to a Babylon Texture
  49557. * @hidden
  49558. */
  49559. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49560. }
  49561. module "babylonjs/Engines/engine" {
  49562. interface Engine {
  49563. /**
  49564. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49565. * @param rootUrl defines the url where the file to load is located
  49566. * @param scene defines the current scene
  49567. * @param lodScale defines scale to apply to the mip map selection
  49568. * @param lodOffset defines offset to apply to the mip map selection
  49569. * @param onLoad defines an optional callback raised when the texture is loaded
  49570. * @param onError defines an optional callback raised if there is an issue to load the texture
  49571. * @param format defines the format of the data
  49572. * @param forcedExtension defines the extension to use to pick the right loader
  49573. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49574. * @returns the cube texture as an InternalTexture
  49575. */
  49576. 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;
  49577. }
  49578. }
  49579. }
  49580. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49581. import { Nullable } from "babylonjs/types";
  49582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49583. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49584. /**
  49585. * Implementation of the DDS Texture Loader.
  49586. * @hidden
  49587. */
  49588. export class _DDSTextureLoader implements IInternalTextureLoader {
  49589. /**
  49590. * Defines wether the loader supports cascade loading the different faces.
  49591. */
  49592. readonly supportCascades: boolean;
  49593. /**
  49594. * This returns if the loader support the current file information.
  49595. * @param extension defines the file extension of the file being loaded
  49596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49597. * @param fallback defines the fallback internal texture if any
  49598. * @param isBase64 defines whether the texture is encoded as a base64
  49599. * @param isBuffer defines whether the texture data are stored as a buffer
  49600. * @returns true if the loader can load the specified file
  49601. */
  49602. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49603. /**
  49604. * Transform the url before loading if required.
  49605. * @param rootUrl the url of the texture
  49606. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49607. * @returns the transformed texture
  49608. */
  49609. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49610. /**
  49611. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49612. * @param rootUrl the url of the texture
  49613. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49614. * @returns the fallback texture
  49615. */
  49616. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49617. /**
  49618. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49619. * @param data contains the texture data
  49620. * @param texture defines the BabylonJS internal texture
  49621. * @param createPolynomials will be true if polynomials have been requested
  49622. * @param onLoad defines the callback to trigger once the texture is ready
  49623. * @param onError defines the callback to trigger in case of error
  49624. */
  49625. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49626. /**
  49627. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49628. * @param data contains the texture data
  49629. * @param texture defines the BabylonJS internal texture
  49630. * @param callback defines the method to call once ready to upload
  49631. */
  49632. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49633. }
  49634. }
  49635. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49636. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49637. /** @hidden */
  49638. export var rgbdEncodePixelShader: {
  49639. name: string;
  49640. shader: string;
  49641. };
  49642. }
  49643. declare module "babylonjs/Misc/environmentTextureTools" {
  49644. import { Nullable } from "babylonjs/types";
  49645. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49646. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49647. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49648. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49649. import "babylonjs/Shaders/rgbdEncode.fragment";
  49650. import "babylonjs/Shaders/rgbdDecode.fragment";
  49651. /**
  49652. * Raw texture data and descriptor sufficient for WebGL texture upload
  49653. */
  49654. export interface EnvironmentTextureInfo {
  49655. /**
  49656. * Version of the environment map
  49657. */
  49658. version: number;
  49659. /**
  49660. * Width of image
  49661. */
  49662. width: number;
  49663. /**
  49664. * Irradiance information stored in the file.
  49665. */
  49666. irradiance: any;
  49667. /**
  49668. * Specular information stored in the file.
  49669. */
  49670. specular: any;
  49671. }
  49672. /**
  49673. * Sets of helpers addressing the serialization and deserialization of environment texture
  49674. * stored in a BabylonJS env file.
  49675. * Those files are usually stored as .env files.
  49676. */
  49677. export class EnvironmentTextureTools {
  49678. /**
  49679. * Magic number identifying the env file.
  49680. */
  49681. private static _MagicBytes;
  49682. /**
  49683. * Gets the environment info from an env file.
  49684. * @param data The array buffer containing the .env bytes.
  49685. * @returns the environment file info (the json header) if successfully parsed.
  49686. */
  49687. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49688. /**
  49689. * Creates an environment texture from a loaded cube texture.
  49690. * @param texture defines the cube texture to convert in env file
  49691. * @return a promise containing the environment data if succesfull.
  49692. */
  49693. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49694. /**
  49695. * Creates a JSON representation of the spherical data.
  49696. * @param texture defines the texture containing the polynomials
  49697. * @return the JSON representation of the spherical info
  49698. */
  49699. private static _CreateEnvTextureIrradiance;
  49700. /**
  49701. * Uploads the texture info contained in the env file to the GPU.
  49702. * @param texture defines the internal texture to upload to
  49703. * @param arrayBuffer defines the buffer cotaining the data to load
  49704. * @param info defines the texture info retrieved through the GetEnvInfo method
  49705. * @returns a promise
  49706. */
  49707. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49708. /**
  49709. * Uploads the levels of image data to the GPU.
  49710. * @param texture defines the internal texture to upload to
  49711. * @param imageData defines the array buffer views of image data [mipmap][face]
  49712. * @returns a promise
  49713. */
  49714. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49715. /**
  49716. * Uploads spherical polynomials information to the texture.
  49717. * @param texture defines the texture we are trying to upload the information to
  49718. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49719. */
  49720. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49721. /** @hidden */
  49722. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49723. }
  49724. }
  49725. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49726. import { Nullable } from "babylonjs/types";
  49727. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49728. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49729. /**
  49730. * Implementation of the ENV Texture Loader.
  49731. * @hidden
  49732. */
  49733. export class _ENVTextureLoader implements IInternalTextureLoader {
  49734. /**
  49735. * Defines wether the loader supports cascade loading the different faces.
  49736. */
  49737. readonly supportCascades: boolean;
  49738. /**
  49739. * This returns if the loader support the current file information.
  49740. * @param extension defines the file extension of the file being loaded
  49741. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49742. * @param fallback defines the fallback internal texture if any
  49743. * @param isBase64 defines whether the texture is encoded as a base64
  49744. * @param isBuffer defines whether the texture data are stored as a buffer
  49745. * @returns true if the loader can load the specified file
  49746. */
  49747. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49748. /**
  49749. * Transform the url before loading if required.
  49750. * @param rootUrl the url of the texture
  49751. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49752. * @returns the transformed texture
  49753. */
  49754. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49755. /**
  49756. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49757. * @param rootUrl the url of the texture
  49758. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49759. * @returns the fallback texture
  49760. */
  49761. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49762. /**
  49763. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49764. * @param data contains the texture data
  49765. * @param texture defines the BabylonJS internal texture
  49766. * @param createPolynomials will be true if polynomials have been requested
  49767. * @param onLoad defines the callback to trigger once the texture is ready
  49768. * @param onError defines the callback to trigger in case of error
  49769. */
  49770. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49771. /**
  49772. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49773. * @param data contains the texture data
  49774. * @param texture defines the BabylonJS internal texture
  49775. * @param callback defines the method to call once ready to upload
  49776. */
  49777. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49778. }
  49779. }
  49780. declare module "babylonjs/Misc/khronosTextureContainer" {
  49781. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49782. /**
  49783. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49784. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49785. */
  49786. export class KhronosTextureContainer {
  49787. /** contents of the KTX container file */
  49788. arrayBuffer: any;
  49789. private static HEADER_LEN;
  49790. private static COMPRESSED_2D;
  49791. private static COMPRESSED_3D;
  49792. private static TEX_2D;
  49793. private static TEX_3D;
  49794. /**
  49795. * Gets the openGL type
  49796. */
  49797. glType: number;
  49798. /**
  49799. * Gets the openGL type size
  49800. */
  49801. glTypeSize: number;
  49802. /**
  49803. * Gets the openGL format
  49804. */
  49805. glFormat: number;
  49806. /**
  49807. * Gets the openGL internal format
  49808. */
  49809. glInternalFormat: number;
  49810. /**
  49811. * Gets the base internal format
  49812. */
  49813. glBaseInternalFormat: number;
  49814. /**
  49815. * Gets image width in pixel
  49816. */
  49817. pixelWidth: number;
  49818. /**
  49819. * Gets image height in pixel
  49820. */
  49821. pixelHeight: number;
  49822. /**
  49823. * Gets image depth in pixels
  49824. */
  49825. pixelDepth: number;
  49826. /**
  49827. * Gets the number of array elements
  49828. */
  49829. numberOfArrayElements: number;
  49830. /**
  49831. * Gets the number of faces
  49832. */
  49833. numberOfFaces: number;
  49834. /**
  49835. * Gets the number of mipmap levels
  49836. */
  49837. numberOfMipmapLevels: number;
  49838. /**
  49839. * Gets the bytes of key value data
  49840. */
  49841. bytesOfKeyValueData: number;
  49842. /**
  49843. * Gets the load type
  49844. */
  49845. loadType: number;
  49846. /**
  49847. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49848. */
  49849. isInvalid: boolean;
  49850. /**
  49851. * Creates a new KhronosTextureContainer
  49852. * @param arrayBuffer contents of the KTX container file
  49853. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49854. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49855. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49856. */
  49857. constructor(
  49858. /** contents of the KTX container file */
  49859. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49860. /**
  49861. * Uploads KTX content to a Babylon Texture.
  49862. * It is assumed that the texture has already been created & is currently bound
  49863. * @hidden
  49864. */
  49865. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49866. private _upload2DCompressedLevels;
  49867. }
  49868. }
  49869. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49870. import { Nullable } from "babylonjs/types";
  49871. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49872. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49873. /**
  49874. * Implementation of the KTX Texture Loader.
  49875. * @hidden
  49876. */
  49877. export class _KTXTextureLoader implements IInternalTextureLoader {
  49878. /**
  49879. * Defines wether the loader supports cascade loading the different faces.
  49880. */
  49881. readonly supportCascades: boolean;
  49882. /**
  49883. * This returns if the loader support the current file information.
  49884. * @param extension defines the file extension of the file being loaded
  49885. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49886. * @param fallback defines the fallback internal texture if any
  49887. * @param isBase64 defines whether the texture is encoded as a base64
  49888. * @param isBuffer defines whether the texture data are stored as a buffer
  49889. * @returns true if the loader can load the specified file
  49890. */
  49891. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49892. /**
  49893. * Transform the url before loading if required.
  49894. * @param rootUrl the url of the texture
  49895. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49896. * @returns the transformed texture
  49897. */
  49898. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49899. /**
  49900. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49901. * @param rootUrl the url of the texture
  49902. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49903. * @returns the fallback texture
  49904. */
  49905. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49906. /**
  49907. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49908. * @param data contains the texture data
  49909. * @param texture defines the BabylonJS internal texture
  49910. * @param createPolynomials will be true if polynomials have been requested
  49911. * @param onLoad defines the callback to trigger once the texture is ready
  49912. * @param onError defines the callback to trigger in case of error
  49913. */
  49914. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49915. /**
  49916. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49917. * @param data contains the texture data
  49918. * @param texture defines the BabylonJS internal texture
  49919. * @param callback defines the method to call once ready to upload
  49920. */
  49921. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49922. }
  49923. }
  49924. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49925. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49926. import { Scene } from "babylonjs/scene";
  49927. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49928. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49929. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49930. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49931. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49932. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49934. /**
  49935. * Options for the default xr helper
  49936. */
  49937. export class WebXRDefaultExperienceOptions {
  49938. /**
  49939. * Floor meshes that should be used for teleporting
  49940. */
  49941. floorMeshes: Array<AbstractMesh>;
  49942. }
  49943. /**
  49944. * Default experience which provides a similar setup to the previous webVRExperience
  49945. */
  49946. export class WebXRDefaultExperience {
  49947. /**
  49948. * Base experience
  49949. */
  49950. baseExperience: WebXRExperienceHelper;
  49951. /**
  49952. * Input experience extension
  49953. */
  49954. input: WebXRInput;
  49955. /**
  49956. * Loads the controller models
  49957. */
  49958. controllerModelLoader: WebXRControllerModelLoader;
  49959. /**
  49960. * Enables laser pointer and selection
  49961. */
  49962. pointerSelection: WebXRControllerPointerSelection;
  49963. /**
  49964. * Enables teleportation
  49965. */
  49966. teleportation: WebXRControllerTeleportation;
  49967. /**
  49968. * Enables ui for enetering/exiting xr
  49969. */
  49970. enterExitUI: WebXREnterExitUI;
  49971. /**
  49972. * Default output canvas xr should render to
  49973. */
  49974. outputCanvas: WebXRManagedOutputCanvas;
  49975. /**
  49976. * Creates the default xr experience
  49977. * @param scene scene
  49978. * @param options options for basic configuration
  49979. * @returns resulting WebXRDefaultExperience
  49980. */
  49981. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49982. private constructor();
  49983. /**
  49984. * DIsposes of the experience helper
  49985. */
  49986. dispose(): void;
  49987. }
  49988. }
  49989. declare module "babylonjs/Helpers/sceneHelpers" {
  49990. import { Nullable } from "babylonjs/types";
  49991. import { Mesh } from "babylonjs/Meshes/mesh";
  49992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49993. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49994. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49995. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49996. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49997. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49998. import "babylonjs/Meshes/Builders/boxBuilder";
  49999. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50000. /** @hidden */
  50001. export var _forceSceneHelpersToBundle: boolean;
  50002. module "babylonjs/scene" {
  50003. interface Scene {
  50004. /**
  50005. * Creates a default light for the scene.
  50006. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50007. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50008. */
  50009. createDefaultLight(replace?: boolean): void;
  50010. /**
  50011. * Creates a default camera for the scene.
  50012. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50013. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50014. * @param replace has default false, when true replaces the active camera in the scene
  50015. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50016. */
  50017. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50018. /**
  50019. * Creates a default camera and a default light.
  50020. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50021. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50022. * @param replace has the default false, when true replaces the active camera/light in the scene
  50023. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50024. */
  50025. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50026. /**
  50027. * Creates a new sky box
  50028. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50029. * @param environmentTexture defines the texture to use as environment texture
  50030. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50031. * @param scale defines the overall scale of the skybox
  50032. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50033. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50034. * @returns a new mesh holding the sky box
  50035. */
  50036. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50037. /**
  50038. * Creates a new environment
  50039. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50040. * @param options defines the options you can use to configure the environment
  50041. * @returns the new EnvironmentHelper
  50042. */
  50043. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50044. /**
  50045. * Creates a new VREXperienceHelper
  50046. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50047. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50048. * @returns a new VREXperienceHelper
  50049. */
  50050. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50051. /**
  50052. * Creates a new WebXRDefaultExperience
  50053. * @see http://doc.babylonjs.com/how_to/webxr
  50054. * @param options experience options
  50055. * @returns a promise for a new WebXRDefaultExperience
  50056. */
  50057. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50058. }
  50059. }
  50060. }
  50061. declare module "babylonjs/Maths/math.vertexFormat" {
  50062. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50063. /**
  50064. * Contains position and normal vectors for a vertex
  50065. */
  50066. export class PositionNormalVertex {
  50067. /** the position of the vertex (defaut: 0,0,0) */
  50068. position: Vector3;
  50069. /** the normal of the vertex (defaut: 0,1,0) */
  50070. normal: Vector3;
  50071. /**
  50072. * Creates a PositionNormalVertex
  50073. * @param position the position of the vertex (defaut: 0,0,0)
  50074. * @param normal the normal of the vertex (defaut: 0,1,0)
  50075. */
  50076. constructor(
  50077. /** the position of the vertex (defaut: 0,0,0) */
  50078. position?: Vector3,
  50079. /** the normal of the vertex (defaut: 0,1,0) */
  50080. normal?: Vector3);
  50081. /**
  50082. * Clones the PositionNormalVertex
  50083. * @returns the cloned PositionNormalVertex
  50084. */
  50085. clone(): PositionNormalVertex;
  50086. }
  50087. /**
  50088. * Contains position, normal and uv vectors for a vertex
  50089. */
  50090. export class PositionNormalTextureVertex {
  50091. /** the position of the vertex (defaut: 0,0,0) */
  50092. position: Vector3;
  50093. /** the normal of the vertex (defaut: 0,1,0) */
  50094. normal: Vector3;
  50095. /** the uv of the vertex (default: 0,0) */
  50096. uv: Vector2;
  50097. /**
  50098. * Creates a PositionNormalTextureVertex
  50099. * @param position the position of the vertex (defaut: 0,0,0)
  50100. * @param normal the normal of the vertex (defaut: 0,1,0)
  50101. * @param uv the uv of the vertex (default: 0,0)
  50102. */
  50103. constructor(
  50104. /** the position of the vertex (defaut: 0,0,0) */
  50105. position?: Vector3,
  50106. /** the normal of the vertex (defaut: 0,1,0) */
  50107. normal?: Vector3,
  50108. /** the uv of the vertex (default: 0,0) */
  50109. uv?: Vector2);
  50110. /**
  50111. * Clones the PositionNormalTextureVertex
  50112. * @returns the cloned PositionNormalTextureVertex
  50113. */
  50114. clone(): PositionNormalTextureVertex;
  50115. }
  50116. }
  50117. declare module "babylonjs/Maths/math" {
  50118. export * from "babylonjs/Maths/math.axis";
  50119. export * from "babylonjs/Maths/math.color";
  50120. export * from "babylonjs/Maths/math.constants";
  50121. export * from "babylonjs/Maths/math.frustum";
  50122. export * from "babylonjs/Maths/math.path";
  50123. export * from "babylonjs/Maths/math.plane";
  50124. export * from "babylonjs/Maths/math.size";
  50125. export * from "babylonjs/Maths/math.vector";
  50126. export * from "babylonjs/Maths/math.vertexFormat";
  50127. export * from "babylonjs/Maths/math.viewport";
  50128. }
  50129. declare module "babylonjs/Helpers/videoDome" {
  50130. import { Scene } from "babylonjs/scene";
  50131. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50132. import { Mesh } from "babylonjs/Meshes/mesh";
  50133. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50134. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50135. import "babylonjs/Meshes/Builders/sphereBuilder";
  50136. /**
  50137. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50138. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50139. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50140. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50141. */
  50142. export class VideoDome extends TransformNode {
  50143. /**
  50144. * Define the video source as a Monoscopic panoramic 360 video.
  50145. */
  50146. static readonly MODE_MONOSCOPIC: number;
  50147. /**
  50148. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50149. */
  50150. static readonly MODE_TOPBOTTOM: number;
  50151. /**
  50152. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50153. */
  50154. static readonly MODE_SIDEBYSIDE: number;
  50155. private _halfDome;
  50156. private _useDirectMapping;
  50157. /**
  50158. * The video texture being displayed on the sphere
  50159. */
  50160. protected _videoTexture: VideoTexture;
  50161. /**
  50162. * Gets the video texture being displayed on the sphere
  50163. */
  50164. readonly videoTexture: VideoTexture;
  50165. /**
  50166. * The skybox material
  50167. */
  50168. protected _material: BackgroundMaterial;
  50169. /**
  50170. * The surface used for the skybox
  50171. */
  50172. protected _mesh: Mesh;
  50173. /**
  50174. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50175. */
  50176. private _halfDomeMask;
  50177. /**
  50178. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50179. * Also see the options.resolution property.
  50180. */
  50181. fovMultiplier: number;
  50182. private _videoMode;
  50183. /**
  50184. * Gets or set the current video mode for the video. It can be:
  50185. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50186. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50187. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50188. */
  50189. videoMode: number;
  50190. /**
  50191. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50192. *
  50193. */
  50194. /**
  50195. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50196. */
  50197. halfDome: boolean;
  50198. /**
  50199. * Oberserver used in Stereoscopic VR Mode.
  50200. */
  50201. private _onBeforeCameraRenderObserver;
  50202. /**
  50203. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50204. * @param name Element's name, child elements will append suffixes for their own names.
  50205. * @param urlsOrVideo defines the url(s) or the video element to use
  50206. * @param options An object containing optional or exposed sub element properties
  50207. */
  50208. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50209. resolution?: number;
  50210. clickToPlay?: boolean;
  50211. autoPlay?: boolean;
  50212. loop?: boolean;
  50213. size?: number;
  50214. poster?: string;
  50215. faceForward?: boolean;
  50216. useDirectMapping?: boolean;
  50217. halfDomeMode?: boolean;
  50218. }, scene: Scene);
  50219. private _changeVideoMode;
  50220. /**
  50221. * Releases resources associated with this node.
  50222. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50223. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50224. */
  50225. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50226. }
  50227. }
  50228. declare module "babylonjs/Helpers/index" {
  50229. export * from "babylonjs/Helpers/environmentHelper";
  50230. export * from "babylonjs/Helpers/photoDome";
  50231. export * from "babylonjs/Helpers/sceneHelpers";
  50232. export * from "babylonjs/Helpers/videoDome";
  50233. }
  50234. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50235. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50236. import { IDisposable } from "babylonjs/scene";
  50237. import { Engine } from "babylonjs/Engines/engine";
  50238. /**
  50239. * This class can be used to get instrumentation data from a Babylon engine
  50240. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50241. */
  50242. export class EngineInstrumentation implements IDisposable {
  50243. /**
  50244. * Define the instrumented engine.
  50245. */
  50246. engine: Engine;
  50247. private _captureGPUFrameTime;
  50248. private _gpuFrameTimeToken;
  50249. private _gpuFrameTime;
  50250. private _captureShaderCompilationTime;
  50251. private _shaderCompilationTime;
  50252. private _onBeginFrameObserver;
  50253. private _onEndFrameObserver;
  50254. private _onBeforeShaderCompilationObserver;
  50255. private _onAfterShaderCompilationObserver;
  50256. /**
  50257. * Gets the perf counter used for GPU frame time
  50258. */
  50259. readonly gpuFrameTimeCounter: PerfCounter;
  50260. /**
  50261. * Gets the GPU frame time capture status
  50262. */
  50263. /**
  50264. * Enable or disable the GPU frame time capture
  50265. */
  50266. captureGPUFrameTime: boolean;
  50267. /**
  50268. * Gets the perf counter used for shader compilation time
  50269. */
  50270. readonly shaderCompilationTimeCounter: PerfCounter;
  50271. /**
  50272. * Gets the shader compilation time capture status
  50273. */
  50274. /**
  50275. * Enable or disable the shader compilation time capture
  50276. */
  50277. captureShaderCompilationTime: boolean;
  50278. /**
  50279. * Instantiates a new engine instrumentation.
  50280. * This class can be used to get instrumentation data from a Babylon engine
  50281. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50282. * @param engine Defines the engine to instrument
  50283. */
  50284. constructor(
  50285. /**
  50286. * Define the instrumented engine.
  50287. */
  50288. engine: Engine);
  50289. /**
  50290. * Dispose and release associated resources.
  50291. */
  50292. dispose(): void;
  50293. }
  50294. }
  50295. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50296. import { Scene, IDisposable } from "babylonjs/scene";
  50297. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50298. /**
  50299. * This class can be used to get instrumentation data from a Babylon engine
  50300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50301. */
  50302. export class SceneInstrumentation implements IDisposable {
  50303. /**
  50304. * Defines the scene to instrument
  50305. */
  50306. scene: Scene;
  50307. private _captureActiveMeshesEvaluationTime;
  50308. private _activeMeshesEvaluationTime;
  50309. private _captureRenderTargetsRenderTime;
  50310. private _renderTargetsRenderTime;
  50311. private _captureFrameTime;
  50312. private _frameTime;
  50313. private _captureRenderTime;
  50314. private _renderTime;
  50315. private _captureInterFrameTime;
  50316. private _interFrameTime;
  50317. private _captureParticlesRenderTime;
  50318. private _particlesRenderTime;
  50319. private _captureSpritesRenderTime;
  50320. private _spritesRenderTime;
  50321. private _capturePhysicsTime;
  50322. private _physicsTime;
  50323. private _captureAnimationsTime;
  50324. private _animationsTime;
  50325. private _captureCameraRenderTime;
  50326. private _cameraRenderTime;
  50327. private _onBeforeActiveMeshesEvaluationObserver;
  50328. private _onAfterActiveMeshesEvaluationObserver;
  50329. private _onBeforeRenderTargetsRenderObserver;
  50330. private _onAfterRenderTargetsRenderObserver;
  50331. private _onAfterRenderObserver;
  50332. private _onBeforeDrawPhaseObserver;
  50333. private _onAfterDrawPhaseObserver;
  50334. private _onBeforeAnimationsObserver;
  50335. private _onBeforeParticlesRenderingObserver;
  50336. private _onAfterParticlesRenderingObserver;
  50337. private _onBeforeSpritesRenderingObserver;
  50338. private _onAfterSpritesRenderingObserver;
  50339. private _onBeforePhysicsObserver;
  50340. private _onAfterPhysicsObserver;
  50341. private _onAfterAnimationsObserver;
  50342. private _onBeforeCameraRenderObserver;
  50343. private _onAfterCameraRenderObserver;
  50344. /**
  50345. * Gets the perf counter used for active meshes evaluation time
  50346. */
  50347. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50348. /**
  50349. * Gets the active meshes evaluation time capture status
  50350. */
  50351. /**
  50352. * Enable or disable the active meshes evaluation time capture
  50353. */
  50354. captureActiveMeshesEvaluationTime: boolean;
  50355. /**
  50356. * Gets the perf counter used for render targets render time
  50357. */
  50358. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50359. /**
  50360. * Gets the render targets render time capture status
  50361. */
  50362. /**
  50363. * Enable or disable the render targets render time capture
  50364. */
  50365. captureRenderTargetsRenderTime: boolean;
  50366. /**
  50367. * Gets the perf counter used for particles render time
  50368. */
  50369. readonly particlesRenderTimeCounter: PerfCounter;
  50370. /**
  50371. * Gets the particles render time capture status
  50372. */
  50373. /**
  50374. * Enable or disable the particles render time capture
  50375. */
  50376. captureParticlesRenderTime: boolean;
  50377. /**
  50378. * Gets the perf counter used for sprites render time
  50379. */
  50380. readonly spritesRenderTimeCounter: PerfCounter;
  50381. /**
  50382. * Gets the sprites render time capture status
  50383. */
  50384. /**
  50385. * Enable or disable the sprites render time capture
  50386. */
  50387. captureSpritesRenderTime: boolean;
  50388. /**
  50389. * Gets the perf counter used for physics time
  50390. */
  50391. readonly physicsTimeCounter: PerfCounter;
  50392. /**
  50393. * Gets the physics time capture status
  50394. */
  50395. /**
  50396. * Enable or disable the physics time capture
  50397. */
  50398. capturePhysicsTime: boolean;
  50399. /**
  50400. * Gets the perf counter used for animations time
  50401. */
  50402. readonly animationsTimeCounter: PerfCounter;
  50403. /**
  50404. * Gets the animations time capture status
  50405. */
  50406. /**
  50407. * Enable or disable the animations time capture
  50408. */
  50409. captureAnimationsTime: boolean;
  50410. /**
  50411. * Gets the perf counter used for frame time capture
  50412. */
  50413. readonly frameTimeCounter: PerfCounter;
  50414. /**
  50415. * Gets the frame time capture status
  50416. */
  50417. /**
  50418. * Enable or disable the frame time capture
  50419. */
  50420. captureFrameTime: boolean;
  50421. /**
  50422. * Gets the perf counter used for inter-frames time capture
  50423. */
  50424. readonly interFrameTimeCounter: PerfCounter;
  50425. /**
  50426. * Gets the inter-frames time capture status
  50427. */
  50428. /**
  50429. * Enable or disable the inter-frames time capture
  50430. */
  50431. captureInterFrameTime: boolean;
  50432. /**
  50433. * Gets the perf counter used for render time capture
  50434. */
  50435. readonly renderTimeCounter: PerfCounter;
  50436. /**
  50437. * Gets the render time capture status
  50438. */
  50439. /**
  50440. * Enable or disable the render time capture
  50441. */
  50442. captureRenderTime: boolean;
  50443. /**
  50444. * Gets the perf counter used for camera render time capture
  50445. */
  50446. readonly cameraRenderTimeCounter: PerfCounter;
  50447. /**
  50448. * Gets the camera render time capture status
  50449. */
  50450. /**
  50451. * Enable or disable the camera render time capture
  50452. */
  50453. captureCameraRenderTime: boolean;
  50454. /**
  50455. * Gets the perf counter used for draw calls
  50456. */
  50457. readonly drawCallsCounter: PerfCounter;
  50458. /**
  50459. * Instantiates a new scene instrumentation.
  50460. * This class can be used to get instrumentation data from a Babylon engine
  50461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50462. * @param scene Defines the scene to instrument
  50463. */
  50464. constructor(
  50465. /**
  50466. * Defines the scene to instrument
  50467. */
  50468. scene: Scene);
  50469. /**
  50470. * Dispose and release associated resources.
  50471. */
  50472. dispose(): void;
  50473. }
  50474. }
  50475. declare module "babylonjs/Instrumentation/index" {
  50476. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50477. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50478. export * from "babylonjs/Instrumentation/timeToken";
  50479. }
  50480. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50481. /** @hidden */
  50482. export var glowMapGenerationPixelShader: {
  50483. name: string;
  50484. shader: string;
  50485. };
  50486. }
  50487. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50488. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50490. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50491. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50493. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50494. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50495. /** @hidden */
  50496. export var glowMapGenerationVertexShader: {
  50497. name: string;
  50498. shader: string;
  50499. };
  50500. }
  50501. declare module "babylonjs/Layers/effectLayer" {
  50502. import { Observable } from "babylonjs/Misc/observable";
  50503. import { Nullable } from "babylonjs/types";
  50504. import { Camera } from "babylonjs/Cameras/camera";
  50505. import { Scene } from "babylonjs/scene";
  50506. import { ISize } from "babylonjs/Maths/math.size";
  50507. import { Color4 } from "babylonjs/Maths/math.color";
  50508. import { Engine } from "babylonjs/Engines/engine";
  50509. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50511. import { Mesh } from "babylonjs/Meshes/mesh";
  50512. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50514. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50515. import { Effect } from "babylonjs/Materials/effect";
  50516. import { Material } from "babylonjs/Materials/material";
  50517. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50518. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50519. /**
  50520. * Effect layer options. This helps customizing the behaviour
  50521. * of the effect layer.
  50522. */
  50523. export interface IEffectLayerOptions {
  50524. /**
  50525. * Multiplication factor apply to the canvas size to compute the render target size
  50526. * used to generated the objects (the smaller the faster).
  50527. */
  50528. mainTextureRatio: number;
  50529. /**
  50530. * Enforces a fixed size texture to ensure effect stability across devices.
  50531. */
  50532. mainTextureFixedSize?: number;
  50533. /**
  50534. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50535. */
  50536. alphaBlendingMode: number;
  50537. /**
  50538. * The camera attached to the layer.
  50539. */
  50540. camera: Nullable<Camera>;
  50541. /**
  50542. * The rendering group to draw the layer in.
  50543. */
  50544. renderingGroupId: number;
  50545. }
  50546. /**
  50547. * The effect layer Helps adding post process effect blended with the main pass.
  50548. *
  50549. * This can be for instance use to generate glow or higlight effects on the scene.
  50550. *
  50551. * The effect layer class can not be used directly and is intented to inherited from to be
  50552. * customized per effects.
  50553. */
  50554. export abstract class EffectLayer {
  50555. private _vertexBuffers;
  50556. private _indexBuffer;
  50557. private _cachedDefines;
  50558. private _effectLayerMapGenerationEffect;
  50559. private _effectLayerOptions;
  50560. private _mergeEffect;
  50561. protected _scene: Scene;
  50562. protected _engine: Engine;
  50563. protected _maxSize: number;
  50564. protected _mainTextureDesiredSize: ISize;
  50565. protected _mainTexture: RenderTargetTexture;
  50566. protected _shouldRender: boolean;
  50567. protected _postProcesses: PostProcess[];
  50568. protected _textures: BaseTexture[];
  50569. protected _emissiveTextureAndColor: {
  50570. texture: Nullable<BaseTexture>;
  50571. color: Color4;
  50572. };
  50573. /**
  50574. * The name of the layer
  50575. */
  50576. name: string;
  50577. /**
  50578. * The clear color of the texture used to generate the glow map.
  50579. */
  50580. neutralColor: Color4;
  50581. /**
  50582. * Specifies wether the highlight layer is enabled or not.
  50583. */
  50584. isEnabled: boolean;
  50585. /**
  50586. * Gets the camera attached to the layer.
  50587. */
  50588. readonly camera: Nullable<Camera>;
  50589. /**
  50590. * Gets the rendering group id the layer should render in.
  50591. */
  50592. renderingGroupId: number;
  50593. /**
  50594. * An event triggered when the effect layer has been disposed.
  50595. */
  50596. onDisposeObservable: Observable<EffectLayer>;
  50597. /**
  50598. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50599. */
  50600. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50601. /**
  50602. * An event triggered when the generated texture is being merged in the scene.
  50603. */
  50604. onBeforeComposeObservable: Observable<EffectLayer>;
  50605. /**
  50606. * An event triggered when the generated texture has been merged in the scene.
  50607. */
  50608. onAfterComposeObservable: Observable<EffectLayer>;
  50609. /**
  50610. * An event triggered when the efffect layer changes its size.
  50611. */
  50612. onSizeChangedObservable: Observable<EffectLayer>;
  50613. /** @hidden */
  50614. static _SceneComponentInitialization: (scene: Scene) => void;
  50615. /**
  50616. * Instantiates a new effect Layer and references it in the scene.
  50617. * @param name The name of the layer
  50618. * @param scene The scene to use the layer in
  50619. */
  50620. constructor(
  50621. /** The Friendly of the effect in the scene */
  50622. name: string, scene: Scene);
  50623. /**
  50624. * Get the effect name of the layer.
  50625. * @return The effect name
  50626. */
  50627. abstract getEffectName(): string;
  50628. /**
  50629. * Checks for the readiness of the element composing the layer.
  50630. * @param subMesh the mesh to check for
  50631. * @param useInstances specify wether or not to use instances to render the mesh
  50632. * @return true if ready otherwise, false
  50633. */
  50634. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50635. /**
  50636. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50637. * @returns true if the effect requires stencil during the main canvas render pass.
  50638. */
  50639. abstract needStencil(): boolean;
  50640. /**
  50641. * Create the merge effect. This is the shader use to blit the information back
  50642. * to the main canvas at the end of the scene rendering.
  50643. * @returns The effect containing the shader used to merge the effect on the main canvas
  50644. */
  50645. protected abstract _createMergeEffect(): Effect;
  50646. /**
  50647. * Creates the render target textures and post processes used in the effect layer.
  50648. */
  50649. protected abstract _createTextureAndPostProcesses(): void;
  50650. /**
  50651. * Implementation specific of rendering the generating effect on the main canvas.
  50652. * @param effect The effect used to render through
  50653. */
  50654. protected abstract _internalRender(effect: Effect): void;
  50655. /**
  50656. * Sets the required values for both the emissive texture and and the main color.
  50657. */
  50658. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50659. /**
  50660. * Free any resources and references associated to a mesh.
  50661. * Internal use
  50662. * @param mesh The mesh to free.
  50663. */
  50664. abstract _disposeMesh(mesh: Mesh): void;
  50665. /**
  50666. * Serializes this layer (Glow or Highlight for example)
  50667. * @returns a serialized layer object
  50668. */
  50669. abstract serialize?(): any;
  50670. /**
  50671. * Initializes the effect layer with the required options.
  50672. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50673. */
  50674. protected _init(options: Partial<IEffectLayerOptions>): void;
  50675. /**
  50676. * Generates the index buffer of the full screen quad blending to the main canvas.
  50677. */
  50678. private _generateIndexBuffer;
  50679. /**
  50680. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50681. */
  50682. private _generateVertexBuffer;
  50683. /**
  50684. * Sets the main texture desired size which is the closest power of two
  50685. * of the engine canvas size.
  50686. */
  50687. private _setMainTextureSize;
  50688. /**
  50689. * Creates the main texture for the effect layer.
  50690. */
  50691. protected _createMainTexture(): void;
  50692. /**
  50693. * Adds specific effects defines.
  50694. * @param defines The defines to add specifics to.
  50695. */
  50696. protected _addCustomEffectDefines(defines: string[]): void;
  50697. /**
  50698. * Checks for the readiness of the element composing the layer.
  50699. * @param subMesh the mesh to check for
  50700. * @param useInstances specify wether or not to use instances to render the mesh
  50701. * @param emissiveTexture the associated emissive texture used to generate the glow
  50702. * @return true if ready otherwise, false
  50703. */
  50704. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50705. /**
  50706. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50707. */
  50708. render(): void;
  50709. /**
  50710. * Determine if a given mesh will be used in the current effect.
  50711. * @param mesh mesh to test
  50712. * @returns true if the mesh will be used
  50713. */
  50714. hasMesh(mesh: AbstractMesh): boolean;
  50715. /**
  50716. * Returns true if the layer contains information to display, otherwise false.
  50717. * @returns true if the glow layer should be rendered
  50718. */
  50719. shouldRender(): boolean;
  50720. /**
  50721. * Returns true if the mesh should render, otherwise false.
  50722. * @param mesh The mesh to render
  50723. * @returns true if it should render otherwise false
  50724. */
  50725. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50726. /**
  50727. * Returns true if the mesh can be rendered, otherwise false.
  50728. * @param mesh The mesh to render
  50729. * @param material The material used on the mesh
  50730. * @returns true if it can be rendered otherwise false
  50731. */
  50732. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50733. /**
  50734. * Returns true if the mesh should render, otherwise false.
  50735. * @param mesh The mesh to render
  50736. * @returns true if it should render otherwise false
  50737. */
  50738. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50739. /**
  50740. * Renders the submesh passed in parameter to the generation map.
  50741. */
  50742. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50743. /**
  50744. * Rebuild the required buffers.
  50745. * @hidden Internal use only.
  50746. */
  50747. _rebuild(): void;
  50748. /**
  50749. * Dispose only the render target textures and post process.
  50750. */
  50751. private _disposeTextureAndPostProcesses;
  50752. /**
  50753. * Dispose the highlight layer and free resources.
  50754. */
  50755. dispose(): void;
  50756. /**
  50757. * Gets the class name of the effect layer
  50758. * @returns the string with the class name of the effect layer
  50759. */
  50760. getClassName(): string;
  50761. /**
  50762. * Creates an effect layer from parsed effect layer data
  50763. * @param parsedEffectLayer defines effect layer data
  50764. * @param scene defines the current scene
  50765. * @param rootUrl defines the root URL containing the effect layer information
  50766. * @returns a parsed effect Layer
  50767. */
  50768. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50769. }
  50770. }
  50771. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50772. import { Scene } from "babylonjs/scene";
  50773. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50774. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50775. import { AbstractScene } from "babylonjs/abstractScene";
  50776. module "babylonjs/abstractScene" {
  50777. interface AbstractScene {
  50778. /**
  50779. * The list of effect layers (highlights/glow) added to the scene
  50780. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50781. * @see http://doc.babylonjs.com/how_to/glow_layer
  50782. */
  50783. effectLayers: Array<EffectLayer>;
  50784. /**
  50785. * Removes the given effect layer from this scene.
  50786. * @param toRemove defines the effect layer to remove
  50787. * @returns the index of the removed effect layer
  50788. */
  50789. removeEffectLayer(toRemove: EffectLayer): number;
  50790. /**
  50791. * Adds the given effect layer to this scene
  50792. * @param newEffectLayer defines the effect layer to add
  50793. */
  50794. addEffectLayer(newEffectLayer: EffectLayer): void;
  50795. }
  50796. }
  50797. /**
  50798. * Defines the layer scene component responsible to manage any effect layers
  50799. * in a given scene.
  50800. */
  50801. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50802. /**
  50803. * The component name helpfull to identify the component in the list of scene components.
  50804. */
  50805. readonly name: string;
  50806. /**
  50807. * The scene the component belongs to.
  50808. */
  50809. scene: Scene;
  50810. private _engine;
  50811. private _renderEffects;
  50812. private _needStencil;
  50813. private _previousStencilState;
  50814. /**
  50815. * Creates a new instance of the component for the given scene
  50816. * @param scene Defines the scene to register the component in
  50817. */
  50818. constructor(scene: Scene);
  50819. /**
  50820. * Registers the component in a given scene
  50821. */
  50822. register(): void;
  50823. /**
  50824. * Rebuilds the elements related to this component in case of
  50825. * context lost for instance.
  50826. */
  50827. rebuild(): void;
  50828. /**
  50829. * Serializes the component data to the specified json object
  50830. * @param serializationObject The object to serialize to
  50831. */
  50832. serialize(serializationObject: any): void;
  50833. /**
  50834. * Adds all the elements from the container to the scene
  50835. * @param container the container holding the elements
  50836. */
  50837. addFromContainer(container: AbstractScene): void;
  50838. /**
  50839. * Removes all the elements in the container from the scene
  50840. * @param container contains the elements to remove
  50841. * @param dispose if the removed element should be disposed (default: false)
  50842. */
  50843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50844. /**
  50845. * Disposes the component and the associated ressources.
  50846. */
  50847. dispose(): void;
  50848. private _isReadyForMesh;
  50849. private _renderMainTexture;
  50850. private _setStencil;
  50851. private _setStencilBack;
  50852. private _draw;
  50853. private _drawCamera;
  50854. private _drawRenderingGroup;
  50855. }
  50856. }
  50857. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50858. /** @hidden */
  50859. export var glowMapMergePixelShader: {
  50860. name: string;
  50861. shader: string;
  50862. };
  50863. }
  50864. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50865. /** @hidden */
  50866. export var glowMapMergeVertexShader: {
  50867. name: string;
  50868. shader: string;
  50869. };
  50870. }
  50871. declare module "babylonjs/Layers/glowLayer" {
  50872. import { Nullable } from "babylonjs/types";
  50873. import { Camera } from "babylonjs/Cameras/camera";
  50874. import { Scene } from "babylonjs/scene";
  50875. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50877. import { Mesh } from "babylonjs/Meshes/mesh";
  50878. import { Texture } from "babylonjs/Materials/Textures/texture";
  50879. import { Effect } from "babylonjs/Materials/effect";
  50880. import { Material } from "babylonjs/Materials/material";
  50881. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50882. import { Color4 } from "babylonjs/Maths/math.color";
  50883. import "babylonjs/Shaders/glowMapMerge.fragment";
  50884. import "babylonjs/Shaders/glowMapMerge.vertex";
  50885. import "babylonjs/Layers/effectLayerSceneComponent";
  50886. module "babylonjs/abstractScene" {
  50887. interface AbstractScene {
  50888. /**
  50889. * Return a the first highlight layer of the scene with a given name.
  50890. * @param name The name of the highlight layer to look for.
  50891. * @return The highlight layer if found otherwise null.
  50892. */
  50893. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50894. }
  50895. }
  50896. /**
  50897. * Glow layer options. This helps customizing the behaviour
  50898. * of the glow layer.
  50899. */
  50900. export interface IGlowLayerOptions {
  50901. /**
  50902. * Multiplication factor apply to the canvas size to compute the render target size
  50903. * used to generated the glowing objects (the smaller the faster).
  50904. */
  50905. mainTextureRatio: number;
  50906. /**
  50907. * Enforces a fixed size texture to ensure resize independant blur.
  50908. */
  50909. mainTextureFixedSize?: number;
  50910. /**
  50911. * How big is the kernel of the blur texture.
  50912. */
  50913. blurKernelSize: number;
  50914. /**
  50915. * The camera attached to the layer.
  50916. */
  50917. camera: Nullable<Camera>;
  50918. /**
  50919. * Enable MSAA by chosing the number of samples.
  50920. */
  50921. mainTextureSamples?: number;
  50922. /**
  50923. * The rendering group to draw the layer in.
  50924. */
  50925. renderingGroupId: number;
  50926. }
  50927. /**
  50928. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50929. *
  50930. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50931. * glowy meshes to your scene.
  50932. *
  50933. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50934. */
  50935. export class GlowLayer extends EffectLayer {
  50936. /**
  50937. * Effect Name of the layer.
  50938. */
  50939. static readonly EffectName: string;
  50940. /**
  50941. * The default blur kernel size used for the glow.
  50942. */
  50943. static DefaultBlurKernelSize: number;
  50944. /**
  50945. * The default texture size ratio used for the glow.
  50946. */
  50947. static DefaultTextureRatio: number;
  50948. /**
  50949. * Sets the kernel size of the blur.
  50950. */
  50951. /**
  50952. * Gets the kernel size of the blur.
  50953. */
  50954. blurKernelSize: number;
  50955. /**
  50956. * Sets the glow intensity.
  50957. */
  50958. /**
  50959. * Gets the glow intensity.
  50960. */
  50961. intensity: number;
  50962. private _options;
  50963. private _intensity;
  50964. private _horizontalBlurPostprocess1;
  50965. private _verticalBlurPostprocess1;
  50966. private _horizontalBlurPostprocess2;
  50967. private _verticalBlurPostprocess2;
  50968. private _blurTexture1;
  50969. private _blurTexture2;
  50970. private _postProcesses1;
  50971. private _postProcesses2;
  50972. private _includedOnlyMeshes;
  50973. private _excludedMeshes;
  50974. /**
  50975. * Callback used to let the user override the color selection on a per mesh basis
  50976. */
  50977. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50978. /**
  50979. * Callback used to let the user override the texture selection on a per mesh basis
  50980. */
  50981. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50982. /**
  50983. * Instantiates a new glow Layer and references it to the scene.
  50984. * @param name The name of the layer
  50985. * @param scene The scene to use the layer in
  50986. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50987. */
  50988. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50989. /**
  50990. * Get the effect name of the layer.
  50991. * @return The effect name
  50992. */
  50993. getEffectName(): string;
  50994. /**
  50995. * Create the merge effect. This is the shader use to blit the information back
  50996. * to the main canvas at the end of the scene rendering.
  50997. */
  50998. protected _createMergeEffect(): Effect;
  50999. /**
  51000. * Creates the render target textures and post processes used in the glow layer.
  51001. */
  51002. protected _createTextureAndPostProcesses(): void;
  51003. /**
  51004. * Checks for the readiness of the element composing the layer.
  51005. * @param subMesh the mesh to check for
  51006. * @param useInstances specify wether or not to use instances to render the mesh
  51007. * @param emissiveTexture the associated emissive texture used to generate the glow
  51008. * @return true if ready otherwise, false
  51009. */
  51010. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51011. /**
  51012. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51013. */
  51014. needStencil(): boolean;
  51015. /**
  51016. * Returns true if the mesh can be rendered, otherwise false.
  51017. * @param mesh The mesh to render
  51018. * @param material The material used on the mesh
  51019. * @returns true if it can be rendered otherwise false
  51020. */
  51021. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51022. /**
  51023. * Implementation specific of rendering the generating effect on the main canvas.
  51024. * @param effect The effect used to render through
  51025. */
  51026. protected _internalRender(effect: Effect): void;
  51027. /**
  51028. * Sets the required values for both the emissive texture and and the main color.
  51029. */
  51030. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51031. /**
  51032. * Returns true if the mesh should render, otherwise false.
  51033. * @param mesh The mesh to render
  51034. * @returns true if it should render otherwise false
  51035. */
  51036. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51037. /**
  51038. * Adds specific effects defines.
  51039. * @param defines The defines to add specifics to.
  51040. */
  51041. protected _addCustomEffectDefines(defines: string[]): void;
  51042. /**
  51043. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51044. * @param mesh The mesh to exclude from the glow layer
  51045. */
  51046. addExcludedMesh(mesh: Mesh): void;
  51047. /**
  51048. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51049. * @param mesh The mesh to remove
  51050. */
  51051. removeExcludedMesh(mesh: Mesh): void;
  51052. /**
  51053. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51054. * @param mesh The mesh to include in the glow layer
  51055. */
  51056. addIncludedOnlyMesh(mesh: Mesh): void;
  51057. /**
  51058. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51059. * @param mesh The mesh to remove
  51060. */
  51061. removeIncludedOnlyMesh(mesh: Mesh): void;
  51062. /**
  51063. * Determine if a given mesh will be used in the glow layer
  51064. * @param mesh The mesh to test
  51065. * @returns true if the mesh will be highlighted by the current glow layer
  51066. */
  51067. hasMesh(mesh: AbstractMesh): boolean;
  51068. /**
  51069. * Free any resources and references associated to a mesh.
  51070. * Internal use
  51071. * @param mesh The mesh to free.
  51072. * @hidden
  51073. */
  51074. _disposeMesh(mesh: Mesh): void;
  51075. /**
  51076. * Gets the class name of the effect layer
  51077. * @returns the string with the class name of the effect layer
  51078. */
  51079. getClassName(): string;
  51080. /**
  51081. * Serializes this glow layer
  51082. * @returns a serialized glow layer object
  51083. */
  51084. serialize(): any;
  51085. /**
  51086. * Creates a Glow Layer from parsed glow layer data
  51087. * @param parsedGlowLayer defines glow layer data
  51088. * @param scene defines the current scene
  51089. * @param rootUrl defines the root URL containing the glow layer information
  51090. * @returns a parsed Glow Layer
  51091. */
  51092. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51093. }
  51094. }
  51095. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51096. /** @hidden */
  51097. export var glowBlurPostProcessPixelShader: {
  51098. name: string;
  51099. shader: string;
  51100. };
  51101. }
  51102. declare module "babylonjs/Layers/highlightLayer" {
  51103. import { Observable } from "babylonjs/Misc/observable";
  51104. import { Nullable } from "babylonjs/types";
  51105. import { Camera } from "babylonjs/Cameras/camera";
  51106. import { Scene } from "babylonjs/scene";
  51107. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51109. import { Mesh } from "babylonjs/Meshes/mesh";
  51110. import { Effect } from "babylonjs/Materials/effect";
  51111. import { Material } from "babylonjs/Materials/material";
  51112. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51113. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51114. import "babylonjs/Shaders/glowMapMerge.fragment";
  51115. import "babylonjs/Shaders/glowMapMerge.vertex";
  51116. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51117. module "babylonjs/abstractScene" {
  51118. interface AbstractScene {
  51119. /**
  51120. * Return a the first highlight layer of the scene with a given name.
  51121. * @param name The name of the highlight layer to look for.
  51122. * @return The highlight layer if found otherwise null.
  51123. */
  51124. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51125. }
  51126. }
  51127. /**
  51128. * Highlight layer options. This helps customizing the behaviour
  51129. * of the highlight layer.
  51130. */
  51131. export interface IHighlightLayerOptions {
  51132. /**
  51133. * Multiplication factor apply to the canvas size to compute the render target size
  51134. * used to generated the glowing objects (the smaller the faster).
  51135. */
  51136. mainTextureRatio: number;
  51137. /**
  51138. * Enforces a fixed size texture to ensure resize independant blur.
  51139. */
  51140. mainTextureFixedSize?: number;
  51141. /**
  51142. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51143. * of the picture to blur (the smaller the faster).
  51144. */
  51145. blurTextureSizeRatio: number;
  51146. /**
  51147. * How big in texel of the blur texture is the vertical blur.
  51148. */
  51149. blurVerticalSize: number;
  51150. /**
  51151. * How big in texel of the blur texture is the horizontal blur.
  51152. */
  51153. blurHorizontalSize: number;
  51154. /**
  51155. * Alpha blending mode used to apply the blur. Default is combine.
  51156. */
  51157. alphaBlendingMode: number;
  51158. /**
  51159. * The camera attached to the layer.
  51160. */
  51161. camera: Nullable<Camera>;
  51162. /**
  51163. * Should we display highlight as a solid stroke?
  51164. */
  51165. isStroke?: boolean;
  51166. /**
  51167. * The rendering group to draw the layer in.
  51168. */
  51169. renderingGroupId: number;
  51170. }
  51171. /**
  51172. * The highlight layer Helps adding a glow effect around a mesh.
  51173. *
  51174. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51175. * glowy meshes to your scene.
  51176. *
  51177. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51178. */
  51179. export class HighlightLayer extends EffectLayer {
  51180. name: string;
  51181. /**
  51182. * Effect Name of the highlight layer.
  51183. */
  51184. static readonly EffectName: string;
  51185. /**
  51186. * The neutral color used during the preparation of the glow effect.
  51187. * This is black by default as the blend operation is a blend operation.
  51188. */
  51189. static NeutralColor: Color4;
  51190. /**
  51191. * Stencil value used for glowing meshes.
  51192. */
  51193. static GlowingMeshStencilReference: number;
  51194. /**
  51195. * Stencil value used for the other meshes in the scene.
  51196. */
  51197. static NormalMeshStencilReference: number;
  51198. /**
  51199. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51200. */
  51201. innerGlow: boolean;
  51202. /**
  51203. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51204. */
  51205. outerGlow: boolean;
  51206. /**
  51207. * Specifies the horizontal size of the blur.
  51208. */
  51209. /**
  51210. * Gets the horizontal size of the blur.
  51211. */
  51212. blurHorizontalSize: number;
  51213. /**
  51214. * Specifies the vertical size of the blur.
  51215. */
  51216. /**
  51217. * Gets the vertical size of the blur.
  51218. */
  51219. blurVerticalSize: number;
  51220. /**
  51221. * An event triggered when the highlight layer is being blurred.
  51222. */
  51223. onBeforeBlurObservable: Observable<HighlightLayer>;
  51224. /**
  51225. * An event triggered when the highlight layer has been blurred.
  51226. */
  51227. onAfterBlurObservable: Observable<HighlightLayer>;
  51228. private _instanceGlowingMeshStencilReference;
  51229. private _options;
  51230. private _downSamplePostprocess;
  51231. private _horizontalBlurPostprocess;
  51232. private _verticalBlurPostprocess;
  51233. private _blurTexture;
  51234. private _meshes;
  51235. private _excludedMeshes;
  51236. /**
  51237. * Instantiates a new highlight Layer and references it to the scene..
  51238. * @param name The name of the layer
  51239. * @param scene The scene to use the layer in
  51240. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51241. */
  51242. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51243. /**
  51244. * Get the effect name of the layer.
  51245. * @return The effect name
  51246. */
  51247. getEffectName(): string;
  51248. /**
  51249. * Create the merge effect. This is the shader use to blit the information back
  51250. * to the main canvas at the end of the scene rendering.
  51251. */
  51252. protected _createMergeEffect(): Effect;
  51253. /**
  51254. * Creates the render target textures and post processes used in the highlight layer.
  51255. */
  51256. protected _createTextureAndPostProcesses(): void;
  51257. /**
  51258. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51259. */
  51260. needStencil(): boolean;
  51261. /**
  51262. * Checks for the readiness of the element composing the layer.
  51263. * @param subMesh the mesh to check for
  51264. * @param useInstances specify wether or not to use instances to render the mesh
  51265. * @param emissiveTexture the associated emissive texture used to generate the glow
  51266. * @return true if ready otherwise, false
  51267. */
  51268. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51269. /**
  51270. * Implementation specific of rendering the generating effect on the main canvas.
  51271. * @param effect The effect used to render through
  51272. */
  51273. protected _internalRender(effect: Effect): void;
  51274. /**
  51275. * Returns true if the layer contains information to display, otherwise false.
  51276. */
  51277. shouldRender(): boolean;
  51278. /**
  51279. * Returns true if the mesh should render, otherwise false.
  51280. * @param mesh The mesh to render
  51281. * @returns true if it should render otherwise false
  51282. */
  51283. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51284. /**
  51285. * Sets the required values for both the emissive texture and and the main color.
  51286. */
  51287. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51288. /**
  51289. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51290. * @param mesh The mesh to exclude from the highlight layer
  51291. */
  51292. addExcludedMesh(mesh: Mesh): void;
  51293. /**
  51294. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51295. * @param mesh The mesh to highlight
  51296. */
  51297. removeExcludedMesh(mesh: Mesh): void;
  51298. /**
  51299. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51300. * @param mesh mesh to test
  51301. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51302. */
  51303. hasMesh(mesh: AbstractMesh): boolean;
  51304. /**
  51305. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51306. * @param mesh The mesh to highlight
  51307. * @param color The color of the highlight
  51308. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51309. */
  51310. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51311. /**
  51312. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51313. * @param mesh The mesh to highlight
  51314. */
  51315. removeMesh(mesh: Mesh): void;
  51316. /**
  51317. * Force the stencil to the normal expected value for none glowing parts
  51318. */
  51319. private _defaultStencilReference;
  51320. /**
  51321. * Free any resources and references associated to a mesh.
  51322. * Internal use
  51323. * @param mesh The mesh to free.
  51324. * @hidden
  51325. */
  51326. _disposeMesh(mesh: Mesh): void;
  51327. /**
  51328. * Dispose the highlight layer and free resources.
  51329. */
  51330. dispose(): void;
  51331. /**
  51332. * Gets the class name of the effect layer
  51333. * @returns the string with the class name of the effect layer
  51334. */
  51335. getClassName(): string;
  51336. /**
  51337. * Serializes this Highlight layer
  51338. * @returns a serialized Highlight layer object
  51339. */
  51340. serialize(): any;
  51341. /**
  51342. * Creates a Highlight layer from parsed Highlight layer data
  51343. * @param parsedHightlightLayer defines the Highlight layer data
  51344. * @param scene defines the current scene
  51345. * @param rootUrl defines the root URL containing the Highlight layer information
  51346. * @returns a parsed Highlight layer
  51347. */
  51348. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51349. }
  51350. }
  51351. declare module "babylonjs/Layers/layerSceneComponent" {
  51352. import { Scene } from "babylonjs/scene";
  51353. import { ISceneComponent } from "babylonjs/sceneComponent";
  51354. import { Layer } from "babylonjs/Layers/layer";
  51355. import { AbstractScene } from "babylonjs/abstractScene";
  51356. module "babylonjs/abstractScene" {
  51357. interface AbstractScene {
  51358. /**
  51359. * The list of layers (background and foreground) of the scene
  51360. */
  51361. layers: Array<Layer>;
  51362. }
  51363. }
  51364. /**
  51365. * Defines the layer scene component responsible to manage any layers
  51366. * in a given scene.
  51367. */
  51368. export class LayerSceneComponent implements ISceneComponent {
  51369. /**
  51370. * The component name helpfull to identify the component in the list of scene components.
  51371. */
  51372. readonly name: string;
  51373. /**
  51374. * The scene the component belongs to.
  51375. */
  51376. scene: Scene;
  51377. private _engine;
  51378. /**
  51379. * Creates a new instance of the component for the given scene
  51380. * @param scene Defines the scene to register the component in
  51381. */
  51382. constructor(scene: Scene);
  51383. /**
  51384. * Registers the component in a given scene
  51385. */
  51386. register(): void;
  51387. /**
  51388. * Rebuilds the elements related to this component in case of
  51389. * context lost for instance.
  51390. */
  51391. rebuild(): void;
  51392. /**
  51393. * Disposes the component and the associated ressources.
  51394. */
  51395. dispose(): void;
  51396. private _draw;
  51397. private _drawCameraPredicate;
  51398. private _drawCameraBackground;
  51399. private _drawCameraForeground;
  51400. private _drawRenderTargetPredicate;
  51401. private _drawRenderTargetBackground;
  51402. private _drawRenderTargetForeground;
  51403. /**
  51404. * Adds all the elements from the container to the scene
  51405. * @param container the container holding the elements
  51406. */
  51407. addFromContainer(container: AbstractScene): void;
  51408. /**
  51409. * Removes all the elements in the container from the scene
  51410. * @param container contains the elements to remove
  51411. * @param dispose if the removed element should be disposed (default: false)
  51412. */
  51413. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51414. }
  51415. }
  51416. declare module "babylonjs/Shaders/layer.fragment" {
  51417. /** @hidden */
  51418. export var layerPixelShader: {
  51419. name: string;
  51420. shader: string;
  51421. };
  51422. }
  51423. declare module "babylonjs/Shaders/layer.vertex" {
  51424. /** @hidden */
  51425. export var layerVertexShader: {
  51426. name: string;
  51427. shader: string;
  51428. };
  51429. }
  51430. declare module "babylonjs/Layers/layer" {
  51431. import { Observable } from "babylonjs/Misc/observable";
  51432. import { Nullable } from "babylonjs/types";
  51433. import { Scene } from "babylonjs/scene";
  51434. import { Vector2 } from "babylonjs/Maths/math.vector";
  51435. import { Color4 } from "babylonjs/Maths/math.color";
  51436. import { Texture } from "babylonjs/Materials/Textures/texture";
  51437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51438. import "babylonjs/Shaders/layer.fragment";
  51439. import "babylonjs/Shaders/layer.vertex";
  51440. /**
  51441. * This represents a full screen 2d layer.
  51442. * This can be useful to display a picture in the background of your scene for instance.
  51443. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51444. */
  51445. export class Layer {
  51446. /**
  51447. * Define the name of the layer.
  51448. */
  51449. name: string;
  51450. /**
  51451. * Define the texture the layer should display.
  51452. */
  51453. texture: Nullable<Texture>;
  51454. /**
  51455. * Is the layer in background or foreground.
  51456. */
  51457. isBackground: boolean;
  51458. /**
  51459. * Define the color of the layer (instead of texture).
  51460. */
  51461. color: Color4;
  51462. /**
  51463. * Define the scale of the layer in order to zoom in out of the texture.
  51464. */
  51465. scale: Vector2;
  51466. /**
  51467. * Define an offset for the layer in order to shift the texture.
  51468. */
  51469. offset: Vector2;
  51470. /**
  51471. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51472. */
  51473. alphaBlendingMode: number;
  51474. /**
  51475. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51476. * Alpha test will not mix with the background color in case of transparency.
  51477. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51478. */
  51479. alphaTest: boolean;
  51480. /**
  51481. * Define a mask to restrict the layer to only some of the scene cameras.
  51482. */
  51483. layerMask: number;
  51484. /**
  51485. * Define the list of render target the layer is visible into.
  51486. */
  51487. renderTargetTextures: RenderTargetTexture[];
  51488. /**
  51489. * Define if the layer is only used in renderTarget or if it also
  51490. * renders in the main frame buffer of the canvas.
  51491. */
  51492. renderOnlyInRenderTargetTextures: boolean;
  51493. private _scene;
  51494. private _vertexBuffers;
  51495. private _indexBuffer;
  51496. private _effect;
  51497. private _alphaTestEffect;
  51498. /**
  51499. * An event triggered when the layer is disposed.
  51500. */
  51501. onDisposeObservable: Observable<Layer>;
  51502. private _onDisposeObserver;
  51503. /**
  51504. * Back compatibility with callback before the onDisposeObservable existed.
  51505. * The set callback will be triggered when the layer has been disposed.
  51506. */
  51507. onDispose: () => void;
  51508. /**
  51509. * An event triggered before rendering the scene
  51510. */
  51511. onBeforeRenderObservable: Observable<Layer>;
  51512. private _onBeforeRenderObserver;
  51513. /**
  51514. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51515. * The set callback will be triggered just before rendering the layer.
  51516. */
  51517. onBeforeRender: () => void;
  51518. /**
  51519. * An event triggered after rendering the scene
  51520. */
  51521. onAfterRenderObservable: Observable<Layer>;
  51522. private _onAfterRenderObserver;
  51523. /**
  51524. * Back compatibility with callback before the onAfterRenderObservable existed.
  51525. * The set callback will be triggered just after rendering the layer.
  51526. */
  51527. onAfterRender: () => void;
  51528. /**
  51529. * Instantiates a new layer.
  51530. * This represents a full screen 2d layer.
  51531. * This can be useful to display a picture in the background of your scene for instance.
  51532. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51533. * @param name Define the name of the layer in the scene
  51534. * @param imgUrl Define the url of the texture to display in the layer
  51535. * @param scene Define the scene the layer belongs to
  51536. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51537. * @param color Defines a color for the layer
  51538. */
  51539. constructor(
  51540. /**
  51541. * Define the name of the layer.
  51542. */
  51543. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51544. private _createIndexBuffer;
  51545. /** @hidden */
  51546. _rebuild(): void;
  51547. /**
  51548. * Renders the layer in the scene.
  51549. */
  51550. render(): void;
  51551. /**
  51552. * Disposes and releases the associated ressources.
  51553. */
  51554. dispose(): void;
  51555. }
  51556. }
  51557. declare module "babylonjs/Layers/index" {
  51558. export * from "babylonjs/Layers/effectLayer";
  51559. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51560. export * from "babylonjs/Layers/glowLayer";
  51561. export * from "babylonjs/Layers/highlightLayer";
  51562. export * from "babylonjs/Layers/layer";
  51563. export * from "babylonjs/Layers/layerSceneComponent";
  51564. }
  51565. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51566. /** @hidden */
  51567. export var lensFlarePixelShader: {
  51568. name: string;
  51569. shader: string;
  51570. };
  51571. }
  51572. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51573. /** @hidden */
  51574. export var lensFlareVertexShader: {
  51575. name: string;
  51576. shader: string;
  51577. };
  51578. }
  51579. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51580. import { Scene } from "babylonjs/scene";
  51581. import { Vector3 } from "babylonjs/Maths/math.vector";
  51582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51583. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51584. import "babylonjs/Shaders/lensFlare.fragment";
  51585. import "babylonjs/Shaders/lensFlare.vertex";
  51586. import { Viewport } from "babylonjs/Maths/math.viewport";
  51587. /**
  51588. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51589. * It is usually composed of several `lensFlare`.
  51590. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51591. */
  51592. export class LensFlareSystem {
  51593. /**
  51594. * Define the name of the lens flare system
  51595. */
  51596. name: string;
  51597. /**
  51598. * List of lens flares used in this system.
  51599. */
  51600. lensFlares: LensFlare[];
  51601. /**
  51602. * Define a limit from the border the lens flare can be visible.
  51603. */
  51604. borderLimit: number;
  51605. /**
  51606. * Define a viewport border we do not want to see the lens flare in.
  51607. */
  51608. viewportBorder: number;
  51609. /**
  51610. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51611. */
  51612. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51613. /**
  51614. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51615. */
  51616. layerMask: number;
  51617. /**
  51618. * Define the id of the lens flare system in the scene.
  51619. * (equal to name by default)
  51620. */
  51621. id: string;
  51622. private _scene;
  51623. private _emitter;
  51624. private _vertexBuffers;
  51625. private _indexBuffer;
  51626. private _effect;
  51627. private _positionX;
  51628. private _positionY;
  51629. private _isEnabled;
  51630. /** @hidden */
  51631. static _SceneComponentInitialization: (scene: Scene) => void;
  51632. /**
  51633. * Instantiates a lens flare system.
  51634. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51635. * It is usually composed of several `lensFlare`.
  51636. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51637. * @param name Define the name of the lens flare system in the scene
  51638. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51639. * @param scene Define the scene the lens flare system belongs to
  51640. */
  51641. constructor(
  51642. /**
  51643. * Define the name of the lens flare system
  51644. */
  51645. name: string, emitter: any, scene: Scene);
  51646. /**
  51647. * Define if the lens flare system is enabled.
  51648. */
  51649. isEnabled: boolean;
  51650. /**
  51651. * Get the scene the effects belongs to.
  51652. * @returns the scene holding the lens flare system
  51653. */
  51654. getScene(): Scene;
  51655. /**
  51656. * Get the emitter of the lens flare system.
  51657. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51658. * @returns the emitter of the lens flare system
  51659. */
  51660. getEmitter(): any;
  51661. /**
  51662. * Set the emitter of the lens flare system.
  51663. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51664. * @param newEmitter Define the new emitter of the system
  51665. */
  51666. setEmitter(newEmitter: any): void;
  51667. /**
  51668. * Get the lens flare system emitter position.
  51669. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51670. * @returns the position
  51671. */
  51672. getEmitterPosition(): Vector3;
  51673. /**
  51674. * @hidden
  51675. */
  51676. computeEffectivePosition(globalViewport: Viewport): boolean;
  51677. /** @hidden */
  51678. _isVisible(): boolean;
  51679. /**
  51680. * @hidden
  51681. */
  51682. render(): boolean;
  51683. /**
  51684. * Dispose and release the lens flare with its associated resources.
  51685. */
  51686. dispose(): void;
  51687. /**
  51688. * Parse a lens flare system from a JSON repressentation
  51689. * @param parsedLensFlareSystem Define the JSON to parse
  51690. * @param scene Define the scene the parsed system should be instantiated in
  51691. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51692. * @returns the parsed system
  51693. */
  51694. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51695. /**
  51696. * Serialize the current Lens Flare System into a JSON representation.
  51697. * @returns the serialized JSON
  51698. */
  51699. serialize(): any;
  51700. }
  51701. }
  51702. declare module "babylonjs/LensFlares/lensFlare" {
  51703. import { Nullable } from "babylonjs/types";
  51704. import { Color3 } from "babylonjs/Maths/math.color";
  51705. import { Texture } from "babylonjs/Materials/Textures/texture";
  51706. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51707. /**
  51708. * This represents one of the lens effect in a `lensFlareSystem`.
  51709. * It controls one of the indiviual texture used in the effect.
  51710. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51711. */
  51712. export class LensFlare {
  51713. /**
  51714. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51715. */
  51716. size: number;
  51717. /**
  51718. * 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.
  51719. */
  51720. position: number;
  51721. /**
  51722. * Define the lens color.
  51723. */
  51724. color: Color3;
  51725. /**
  51726. * Define the lens texture.
  51727. */
  51728. texture: Nullable<Texture>;
  51729. /**
  51730. * Define the alpha mode to render this particular lens.
  51731. */
  51732. alphaMode: number;
  51733. private _system;
  51734. /**
  51735. * Creates a new Lens Flare.
  51736. * This represents one of the lens effect in a `lensFlareSystem`.
  51737. * It controls one of the indiviual texture used in the effect.
  51738. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51739. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51740. * @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.
  51741. * @param color Define the lens color
  51742. * @param imgUrl Define the lens texture url
  51743. * @param system Define the `lensFlareSystem` this flare is part of
  51744. * @returns The newly created Lens Flare
  51745. */
  51746. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51747. /**
  51748. * Instantiates a new Lens Flare.
  51749. * This represents one of the lens effect in a `lensFlareSystem`.
  51750. * It controls one of the indiviual texture used in the effect.
  51751. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51752. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51753. * @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.
  51754. * @param color Define the lens color
  51755. * @param imgUrl Define the lens texture url
  51756. * @param system Define the `lensFlareSystem` this flare is part of
  51757. */
  51758. constructor(
  51759. /**
  51760. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51761. */
  51762. size: number,
  51763. /**
  51764. * 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.
  51765. */
  51766. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51767. /**
  51768. * Dispose and release the lens flare with its associated resources.
  51769. */
  51770. dispose(): void;
  51771. }
  51772. }
  51773. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51774. import { Nullable } from "babylonjs/types";
  51775. import { Scene } from "babylonjs/scene";
  51776. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51777. import { AbstractScene } from "babylonjs/abstractScene";
  51778. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51779. module "babylonjs/abstractScene" {
  51780. interface AbstractScene {
  51781. /**
  51782. * The list of lens flare system added to the scene
  51783. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51784. */
  51785. lensFlareSystems: Array<LensFlareSystem>;
  51786. /**
  51787. * Removes the given lens flare system from this scene.
  51788. * @param toRemove The lens flare system to remove
  51789. * @returns The index of the removed lens flare system
  51790. */
  51791. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51792. /**
  51793. * Adds the given lens flare system to this scene
  51794. * @param newLensFlareSystem The lens flare system to add
  51795. */
  51796. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51797. /**
  51798. * Gets a lens flare system using its name
  51799. * @param name defines the name to look for
  51800. * @returns the lens flare system or null if not found
  51801. */
  51802. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51803. /**
  51804. * Gets a lens flare system using its id
  51805. * @param id defines the id to look for
  51806. * @returns the lens flare system or null if not found
  51807. */
  51808. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51809. }
  51810. }
  51811. /**
  51812. * Defines the lens flare scene component responsible to manage any lens flares
  51813. * in a given scene.
  51814. */
  51815. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51816. /**
  51817. * The component name helpfull to identify the component in the list of scene components.
  51818. */
  51819. readonly name: string;
  51820. /**
  51821. * The scene the component belongs to.
  51822. */
  51823. scene: Scene;
  51824. /**
  51825. * Creates a new instance of the component for the given scene
  51826. * @param scene Defines the scene to register the component in
  51827. */
  51828. constructor(scene: Scene);
  51829. /**
  51830. * Registers the component in a given scene
  51831. */
  51832. register(): void;
  51833. /**
  51834. * Rebuilds the elements related to this component in case of
  51835. * context lost for instance.
  51836. */
  51837. rebuild(): void;
  51838. /**
  51839. * Adds all the elements from the container to the scene
  51840. * @param container the container holding the elements
  51841. */
  51842. addFromContainer(container: AbstractScene): void;
  51843. /**
  51844. * Removes all the elements in the container from the scene
  51845. * @param container contains the elements to remove
  51846. * @param dispose if the removed element should be disposed (default: false)
  51847. */
  51848. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51849. /**
  51850. * Serializes the component data to the specified json object
  51851. * @param serializationObject The object to serialize to
  51852. */
  51853. serialize(serializationObject: any): void;
  51854. /**
  51855. * Disposes the component and the associated ressources.
  51856. */
  51857. dispose(): void;
  51858. private _draw;
  51859. }
  51860. }
  51861. declare module "babylonjs/LensFlares/index" {
  51862. export * from "babylonjs/LensFlares/lensFlare";
  51863. export * from "babylonjs/LensFlares/lensFlareSystem";
  51864. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51865. }
  51866. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51867. import { Scene } from "babylonjs/scene";
  51868. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51869. import { AbstractScene } from "babylonjs/abstractScene";
  51870. /**
  51871. * Defines the shadow generator component responsible to manage any shadow generators
  51872. * in a given scene.
  51873. */
  51874. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51875. /**
  51876. * The component name helpfull to identify the component in the list of scene components.
  51877. */
  51878. readonly name: string;
  51879. /**
  51880. * The scene the component belongs to.
  51881. */
  51882. scene: Scene;
  51883. /**
  51884. * Creates a new instance of the component for the given scene
  51885. * @param scene Defines the scene to register the component in
  51886. */
  51887. constructor(scene: Scene);
  51888. /**
  51889. * Registers the component in a given scene
  51890. */
  51891. register(): void;
  51892. /**
  51893. * Rebuilds the elements related to this component in case of
  51894. * context lost for instance.
  51895. */
  51896. rebuild(): void;
  51897. /**
  51898. * Serializes the component data to the specified json object
  51899. * @param serializationObject The object to serialize to
  51900. */
  51901. serialize(serializationObject: any): void;
  51902. /**
  51903. * Adds all the elements from the container to the scene
  51904. * @param container the container holding the elements
  51905. */
  51906. addFromContainer(container: AbstractScene): void;
  51907. /**
  51908. * Removes all the elements in the container from the scene
  51909. * @param container contains the elements to remove
  51910. * @param dispose if the removed element should be disposed (default: false)
  51911. */
  51912. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51913. /**
  51914. * Rebuilds the elements related to this component in case of
  51915. * context lost for instance.
  51916. */
  51917. dispose(): void;
  51918. private _gatherRenderTargets;
  51919. }
  51920. }
  51921. declare module "babylonjs/Lights/Shadows/index" {
  51922. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51923. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51924. }
  51925. declare module "babylonjs/Lights/pointLight" {
  51926. import { Scene } from "babylonjs/scene";
  51927. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51929. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51930. import { Effect } from "babylonjs/Materials/effect";
  51931. /**
  51932. * A point light is a light defined by an unique point in world space.
  51933. * The light is emitted in every direction from this point.
  51934. * A good example of a point light is a standard light bulb.
  51935. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51936. */
  51937. export class PointLight extends ShadowLight {
  51938. private _shadowAngle;
  51939. /**
  51940. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51941. * This specifies what angle the shadow will use to be created.
  51942. *
  51943. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51944. */
  51945. /**
  51946. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51947. * This specifies what angle the shadow will use to be created.
  51948. *
  51949. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51950. */
  51951. shadowAngle: number;
  51952. /**
  51953. * Gets the direction if it has been set.
  51954. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51955. */
  51956. /**
  51957. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51958. */
  51959. direction: Vector3;
  51960. /**
  51961. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51962. * A PointLight emits the light in every direction.
  51963. * It can cast shadows.
  51964. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51965. * ```javascript
  51966. * var pointLight = new PointLight("pl", camera.position, scene);
  51967. * ```
  51968. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51969. * @param name The light friendly name
  51970. * @param position The position of the point light in the scene
  51971. * @param scene The scene the lights belongs to
  51972. */
  51973. constructor(name: string, position: Vector3, scene: Scene);
  51974. /**
  51975. * Returns the string "PointLight"
  51976. * @returns the class name
  51977. */
  51978. getClassName(): string;
  51979. /**
  51980. * Returns the integer 0.
  51981. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51982. */
  51983. getTypeID(): number;
  51984. /**
  51985. * Specifies wether or not the shadowmap should be a cube texture.
  51986. * @returns true if the shadowmap needs to be a cube texture.
  51987. */
  51988. needCube(): boolean;
  51989. /**
  51990. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51991. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51992. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51993. */
  51994. getShadowDirection(faceIndex?: number): Vector3;
  51995. /**
  51996. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51997. * - fov = PI / 2
  51998. * - aspect ratio : 1.0
  51999. * - z-near and far equal to the active camera minZ and maxZ.
  52000. * Returns the PointLight.
  52001. */
  52002. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52003. protected _buildUniformLayout(): void;
  52004. /**
  52005. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52006. * @param effect The effect to update
  52007. * @param lightIndex The index of the light in the effect to update
  52008. * @returns The point light
  52009. */
  52010. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52011. /**
  52012. * Prepares the list of defines specific to the light type.
  52013. * @param defines the list of defines
  52014. * @param lightIndex defines the index of the light for the effect
  52015. */
  52016. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52017. }
  52018. }
  52019. declare module "babylonjs/Lights/index" {
  52020. export * from "babylonjs/Lights/light";
  52021. export * from "babylonjs/Lights/shadowLight";
  52022. export * from "babylonjs/Lights/Shadows/index";
  52023. export * from "babylonjs/Lights/directionalLight";
  52024. export * from "babylonjs/Lights/hemisphericLight";
  52025. export * from "babylonjs/Lights/pointLight";
  52026. export * from "babylonjs/Lights/spotLight";
  52027. }
  52028. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52029. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52030. /**
  52031. * Header information of HDR texture files.
  52032. */
  52033. export interface HDRInfo {
  52034. /**
  52035. * The height of the texture in pixels.
  52036. */
  52037. height: number;
  52038. /**
  52039. * The width of the texture in pixels.
  52040. */
  52041. width: number;
  52042. /**
  52043. * The index of the beginning of the data in the binary file.
  52044. */
  52045. dataPosition: number;
  52046. }
  52047. /**
  52048. * This groups tools to convert HDR texture to native colors array.
  52049. */
  52050. export class HDRTools {
  52051. private static Ldexp;
  52052. private static Rgbe2float;
  52053. private static readStringLine;
  52054. /**
  52055. * Reads header information from an RGBE texture stored in a native array.
  52056. * More information on this format are available here:
  52057. * https://en.wikipedia.org/wiki/RGBE_image_format
  52058. *
  52059. * @param uint8array The binary file stored in native array.
  52060. * @return The header information.
  52061. */
  52062. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52063. /**
  52064. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52065. * This RGBE texture needs to store the information as a panorama.
  52066. *
  52067. * More information on this format are available here:
  52068. * https://en.wikipedia.org/wiki/RGBE_image_format
  52069. *
  52070. * @param buffer The binary file stored in an array buffer.
  52071. * @param size The expected size of the extracted cubemap.
  52072. * @return The Cube Map information.
  52073. */
  52074. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52075. /**
  52076. * Returns the pixels data extracted from an RGBE texture.
  52077. * This pixels will be stored left to right up to down in the R G B order in one array.
  52078. *
  52079. * More information on this format are available here:
  52080. * https://en.wikipedia.org/wiki/RGBE_image_format
  52081. *
  52082. * @param uint8array The binary file stored in an array buffer.
  52083. * @param hdrInfo The header information of the file.
  52084. * @return The pixels data in RGB right to left up to down order.
  52085. */
  52086. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52087. private static RGBE_ReadPixels_RLE;
  52088. }
  52089. }
  52090. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52091. import { Nullable } from "babylonjs/types";
  52092. import { Scene } from "babylonjs/scene";
  52093. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52095. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52096. /**
  52097. * This represents a texture coming from an HDR input.
  52098. *
  52099. * The only supported format is currently panorama picture stored in RGBE format.
  52100. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52101. */
  52102. export class HDRCubeTexture extends BaseTexture {
  52103. private static _facesMapping;
  52104. private _generateHarmonics;
  52105. private _noMipmap;
  52106. private _textureMatrix;
  52107. private _size;
  52108. private _onLoad;
  52109. private _onError;
  52110. /**
  52111. * The texture URL.
  52112. */
  52113. url: string;
  52114. /**
  52115. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52116. */
  52117. coordinatesMode: number;
  52118. protected _isBlocking: boolean;
  52119. /**
  52120. * Sets wether or not the texture is blocking during loading.
  52121. */
  52122. /**
  52123. * Gets wether or not the texture is blocking during loading.
  52124. */
  52125. isBlocking: boolean;
  52126. protected _rotationY: number;
  52127. /**
  52128. * Sets texture matrix rotation angle around Y axis in radians.
  52129. */
  52130. /**
  52131. * Gets texture matrix rotation angle around Y axis radians.
  52132. */
  52133. rotationY: number;
  52134. /**
  52135. * Gets or sets the center of the bounding box associated with the cube texture
  52136. * It must define where the camera used to render the texture was set
  52137. */
  52138. boundingBoxPosition: Vector3;
  52139. private _boundingBoxSize;
  52140. /**
  52141. * Gets or sets the size of the bounding box associated with the cube texture
  52142. * When defined, the cubemap will switch to local mode
  52143. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52144. * @example https://www.babylonjs-playground.com/#RNASML
  52145. */
  52146. boundingBoxSize: Vector3;
  52147. /**
  52148. * Instantiates an HDRTexture from the following parameters.
  52149. *
  52150. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52151. * @param scene The scene the texture will be used in
  52152. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52153. * @param noMipmap Forces to not generate the mipmap if true
  52154. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52155. * @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)
  52156. * @param reserved Reserved flag for internal use.
  52157. */
  52158. 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>);
  52159. /**
  52160. * Get the current class name of the texture useful for serialization or dynamic coding.
  52161. * @returns "HDRCubeTexture"
  52162. */
  52163. getClassName(): string;
  52164. /**
  52165. * Occurs when the file is raw .hdr file.
  52166. */
  52167. private loadTexture;
  52168. clone(): HDRCubeTexture;
  52169. delayLoad(): void;
  52170. /**
  52171. * Get the texture reflection matrix used to rotate/transform the reflection.
  52172. * @returns the reflection matrix
  52173. */
  52174. getReflectionTextureMatrix(): Matrix;
  52175. /**
  52176. * Set the texture reflection matrix used to rotate/transform the reflection.
  52177. * @param value Define the reflection matrix to set
  52178. */
  52179. setReflectionTextureMatrix(value: Matrix): void;
  52180. /**
  52181. * Parses a JSON representation of an HDR Texture in order to create the texture
  52182. * @param parsedTexture Define the JSON representation
  52183. * @param scene Define the scene the texture should be created in
  52184. * @param rootUrl Define the root url in case we need to load relative dependencies
  52185. * @returns the newly created texture after parsing
  52186. */
  52187. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52188. serialize(): any;
  52189. }
  52190. }
  52191. declare module "babylonjs/Physics/physicsEngine" {
  52192. import { Nullable } from "babylonjs/types";
  52193. import { Vector3 } from "babylonjs/Maths/math.vector";
  52194. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52195. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52196. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52197. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52198. /**
  52199. * Class used to control physics engine
  52200. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52201. */
  52202. export class PhysicsEngine implements IPhysicsEngine {
  52203. private _physicsPlugin;
  52204. /**
  52205. * Global value used to control the smallest number supported by the simulation
  52206. */
  52207. static Epsilon: number;
  52208. private _impostors;
  52209. private _joints;
  52210. /**
  52211. * Gets the gravity vector used by the simulation
  52212. */
  52213. gravity: Vector3;
  52214. /**
  52215. * Factory used to create the default physics plugin.
  52216. * @returns The default physics plugin
  52217. */
  52218. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52219. /**
  52220. * Creates a new Physics Engine
  52221. * @param gravity defines the gravity vector used by the simulation
  52222. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52223. */
  52224. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52225. /**
  52226. * Sets the gravity vector used by the simulation
  52227. * @param gravity defines the gravity vector to use
  52228. */
  52229. setGravity(gravity: Vector3): void;
  52230. /**
  52231. * Set the time step of the physics engine.
  52232. * Default is 1/60.
  52233. * To slow it down, enter 1/600 for example.
  52234. * To speed it up, 1/30
  52235. * @param newTimeStep defines the new timestep to apply to this world.
  52236. */
  52237. setTimeStep(newTimeStep?: number): void;
  52238. /**
  52239. * Get the time step of the physics engine.
  52240. * @returns the current time step
  52241. */
  52242. getTimeStep(): number;
  52243. /**
  52244. * Release all resources
  52245. */
  52246. dispose(): void;
  52247. /**
  52248. * Gets the name of the current physics plugin
  52249. * @returns the name of the plugin
  52250. */
  52251. getPhysicsPluginName(): string;
  52252. /**
  52253. * Adding a new impostor for the impostor tracking.
  52254. * This will be done by the impostor itself.
  52255. * @param impostor the impostor to add
  52256. */
  52257. addImpostor(impostor: PhysicsImpostor): void;
  52258. /**
  52259. * Remove an impostor from the engine.
  52260. * This impostor and its mesh will not longer be updated by the physics engine.
  52261. * @param impostor the impostor to remove
  52262. */
  52263. removeImpostor(impostor: PhysicsImpostor): void;
  52264. /**
  52265. * Add a joint to the physics engine
  52266. * @param mainImpostor defines the main impostor to which the joint is added.
  52267. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52268. * @param joint defines the joint that will connect both impostors.
  52269. */
  52270. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52271. /**
  52272. * Removes a joint from the simulation
  52273. * @param mainImpostor defines the impostor used with the joint
  52274. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52275. * @param joint defines the joint to remove
  52276. */
  52277. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52278. /**
  52279. * Called by the scene. No need to call it.
  52280. * @param delta defines the timespam between frames
  52281. */
  52282. _step(delta: number): void;
  52283. /**
  52284. * Gets the current plugin used to run the simulation
  52285. * @returns current plugin
  52286. */
  52287. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52288. /**
  52289. * Gets the list of physic impostors
  52290. * @returns an array of PhysicsImpostor
  52291. */
  52292. getImpostors(): Array<PhysicsImpostor>;
  52293. /**
  52294. * Gets the impostor for a physics enabled object
  52295. * @param object defines the object impersonated by the impostor
  52296. * @returns the PhysicsImpostor or null if not found
  52297. */
  52298. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52299. /**
  52300. * Gets the impostor for a physics body object
  52301. * @param body defines physics body used by the impostor
  52302. * @returns the PhysicsImpostor or null if not found
  52303. */
  52304. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52305. /**
  52306. * Does a raycast in the physics world
  52307. * @param from when should the ray start?
  52308. * @param to when should the ray end?
  52309. * @returns PhysicsRaycastResult
  52310. */
  52311. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52312. }
  52313. }
  52314. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52315. import { Nullable } from "babylonjs/types";
  52316. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52318. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52319. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52320. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52321. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52322. /** @hidden */
  52323. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52324. private _useDeltaForWorldStep;
  52325. world: any;
  52326. name: string;
  52327. private _physicsMaterials;
  52328. private _fixedTimeStep;
  52329. private _cannonRaycastResult;
  52330. private _raycastResult;
  52331. private _physicsBodysToRemoveAfterStep;
  52332. BJSCANNON: any;
  52333. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52334. setGravity(gravity: Vector3): void;
  52335. setTimeStep(timeStep: number): void;
  52336. getTimeStep(): number;
  52337. executeStep(delta: number): void;
  52338. private _removeMarkedPhysicsBodiesFromWorld;
  52339. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52340. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52341. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52342. private _processChildMeshes;
  52343. removePhysicsBody(impostor: PhysicsImpostor): void;
  52344. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52345. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52346. private _addMaterial;
  52347. private _checkWithEpsilon;
  52348. private _createShape;
  52349. private _createHeightmap;
  52350. private _minus90X;
  52351. private _plus90X;
  52352. private _tmpPosition;
  52353. private _tmpDeltaPosition;
  52354. private _tmpUnityRotation;
  52355. private _updatePhysicsBodyTransformation;
  52356. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52357. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52358. isSupported(): boolean;
  52359. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52360. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52361. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52362. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52363. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52364. getBodyMass(impostor: PhysicsImpostor): number;
  52365. getBodyFriction(impostor: PhysicsImpostor): number;
  52366. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52367. getBodyRestitution(impostor: PhysicsImpostor): number;
  52368. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52369. sleepBody(impostor: PhysicsImpostor): void;
  52370. wakeUpBody(impostor: PhysicsImpostor): void;
  52371. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52372. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52373. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52374. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52375. getRadius(impostor: PhysicsImpostor): number;
  52376. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52377. dispose(): void;
  52378. private _extendNamespace;
  52379. /**
  52380. * Does a raycast in the physics world
  52381. * @param from when should the ray start?
  52382. * @param to when should the ray end?
  52383. * @returns PhysicsRaycastResult
  52384. */
  52385. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52386. }
  52387. }
  52388. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52389. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52390. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52391. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52393. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52394. import { Nullable } from "babylonjs/types";
  52395. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52396. /** @hidden */
  52397. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52398. world: any;
  52399. name: string;
  52400. BJSOIMO: any;
  52401. private _raycastResult;
  52402. constructor(iterations?: number, oimoInjection?: any);
  52403. setGravity(gravity: Vector3): void;
  52404. setTimeStep(timeStep: number): void;
  52405. getTimeStep(): number;
  52406. private _tmpImpostorsArray;
  52407. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52408. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52409. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52410. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52411. private _tmpPositionVector;
  52412. removePhysicsBody(impostor: PhysicsImpostor): void;
  52413. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52414. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52415. isSupported(): boolean;
  52416. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52417. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52418. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52419. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52420. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52421. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52422. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52423. getBodyMass(impostor: PhysicsImpostor): number;
  52424. getBodyFriction(impostor: PhysicsImpostor): number;
  52425. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52426. getBodyRestitution(impostor: PhysicsImpostor): number;
  52427. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52428. sleepBody(impostor: PhysicsImpostor): void;
  52429. wakeUpBody(impostor: PhysicsImpostor): void;
  52430. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52431. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52432. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52433. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52434. getRadius(impostor: PhysicsImpostor): number;
  52435. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52436. dispose(): void;
  52437. /**
  52438. * Does a raycast in the physics world
  52439. * @param from when should the ray start?
  52440. * @param to when should the ray end?
  52441. * @returns PhysicsRaycastResult
  52442. */
  52443. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52444. }
  52445. }
  52446. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52447. import { Nullable } from "babylonjs/types";
  52448. import { Scene } from "babylonjs/scene";
  52449. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52450. import { Color4 } from "babylonjs/Maths/math.color";
  52451. import { Mesh } from "babylonjs/Meshes/mesh";
  52452. /**
  52453. * Class containing static functions to help procedurally build meshes
  52454. */
  52455. export class RibbonBuilder {
  52456. /**
  52457. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52458. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52459. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52460. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52461. * * 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
  52462. * * 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
  52463. * * 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
  52464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52467. * * 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
  52468. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52469. * * 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
  52470. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52472. * @param name defines the name of the mesh
  52473. * @param options defines the options used to create the mesh
  52474. * @param scene defines the hosting scene
  52475. * @returns the ribbon mesh
  52476. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52477. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52478. */
  52479. static CreateRibbon(name: string, options: {
  52480. pathArray: Vector3[][];
  52481. closeArray?: boolean;
  52482. closePath?: boolean;
  52483. offset?: number;
  52484. updatable?: boolean;
  52485. sideOrientation?: number;
  52486. frontUVs?: Vector4;
  52487. backUVs?: Vector4;
  52488. instance?: Mesh;
  52489. invertUV?: boolean;
  52490. uvs?: Vector2[];
  52491. colors?: Color4[];
  52492. }, scene?: Nullable<Scene>): Mesh;
  52493. }
  52494. }
  52495. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52496. import { Nullable } from "babylonjs/types";
  52497. import { Scene } from "babylonjs/scene";
  52498. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52499. import { Mesh } from "babylonjs/Meshes/mesh";
  52500. /**
  52501. * Class containing static functions to help procedurally build meshes
  52502. */
  52503. export class ShapeBuilder {
  52504. /**
  52505. * 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.
  52506. * * 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.
  52507. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52508. * * 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.
  52509. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52510. * * 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
  52511. * * 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
  52512. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52517. * @param name defines the name of the mesh
  52518. * @param options defines the options used to create the mesh
  52519. * @param scene defines the hosting scene
  52520. * @returns the extruded shape mesh
  52521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52523. */
  52524. static ExtrudeShape(name: string, options: {
  52525. shape: Vector3[];
  52526. path: Vector3[];
  52527. scale?: number;
  52528. rotation?: number;
  52529. cap?: number;
  52530. updatable?: boolean;
  52531. sideOrientation?: number;
  52532. frontUVs?: Vector4;
  52533. backUVs?: Vector4;
  52534. instance?: Mesh;
  52535. invertUV?: boolean;
  52536. }, scene?: Nullable<Scene>): Mesh;
  52537. /**
  52538. * Creates an custom extruded shape mesh.
  52539. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52540. * * 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.
  52541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52542. * * 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
  52543. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52544. * * 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
  52545. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52546. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52547. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52548. * * 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
  52549. * * 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
  52550. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52555. * @param name defines the name of the mesh
  52556. * @param options defines the options used to create the mesh
  52557. * @param scene defines the hosting scene
  52558. * @returns the custom extruded shape mesh
  52559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52562. */
  52563. static ExtrudeShapeCustom(name: string, options: {
  52564. shape: Vector3[];
  52565. path: Vector3[];
  52566. scaleFunction?: any;
  52567. rotationFunction?: any;
  52568. ribbonCloseArray?: boolean;
  52569. ribbonClosePath?: boolean;
  52570. cap?: number;
  52571. updatable?: boolean;
  52572. sideOrientation?: number;
  52573. frontUVs?: Vector4;
  52574. backUVs?: Vector4;
  52575. instance?: Mesh;
  52576. invertUV?: boolean;
  52577. }, scene?: Nullable<Scene>): Mesh;
  52578. private static _ExtrudeShapeGeneric;
  52579. }
  52580. }
  52581. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52582. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52583. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52584. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52585. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52586. import { Nullable } from "babylonjs/types";
  52587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52588. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52589. /**
  52590. * AmmoJS Physics plugin
  52591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52592. * @see https://github.com/kripken/ammo.js/
  52593. */
  52594. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52595. private _useDeltaForWorldStep;
  52596. /**
  52597. * Reference to the Ammo library
  52598. */
  52599. bjsAMMO: any;
  52600. /**
  52601. * Created ammoJS world which physics bodies are added to
  52602. */
  52603. world: any;
  52604. /**
  52605. * Name of the plugin
  52606. */
  52607. name: string;
  52608. private _timeStep;
  52609. private _fixedTimeStep;
  52610. private _maxSteps;
  52611. private _tmpQuaternion;
  52612. private _tmpAmmoTransform;
  52613. private _tmpAmmoQuaternion;
  52614. private _tmpAmmoConcreteContactResultCallback;
  52615. private _collisionConfiguration;
  52616. private _dispatcher;
  52617. private _overlappingPairCache;
  52618. private _solver;
  52619. private _softBodySolver;
  52620. private _tmpAmmoVectorA;
  52621. private _tmpAmmoVectorB;
  52622. private _tmpAmmoVectorC;
  52623. private _tmpAmmoVectorD;
  52624. private _tmpContactCallbackResult;
  52625. private _tmpAmmoVectorRCA;
  52626. private _tmpAmmoVectorRCB;
  52627. private _raycastResult;
  52628. private static readonly DISABLE_COLLISION_FLAG;
  52629. private static readonly KINEMATIC_FLAG;
  52630. private static readonly DISABLE_DEACTIVATION_FLAG;
  52631. /**
  52632. * Initializes the ammoJS plugin
  52633. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52634. * @param ammoInjection can be used to inject your own ammo reference
  52635. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52636. */
  52637. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52638. /**
  52639. * Sets the gravity of the physics world (m/(s^2))
  52640. * @param gravity Gravity to set
  52641. */
  52642. setGravity(gravity: Vector3): void;
  52643. /**
  52644. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52645. * @param timeStep timestep to use in seconds
  52646. */
  52647. setTimeStep(timeStep: number): void;
  52648. /**
  52649. * 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)
  52650. * @param fixedTimeStep fixedTimeStep to use in seconds
  52651. */
  52652. setFixedTimeStep(fixedTimeStep: number): void;
  52653. /**
  52654. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52655. * @param maxSteps the maximum number of steps by the physics engine per frame
  52656. */
  52657. setMaxSteps(maxSteps: number): void;
  52658. /**
  52659. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52660. * @returns the current timestep in seconds
  52661. */
  52662. getTimeStep(): number;
  52663. private _isImpostorInContact;
  52664. private _isImpostorPairInContact;
  52665. private _stepSimulation;
  52666. /**
  52667. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52668. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52669. * After the step the babylon meshes are set to the position of the physics imposters
  52670. * @param delta amount of time to step forward
  52671. * @param impostors array of imposters to update before/after the step
  52672. */
  52673. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52674. /**
  52675. * Update babylon mesh to match physics world object
  52676. * @param impostor imposter to match
  52677. */
  52678. private _afterSoftStep;
  52679. /**
  52680. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52681. * @param impostor imposter to match
  52682. */
  52683. private _ropeStep;
  52684. /**
  52685. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52686. * @param impostor imposter to match
  52687. */
  52688. private _softbodyOrClothStep;
  52689. private _tmpVector;
  52690. private _tmpMatrix;
  52691. /**
  52692. * Applies an impulse on the imposter
  52693. * @param impostor imposter to apply impulse to
  52694. * @param force amount of force to be applied to the imposter
  52695. * @param contactPoint the location to apply the impulse on the imposter
  52696. */
  52697. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52698. /**
  52699. * Applies a force on the imposter
  52700. * @param impostor imposter to apply force
  52701. * @param force amount of force to be applied to the imposter
  52702. * @param contactPoint the location to apply the force on the imposter
  52703. */
  52704. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52705. /**
  52706. * Creates a physics body using the plugin
  52707. * @param impostor the imposter to create the physics body on
  52708. */
  52709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52710. /**
  52711. * Removes the physics body from the imposter and disposes of the body's memory
  52712. * @param impostor imposter to remove the physics body from
  52713. */
  52714. removePhysicsBody(impostor: PhysicsImpostor): void;
  52715. /**
  52716. * Generates a joint
  52717. * @param impostorJoint the imposter joint to create the joint with
  52718. */
  52719. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52720. /**
  52721. * Removes a joint
  52722. * @param impostorJoint the imposter joint to remove the joint from
  52723. */
  52724. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52725. private _addMeshVerts;
  52726. /**
  52727. * Initialise the soft body vertices to match its object's (mesh) vertices
  52728. * Softbody vertices (nodes) are in world space and to match this
  52729. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52730. * @param impostor to create the softbody for
  52731. */
  52732. private _softVertexData;
  52733. /**
  52734. * Create an impostor's soft body
  52735. * @param impostor to create the softbody for
  52736. */
  52737. private _createSoftbody;
  52738. /**
  52739. * Create cloth for an impostor
  52740. * @param impostor to create the softbody for
  52741. */
  52742. private _createCloth;
  52743. /**
  52744. * Create rope for an impostor
  52745. * @param impostor to create the softbody for
  52746. */
  52747. private _createRope;
  52748. private _addHullVerts;
  52749. private _createShape;
  52750. /**
  52751. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52752. * @param impostor imposter containing the physics body and babylon object
  52753. */
  52754. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52755. /**
  52756. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52757. * @param impostor imposter containing the physics body and babylon object
  52758. * @param newPosition new position
  52759. * @param newRotation new rotation
  52760. */
  52761. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52762. /**
  52763. * If this plugin is supported
  52764. * @returns true if its supported
  52765. */
  52766. isSupported(): boolean;
  52767. /**
  52768. * Sets the linear velocity of the physics body
  52769. * @param impostor imposter to set the velocity on
  52770. * @param velocity velocity to set
  52771. */
  52772. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52773. /**
  52774. * Sets the angular velocity of the physics body
  52775. * @param impostor imposter to set the velocity on
  52776. * @param velocity velocity to set
  52777. */
  52778. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52779. /**
  52780. * gets the linear velocity
  52781. * @param impostor imposter to get linear velocity from
  52782. * @returns linear velocity
  52783. */
  52784. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52785. /**
  52786. * gets the angular velocity
  52787. * @param impostor imposter to get angular velocity from
  52788. * @returns angular velocity
  52789. */
  52790. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52791. /**
  52792. * Sets the mass of physics body
  52793. * @param impostor imposter to set the mass on
  52794. * @param mass mass to set
  52795. */
  52796. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52797. /**
  52798. * Gets the mass of the physics body
  52799. * @param impostor imposter to get the mass from
  52800. * @returns mass
  52801. */
  52802. getBodyMass(impostor: PhysicsImpostor): number;
  52803. /**
  52804. * Gets friction of the impostor
  52805. * @param impostor impostor to get friction from
  52806. * @returns friction value
  52807. */
  52808. getBodyFriction(impostor: PhysicsImpostor): number;
  52809. /**
  52810. * Sets friction of the impostor
  52811. * @param impostor impostor to set friction on
  52812. * @param friction friction value
  52813. */
  52814. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52815. /**
  52816. * Gets restitution of the impostor
  52817. * @param impostor impostor to get restitution from
  52818. * @returns restitution value
  52819. */
  52820. getBodyRestitution(impostor: PhysicsImpostor): number;
  52821. /**
  52822. * Sets resitution of the impostor
  52823. * @param impostor impostor to set resitution on
  52824. * @param restitution resitution value
  52825. */
  52826. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52827. /**
  52828. * Gets pressure inside the impostor
  52829. * @param impostor impostor to get pressure from
  52830. * @returns pressure value
  52831. */
  52832. getBodyPressure(impostor: PhysicsImpostor): number;
  52833. /**
  52834. * Sets pressure inside a soft body impostor
  52835. * Cloth and rope must remain 0 pressure
  52836. * @param impostor impostor to set pressure on
  52837. * @param pressure pressure value
  52838. */
  52839. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52840. /**
  52841. * Gets stiffness of the impostor
  52842. * @param impostor impostor to get stiffness from
  52843. * @returns pressure value
  52844. */
  52845. getBodyStiffness(impostor: PhysicsImpostor): number;
  52846. /**
  52847. * Sets stiffness of the impostor
  52848. * @param impostor impostor to set stiffness on
  52849. * @param stiffness stiffness value from 0 to 1
  52850. */
  52851. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52852. /**
  52853. * Gets velocityIterations of the impostor
  52854. * @param impostor impostor to get velocity iterations from
  52855. * @returns velocityIterations value
  52856. */
  52857. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52858. /**
  52859. * Sets velocityIterations of the impostor
  52860. * @param impostor impostor to set velocity iterations on
  52861. * @param velocityIterations velocityIterations value
  52862. */
  52863. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52864. /**
  52865. * Gets positionIterations of the impostor
  52866. * @param impostor impostor to get position iterations from
  52867. * @returns positionIterations value
  52868. */
  52869. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52870. /**
  52871. * Sets positionIterations of the impostor
  52872. * @param impostor impostor to set position on
  52873. * @param positionIterations positionIterations value
  52874. */
  52875. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52876. /**
  52877. * Append an anchor to a cloth object
  52878. * @param impostor is the cloth impostor to add anchor to
  52879. * @param otherImpostor is the rigid impostor to anchor to
  52880. * @param width ratio across width from 0 to 1
  52881. * @param height ratio up height from 0 to 1
  52882. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52883. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52884. */
  52885. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52886. /**
  52887. * Append an hook to a rope object
  52888. * @param impostor is the rope impostor to add hook to
  52889. * @param otherImpostor is the rigid impostor to hook to
  52890. * @param length ratio along the rope from 0 to 1
  52891. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52892. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52893. */
  52894. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52895. /**
  52896. * Sleeps the physics body and stops it from being active
  52897. * @param impostor impostor to sleep
  52898. */
  52899. sleepBody(impostor: PhysicsImpostor): void;
  52900. /**
  52901. * Activates the physics body
  52902. * @param impostor impostor to activate
  52903. */
  52904. wakeUpBody(impostor: PhysicsImpostor): void;
  52905. /**
  52906. * Updates the distance parameters of the joint
  52907. * @param joint joint to update
  52908. * @param maxDistance maximum distance of the joint
  52909. * @param minDistance minimum distance of the joint
  52910. */
  52911. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52912. /**
  52913. * Sets a motor on the joint
  52914. * @param joint joint to set motor on
  52915. * @param speed speed of the motor
  52916. * @param maxForce maximum force of the motor
  52917. * @param motorIndex index of the motor
  52918. */
  52919. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52920. /**
  52921. * Sets the motors limit
  52922. * @param joint joint to set limit on
  52923. * @param upperLimit upper limit
  52924. * @param lowerLimit lower limit
  52925. */
  52926. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52927. /**
  52928. * Syncs the position and rotation of a mesh with the impostor
  52929. * @param mesh mesh to sync
  52930. * @param impostor impostor to update the mesh with
  52931. */
  52932. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52933. /**
  52934. * Gets the radius of the impostor
  52935. * @param impostor impostor to get radius from
  52936. * @returns the radius
  52937. */
  52938. getRadius(impostor: PhysicsImpostor): number;
  52939. /**
  52940. * Gets the box size of the impostor
  52941. * @param impostor impostor to get box size from
  52942. * @param result the resulting box size
  52943. */
  52944. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52945. /**
  52946. * Disposes of the impostor
  52947. */
  52948. dispose(): void;
  52949. /**
  52950. * Does a raycast in the physics world
  52951. * @param from when should the ray start?
  52952. * @param to when should the ray end?
  52953. * @returns PhysicsRaycastResult
  52954. */
  52955. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52956. }
  52957. }
  52958. declare module "babylonjs/Probes/reflectionProbe" {
  52959. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52960. import { Vector3 } from "babylonjs/Maths/math.vector";
  52961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52962. import { Nullable } from "babylonjs/types";
  52963. import { Scene } from "babylonjs/scene";
  52964. module "babylonjs/abstractScene" {
  52965. interface AbstractScene {
  52966. /**
  52967. * The list of reflection probes added to the scene
  52968. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52969. */
  52970. reflectionProbes: Array<ReflectionProbe>;
  52971. /**
  52972. * Removes the given reflection probe from this scene.
  52973. * @param toRemove The reflection probe to remove
  52974. * @returns The index of the removed reflection probe
  52975. */
  52976. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52977. /**
  52978. * Adds the given reflection probe to this scene.
  52979. * @param newReflectionProbe The reflection probe to add
  52980. */
  52981. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52982. }
  52983. }
  52984. /**
  52985. * Class used to generate realtime reflection / refraction cube textures
  52986. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52987. */
  52988. export class ReflectionProbe {
  52989. /** defines the name of the probe */
  52990. name: string;
  52991. private _scene;
  52992. private _renderTargetTexture;
  52993. private _projectionMatrix;
  52994. private _viewMatrix;
  52995. private _target;
  52996. private _add;
  52997. private _attachedMesh;
  52998. private _invertYAxis;
  52999. /** Gets or sets probe position (center of the cube map) */
  53000. position: Vector3;
  53001. /**
  53002. * Creates a new reflection probe
  53003. * @param name defines the name of the probe
  53004. * @param size defines the texture resolution (for each face)
  53005. * @param scene defines the hosting scene
  53006. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53007. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53008. */
  53009. constructor(
  53010. /** defines the name of the probe */
  53011. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53012. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53013. samples: number;
  53014. /** Gets or sets the refresh rate to use (on every frame by default) */
  53015. refreshRate: number;
  53016. /**
  53017. * Gets the hosting scene
  53018. * @returns a Scene
  53019. */
  53020. getScene(): Scene;
  53021. /** Gets the internal CubeTexture used to render to */
  53022. readonly cubeTexture: RenderTargetTexture;
  53023. /** Gets the list of meshes to render */
  53024. readonly renderList: Nullable<AbstractMesh[]>;
  53025. /**
  53026. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53027. * @param mesh defines the mesh to attach to
  53028. */
  53029. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53030. /**
  53031. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53032. * @param renderingGroupId The rendering group id corresponding to its index
  53033. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53034. */
  53035. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53036. /**
  53037. * Clean all associated resources
  53038. */
  53039. dispose(): void;
  53040. /**
  53041. * Converts the reflection probe information to a readable string for debug purpose.
  53042. * @param fullDetails Supports for multiple levels of logging within scene loading
  53043. * @returns the human readable reflection probe info
  53044. */
  53045. toString(fullDetails?: boolean): string;
  53046. /**
  53047. * Get the class name of the relfection probe.
  53048. * @returns "ReflectionProbe"
  53049. */
  53050. getClassName(): string;
  53051. /**
  53052. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53053. * @returns The JSON representation of the texture
  53054. */
  53055. serialize(): any;
  53056. /**
  53057. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53058. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53059. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53060. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53061. * @returns The parsed reflection probe if successful
  53062. */
  53063. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53064. }
  53065. }
  53066. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53067. /** @hidden */
  53068. export var _BabylonLoaderRegistered: boolean;
  53069. }
  53070. declare module "babylonjs/Loading/Plugins/index" {
  53071. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53072. }
  53073. declare module "babylonjs/Loading/index" {
  53074. export * from "babylonjs/Loading/loadingScreen";
  53075. export * from "babylonjs/Loading/Plugins/index";
  53076. export * from "babylonjs/Loading/sceneLoader";
  53077. export * from "babylonjs/Loading/sceneLoaderFlags";
  53078. }
  53079. declare module "babylonjs/Materials/Background/index" {
  53080. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53081. }
  53082. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53083. import { Scene } from "babylonjs/scene";
  53084. import { Color3 } from "babylonjs/Maths/math.color";
  53085. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53086. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53087. /**
  53088. * The Physically based simple base material of BJS.
  53089. *
  53090. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53091. * It is used as the base class for both the specGloss and metalRough conventions.
  53092. */
  53093. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53094. /**
  53095. * Number of Simultaneous lights allowed on the material.
  53096. */
  53097. maxSimultaneousLights: number;
  53098. /**
  53099. * If sets to true, disables all the lights affecting the material.
  53100. */
  53101. disableLighting: boolean;
  53102. /**
  53103. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53104. */
  53105. environmentTexture: BaseTexture;
  53106. /**
  53107. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53108. */
  53109. invertNormalMapX: boolean;
  53110. /**
  53111. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53112. */
  53113. invertNormalMapY: boolean;
  53114. /**
  53115. * Normal map used in the model.
  53116. */
  53117. normalTexture: BaseTexture;
  53118. /**
  53119. * Emissivie color used to self-illuminate the model.
  53120. */
  53121. emissiveColor: Color3;
  53122. /**
  53123. * Emissivie texture used to self-illuminate the model.
  53124. */
  53125. emissiveTexture: BaseTexture;
  53126. /**
  53127. * Occlusion Channel Strenght.
  53128. */
  53129. occlusionStrength: number;
  53130. /**
  53131. * Occlusion Texture of the material (adding extra occlusion effects).
  53132. */
  53133. occlusionTexture: BaseTexture;
  53134. /**
  53135. * Defines the alpha limits in alpha test mode.
  53136. */
  53137. alphaCutOff: number;
  53138. /**
  53139. * Gets the current double sided mode.
  53140. */
  53141. /**
  53142. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53143. */
  53144. doubleSided: boolean;
  53145. /**
  53146. * Stores the pre-calculated light information of a mesh in a texture.
  53147. */
  53148. lightmapTexture: BaseTexture;
  53149. /**
  53150. * If true, the light map contains occlusion information instead of lighting info.
  53151. */
  53152. useLightmapAsShadowmap: boolean;
  53153. /**
  53154. * Instantiates a new PBRMaterial instance.
  53155. *
  53156. * @param name The material name
  53157. * @param scene The scene the material will be use in.
  53158. */
  53159. constructor(name: string, scene: Scene);
  53160. getClassName(): string;
  53161. }
  53162. }
  53163. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53164. import { Scene } from "babylonjs/scene";
  53165. import { Color3 } from "babylonjs/Maths/math.color";
  53166. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53167. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53168. /**
  53169. * The PBR material of BJS following the metal roughness convention.
  53170. *
  53171. * This fits to the PBR convention in the GLTF definition:
  53172. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53173. */
  53174. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53175. /**
  53176. * The base color has two different interpretations depending on the value of metalness.
  53177. * When the material is a metal, the base color is the specific measured reflectance value
  53178. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53179. * of the material.
  53180. */
  53181. baseColor: Color3;
  53182. /**
  53183. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53184. * well as opacity information in the alpha channel.
  53185. */
  53186. baseTexture: BaseTexture;
  53187. /**
  53188. * Specifies the metallic scalar value of the material.
  53189. * Can also be used to scale the metalness values of the metallic texture.
  53190. */
  53191. metallic: number;
  53192. /**
  53193. * Specifies the roughness scalar value of the material.
  53194. * Can also be used to scale the roughness values of the metallic texture.
  53195. */
  53196. roughness: number;
  53197. /**
  53198. * Texture containing both the metallic value in the B channel and the
  53199. * roughness value in the G channel to keep better precision.
  53200. */
  53201. metallicRoughnessTexture: BaseTexture;
  53202. /**
  53203. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53204. *
  53205. * @param name The material name
  53206. * @param scene The scene the material will be use in.
  53207. */
  53208. constructor(name: string, scene: Scene);
  53209. /**
  53210. * Return the currrent class name of the material.
  53211. */
  53212. getClassName(): string;
  53213. /**
  53214. * Makes a duplicate of the current material.
  53215. * @param name - name to use for the new material.
  53216. */
  53217. clone(name: string): PBRMetallicRoughnessMaterial;
  53218. /**
  53219. * Serialize the material to a parsable JSON object.
  53220. */
  53221. serialize(): any;
  53222. /**
  53223. * Parses a JSON object correponding to the serialize function.
  53224. */
  53225. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53226. }
  53227. }
  53228. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53229. import { Scene } from "babylonjs/scene";
  53230. import { Color3 } from "babylonjs/Maths/math.color";
  53231. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53232. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53233. /**
  53234. * The PBR material of BJS following the specular glossiness convention.
  53235. *
  53236. * This fits to the PBR convention in the GLTF definition:
  53237. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53238. */
  53239. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53240. /**
  53241. * Specifies the diffuse color of the material.
  53242. */
  53243. diffuseColor: Color3;
  53244. /**
  53245. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53246. * channel.
  53247. */
  53248. diffuseTexture: BaseTexture;
  53249. /**
  53250. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53251. */
  53252. specularColor: Color3;
  53253. /**
  53254. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53255. */
  53256. glossiness: number;
  53257. /**
  53258. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53259. */
  53260. specularGlossinessTexture: BaseTexture;
  53261. /**
  53262. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53263. *
  53264. * @param name The material name
  53265. * @param scene The scene the material will be use in.
  53266. */
  53267. constructor(name: string, scene: Scene);
  53268. /**
  53269. * Return the currrent class name of the material.
  53270. */
  53271. getClassName(): string;
  53272. /**
  53273. * Makes a duplicate of the current material.
  53274. * @param name - name to use for the new material.
  53275. */
  53276. clone(name: string): PBRSpecularGlossinessMaterial;
  53277. /**
  53278. * Serialize the material to a parsable JSON object.
  53279. */
  53280. serialize(): any;
  53281. /**
  53282. * Parses a JSON object correponding to the serialize function.
  53283. */
  53284. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53285. }
  53286. }
  53287. declare module "babylonjs/Materials/PBR/index" {
  53288. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53289. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53290. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53291. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53292. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53293. }
  53294. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53295. import { Nullable } from "babylonjs/types";
  53296. import { Scene } from "babylonjs/scene";
  53297. import { Matrix } from "babylonjs/Maths/math.vector";
  53298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53299. /**
  53300. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53301. * It can help converting any input color in a desired output one. This can then be used to create effects
  53302. * from sepia, black and white to sixties or futuristic rendering...
  53303. *
  53304. * The only supported format is currently 3dl.
  53305. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53306. */
  53307. export class ColorGradingTexture extends BaseTexture {
  53308. /**
  53309. * The current texture matrix. (will always be identity in color grading texture)
  53310. */
  53311. private _textureMatrix;
  53312. /**
  53313. * The texture URL.
  53314. */
  53315. url: string;
  53316. /**
  53317. * Empty line regex stored for GC.
  53318. */
  53319. private static _noneEmptyLineRegex;
  53320. private _engine;
  53321. /**
  53322. * Instantiates a ColorGradingTexture from the following parameters.
  53323. *
  53324. * @param url The location of the color gradind data (currently only supporting 3dl)
  53325. * @param scene The scene the texture will be used in
  53326. */
  53327. constructor(url: string, scene: Scene);
  53328. /**
  53329. * Returns the texture matrix used in most of the material.
  53330. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53331. */
  53332. getTextureMatrix(): Matrix;
  53333. /**
  53334. * Occurs when the file being loaded is a .3dl LUT file.
  53335. */
  53336. private load3dlTexture;
  53337. /**
  53338. * Starts the loading process of the texture.
  53339. */
  53340. private loadTexture;
  53341. /**
  53342. * Clones the color gradind texture.
  53343. */
  53344. clone(): ColorGradingTexture;
  53345. /**
  53346. * Called during delayed load for textures.
  53347. */
  53348. delayLoad(): void;
  53349. /**
  53350. * Parses a color grading texture serialized by Babylon.
  53351. * @param parsedTexture The texture information being parsedTexture
  53352. * @param scene The scene to load the texture in
  53353. * @param rootUrl The root url of the data assets to load
  53354. * @return A color gradind texture
  53355. */
  53356. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53357. /**
  53358. * Serializes the LUT texture to json format.
  53359. */
  53360. serialize(): any;
  53361. }
  53362. }
  53363. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53365. import { Scene } from "babylonjs/scene";
  53366. import { Nullable } from "babylonjs/types";
  53367. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53368. /**
  53369. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53370. */
  53371. export class EquiRectangularCubeTexture extends BaseTexture {
  53372. /** The six faces of the cube. */
  53373. private static _FacesMapping;
  53374. private _noMipmap;
  53375. private _onLoad;
  53376. private _onError;
  53377. /** The size of the cubemap. */
  53378. private _size;
  53379. /** The buffer of the image. */
  53380. private _buffer;
  53381. /** The width of the input image. */
  53382. private _width;
  53383. /** The height of the input image. */
  53384. private _height;
  53385. /** The URL to the image. */
  53386. url: string;
  53387. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53388. coordinatesMode: number;
  53389. /**
  53390. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53391. * @param url The location of the image
  53392. * @param scene The scene the texture will be used in
  53393. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53394. * @param noMipmap Forces to not generate the mipmap if true
  53395. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53396. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53397. * @param onLoad — defines a callback called when texture is loaded
  53398. * @param onError — defines a callback called if there is an error
  53399. */
  53400. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53401. /**
  53402. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53403. */
  53404. private loadImage;
  53405. /**
  53406. * Convert the image buffer into a cubemap and create a CubeTexture.
  53407. */
  53408. private loadTexture;
  53409. /**
  53410. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53411. * @param buffer The ArrayBuffer that should be converted.
  53412. * @returns The buffer as Float32Array.
  53413. */
  53414. private getFloat32ArrayFromArrayBuffer;
  53415. /**
  53416. * Get the current class name of the texture useful for serialization or dynamic coding.
  53417. * @returns "EquiRectangularCubeTexture"
  53418. */
  53419. getClassName(): string;
  53420. /**
  53421. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53422. * @returns A clone of the current EquiRectangularCubeTexture.
  53423. */
  53424. clone(): EquiRectangularCubeTexture;
  53425. }
  53426. }
  53427. declare module "babylonjs/Misc/tga" {
  53428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53429. /**
  53430. * Based on jsTGALoader - Javascript loader for TGA file
  53431. * By Vincent Thibault
  53432. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53433. */
  53434. export class TGATools {
  53435. private static _TYPE_INDEXED;
  53436. private static _TYPE_RGB;
  53437. private static _TYPE_GREY;
  53438. private static _TYPE_RLE_INDEXED;
  53439. private static _TYPE_RLE_RGB;
  53440. private static _TYPE_RLE_GREY;
  53441. private static _ORIGIN_MASK;
  53442. private static _ORIGIN_SHIFT;
  53443. private static _ORIGIN_BL;
  53444. private static _ORIGIN_BR;
  53445. private static _ORIGIN_UL;
  53446. private static _ORIGIN_UR;
  53447. /**
  53448. * Gets the header of a TGA file
  53449. * @param data defines the TGA data
  53450. * @returns the header
  53451. */
  53452. static GetTGAHeader(data: Uint8Array): any;
  53453. /**
  53454. * Uploads TGA content to a Babylon Texture
  53455. * @hidden
  53456. */
  53457. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53458. /** @hidden */
  53459. 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;
  53460. /** @hidden */
  53461. 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;
  53462. /** @hidden */
  53463. 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;
  53464. /** @hidden */
  53465. 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;
  53466. /** @hidden */
  53467. 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;
  53468. /** @hidden */
  53469. 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;
  53470. }
  53471. }
  53472. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53473. import { Nullable } from "babylonjs/types";
  53474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53475. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53476. /**
  53477. * Implementation of the TGA Texture Loader.
  53478. * @hidden
  53479. */
  53480. export class _TGATextureLoader implements IInternalTextureLoader {
  53481. /**
  53482. * Defines wether the loader supports cascade loading the different faces.
  53483. */
  53484. readonly supportCascades: boolean;
  53485. /**
  53486. * This returns if the loader support the current file information.
  53487. * @param extension defines the file extension of the file being loaded
  53488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53489. * @param fallback defines the fallback internal texture if any
  53490. * @param isBase64 defines whether the texture is encoded as a base64
  53491. * @param isBuffer defines whether the texture data are stored as a buffer
  53492. * @returns true if the loader can load the specified file
  53493. */
  53494. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53495. /**
  53496. * Transform the url before loading if required.
  53497. * @param rootUrl the url of the texture
  53498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53499. * @returns the transformed texture
  53500. */
  53501. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53502. /**
  53503. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53504. * @param rootUrl the url of the texture
  53505. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53506. * @returns the fallback texture
  53507. */
  53508. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53509. /**
  53510. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53511. * @param data contains the texture data
  53512. * @param texture defines the BabylonJS internal texture
  53513. * @param createPolynomials will be true if polynomials have been requested
  53514. * @param onLoad defines the callback to trigger once the texture is ready
  53515. * @param onError defines the callback to trigger in case of error
  53516. */
  53517. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53518. /**
  53519. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53520. * @param data contains the texture data
  53521. * @param texture defines the BabylonJS internal texture
  53522. * @param callback defines the method to call once ready to upload
  53523. */
  53524. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53525. }
  53526. }
  53527. declare module "babylonjs/Misc/basis" {
  53528. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53529. /**
  53530. * Info about the .basis files
  53531. */
  53532. class BasisFileInfo {
  53533. /**
  53534. * If the file has alpha
  53535. */
  53536. hasAlpha: boolean;
  53537. /**
  53538. * Info about each image of the basis file
  53539. */
  53540. images: Array<{
  53541. levels: Array<{
  53542. width: number;
  53543. height: number;
  53544. transcodedPixels: ArrayBufferView;
  53545. }>;
  53546. }>;
  53547. }
  53548. /**
  53549. * Result of transcoding a basis file
  53550. */
  53551. class TranscodeResult {
  53552. /**
  53553. * Info about the .basis file
  53554. */
  53555. fileInfo: BasisFileInfo;
  53556. /**
  53557. * Format to use when loading the file
  53558. */
  53559. format: number;
  53560. }
  53561. /**
  53562. * Configuration options for the Basis transcoder
  53563. */
  53564. export class BasisTranscodeConfiguration {
  53565. /**
  53566. * Supported compression formats used to determine the supported output format of the transcoder
  53567. */
  53568. supportedCompressionFormats?: {
  53569. /**
  53570. * etc1 compression format
  53571. */
  53572. etc1?: boolean;
  53573. /**
  53574. * s3tc compression format
  53575. */
  53576. s3tc?: boolean;
  53577. /**
  53578. * pvrtc compression format
  53579. */
  53580. pvrtc?: boolean;
  53581. /**
  53582. * etc2 compression format
  53583. */
  53584. etc2?: boolean;
  53585. };
  53586. /**
  53587. * If mipmap levels should be loaded for transcoded images (Default: true)
  53588. */
  53589. loadMipmapLevels?: boolean;
  53590. /**
  53591. * Index of a single image to load (Default: all images)
  53592. */
  53593. loadSingleImage?: number;
  53594. }
  53595. /**
  53596. * Used to load .Basis files
  53597. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53598. */
  53599. export class BasisTools {
  53600. private static _IgnoreSupportedFormats;
  53601. /**
  53602. * URL to use when loading the basis transcoder
  53603. */
  53604. static JSModuleURL: string;
  53605. /**
  53606. * URL to use when loading the wasm module for the transcoder
  53607. */
  53608. static WasmModuleURL: string;
  53609. /**
  53610. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53611. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53612. * @returns internal format corresponding to the Basis format
  53613. */
  53614. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53615. private static _WorkerPromise;
  53616. private static _Worker;
  53617. private static _actionId;
  53618. private static _CreateWorkerAsync;
  53619. /**
  53620. * Transcodes a loaded image file to compressed pixel data
  53621. * @param imageData image data to transcode
  53622. * @param config configuration options for the transcoding
  53623. * @returns a promise resulting in the transcoded image
  53624. */
  53625. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53626. /**
  53627. * Loads a texture from the transcode result
  53628. * @param texture texture load to
  53629. * @param transcodeResult the result of transcoding the basis file to load from
  53630. */
  53631. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53632. }
  53633. }
  53634. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53635. import { Nullable } from "babylonjs/types";
  53636. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53637. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53638. /**
  53639. * Loader for .basis file format
  53640. */
  53641. export class _BasisTextureLoader implements IInternalTextureLoader {
  53642. /**
  53643. * Defines whether the loader supports cascade loading the different faces.
  53644. */
  53645. readonly supportCascades: boolean;
  53646. /**
  53647. * This returns if the loader support the current file information.
  53648. * @param extension defines the file extension of the file being loaded
  53649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53650. * @param fallback defines the fallback internal texture if any
  53651. * @param isBase64 defines whether the texture is encoded as a base64
  53652. * @param isBuffer defines whether the texture data are stored as a buffer
  53653. * @returns true if the loader can load the specified file
  53654. */
  53655. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53656. /**
  53657. * Transform the url before loading if required.
  53658. * @param rootUrl the url of the texture
  53659. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53660. * @returns the transformed texture
  53661. */
  53662. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53663. /**
  53664. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53665. * @param rootUrl the url of the texture
  53666. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53667. * @returns the fallback texture
  53668. */
  53669. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53670. /**
  53671. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53672. * @param data contains the texture data
  53673. * @param texture defines the BabylonJS internal texture
  53674. * @param createPolynomials will be true if polynomials have been requested
  53675. * @param onLoad defines the callback to trigger once the texture is ready
  53676. * @param onError defines the callback to trigger in case of error
  53677. */
  53678. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53679. /**
  53680. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53681. * @param data contains the texture data
  53682. * @param texture defines the BabylonJS internal texture
  53683. * @param callback defines the method to call once ready to upload
  53684. */
  53685. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53686. }
  53687. }
  53688. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53689. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53690. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53691. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53692. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53693. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53694. }
  53695. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53696. import { Scene } from "babylonjs/scene";
  53697. import { Texture } from "babylonjs/Materials/Textures/texture";
  53698. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53699. /**
  53700. * 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.
  53701. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53702. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53703. */
  53704. export class CustomProceduralTexture extends ProceduralTexture {
  53705. private _animate;
  53706. private _time;
  53707. private _config;
  53708. private _texturePath;
  53709. /**
  53710. * Instantiates a new Custom Procedural Texture.
  53711. * 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.
  53712. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53713. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53714. * @param name Define the name of the texture
  53715. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53716. * @param size Define the size of the texture to create
  53717. * @param scene Define the scene the texture belongs to
  53718. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53719. * @param generateMipMaps Define if the texture should creates mip maps or not
  53720. */
  53721. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53722. private _loadJson;
  53723. /**
  53724. * Is the texture ready to be used ? (rendered at least once)
  53725. * @returns true if ready, otherwise, false.
  53726. */
  53727. isReady(): boolean;
  53728. /**
  53729. * Render the texture to its associated render target.
  53730. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53731. */
  53732. render(useCameraPostProcess?: boolean): void;
  53733. /**
  53734. * Update the list of dependant textures samplers in the shader.
  53735. */
  53736. updateTextures(): void;
  53737. /**
  53738. * Update the uniform values of the procedural texture in the shader.
  53739. */
  53740. updateShaderUniforms(): void;
  53741. /**
  53742. * Define if the texture animates or not.
  53743. */
  53744. animate: boolean;
  53745. }
  53746. }
  53747. declare module "babylonjs/Shaders/noise.fragment" {
  53748. /** @hidden */
  53749. export var noisePixelShader: {
  53750. name: string;
  53751. shader: string;
  53752. };
  53753. }
  53754. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53755. import { Nullable } from "babylonjs/types";
  53756. import { Scene } from "babylonjs/scene";
  53757. import { Texture } from "babylonjs/Materials/Textures/texture";
  53758. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53759. import "babylonjs/Shaders/noise.fragment";
  53760. /**
  53761. * Class used to generate noise procedural textures
  53762. */
  53763. export class NoiseProceduralTexture extends ProceduralTexture {
  53764. private _time;
  53765. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53766. brightness: number;
  53767. /** Defines the number of octaves to process */
  53768. octaves: number;
  53769. /** Defines the level of persistence (0.8 by default) */
  53770. persistence: number;
  53771. /** Gets or sets animation speed factor (default is 1) */
  53772. animationSpeedFactor: number;
  53773. /**
  53774. * Creates a new NoiseProceduralTexture
  53775. * @param name defines the name fo the texture
  53776. * @param size defines the size of the texture (default is 256)
  53777. * @param scene defines the hosting scene
  53778. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53779. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53780. */
  53781. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53782. private _updateShaderUniforms;
  53783. protected _getDefines(): string;
  53784. /** Generate the current state of the procedural texture */
  53785. render(useCameraPostProcess?: boolean): void;
  53786. /**
  53787. * Serializes this noise procedural texture
  53788. * @returns a serialized noise procedural texture object
  53789. */
  53790. serialize(): any;
  53791. /**
  53792. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53793. * @param parsedTexture defines parsed texture data
  53794. * @param scene defines the current scene
  53795. * @param rootUrl defines the root URL containing noise procedural texture information
  53796. * @returns a parsed NoiseProceduralTexture
  53797. */
  53798. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53799. }
  53800. }
  53801. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53802. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53803. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53804. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53805. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53806. }
  53807. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53808. import { Nullable } from "babylonjs/types";
  53809. import { Scene } from "babylonjs/scene";
  53810. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53811. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53812. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53813. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53814. /**
  53815. * Raw cube texture where the raw buffers are passed in
  53816. */
  53817. export class RawCubeTexture extends CubeTexture {
  53818. /**
  53819. * Creates a cube texture where the raw buffers are passed in.
  53820. * @param scene defines the scene the texture is attached to
  53821. * @param data defines the array of data to use to create each face
  53822. * @param size defines the size of the textures
  53823. * @param format defines the format of the data
  53824. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53825. * @param generateMipMaps defines if the engine should generate the mip levels
  53826. * @param invertY defines if data must be stored with Y axis inverted
  53827. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53828. * @param compression defines the compression used (null by default)
  53829. */
  53830. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53831. /**
  53832. * Updates the raw cube texture.
  53833. * @param data defines the data to store
  53834. * @param format defines the data format
  53835. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53836. * @param invertY defines if data must be stored with Y axis inverted
  53837. * @param compression defines the compression used (null by default)
  53838. * @param level defines which level of the texture to update
  53839. */
  53840. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53841. /**
  53842. * Updates a raw cube texture with RGBD encoded data.
  53843. * @param data defines the array of data [mipmap][face] to use to create each face
  53844. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53845. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53846. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53847. * @returns a promsie that resolves when the operation is complete
  53848. */
  53849. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53850. /**
  53851. * Clones the raw cube texture.
  53852. * @return a new cube texture
  53853. */
  53854. clone(): CubeTexture;
  53855. /** @hidden */
  53856. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53857. }
  53858. }
  53859. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53860. import { Scene } from "babylonjs/scene";
  53861. import { Texture } from "babylonjs/Materials/Textures/texture";
  53862. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53863. /**
  53864. * Class used to store 3D textures containing user data
  53865. */
  53866. export class RawTexture3D extends Texture {
  53867. /** Gets or sets the texture format to use */
  53868. format: number;
  53869. private _engine;
  53870. /**
  53871. * Create a new RawTexture3D
  53872. * @param data defines the data of the texture
  53873. * @param width defines the width of the texture
  53874. * @param height defines the height of the texture
  53875. * @param depth defines the depth of the texture
  53876. * @param format defines the texture format to use
  53877. * @param scene defines the hosting scene
  53878. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53879. * @param invertY defines if texture must be stored with Y axis inverted
  53880. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53881. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53882. */
  53883. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53884. /** Gets or sets the texture format to use */
  53885. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53886. /**
  53887. * Update the texture with new data
  53888. * @param data defines the data to store in the texture
  53889. */
  53890. update(data: ArrayBufferView): void;
  53891. }
  53892. }
  53893. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53894. import { Scene } from "babylonjs/scene";
  53895. import { Plane } from "babylonjs/Maths/math.plane";
  53896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53897. /**
  53898. * Creates a refraction texture used by refraction channel of the standard material.
  53899. * It is like a mirror but to see through a material.
  53900. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53901. */
  53902. export class RefractionTexture extends RenderTargetTexture {
  53903. /**
  53904. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53905. * 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.
  53906. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53907. */
  53908. refractionPlane: Plane;
  53909. /**
  53910. * Define how deep under the surface we should see.
  53911. */
  53912. depth: number;
  53913. /**
  53914. * Creates a refraction texture used by refraction channel of the standard material.
  53915. * It is like a mirror but to see through a material.
  53916. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53917. * @param name Define the texture name
  53918. * @param size Define the size of the underlying texture
  53919. * @param scene Define the scene the refraction belongs to
  53920. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53921. */
  53922. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53923. /**
  53924. * Clone the refraction texture.
  53925. * @returns the cloned texture
  53926. */
  53927. clone(): RefractionTexture;
  53928. /**
  53929. * Serialize the texture to a JSON representation you could use in Parse later on
  53930. * @returns the serialized JSON representation
  53931. */
  53932. serialize(): any;
  53933. }
  53934. }
  53935. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53936. import { Nullable } from "babylonjs/types";
  53937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53938. import { Matrix } from "babylonjs/Maths/math.vector";
  53939. import { Engine } from "babylonjs/Engines/engine";
  53940. import { Scene } from "babylonjs/scene";
  53941. /**
  53942. * Defines the options related to the creation of an HtmlElementTexture
  53943. */
  53944. export interface IHtmlElementTextureOptions {
  53945. /**
  53946. * Defines wether mip maps should be created or not.
  53947. */
  53948. generateMipMaps?: boolean;
  53949. /**
  53950. * Defines the sampling mode of the texture.
  53951. */
  53952. samplingMode?: number;
  53953. /**
  53954. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53955. */
  53956. engine: Nullable<Engine>;
  53957. /**
  53958. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53959. */
  53960. scene: Nullable<Scene>;
  53961. }
  53962. /**
  53963. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53964. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53965. * is automatically managed.
  53966. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53967. * in your application.
  53968. *
  53969. * As the update is not automatic, you need to call them manually.
  53970. */
  53971. export class HtmlElementTexture extends BaseTexture {
  53972. /**
  53973. * The texture URL.
  53974. */
  53975. element: HTMLVideoElement | HTMLCanvasElement;
  53976. private static readonly DefaultOptions;
  53977. private _textureMatrix;
  53978. private _engine;
  53979. private _isVideo;
  53980. private _generateMipMaps;
  53981. private _samplingMode;
  53982. /**
  53983. * Instantiates a HtmlElementTexture from the following parameters.
  53984. *
  53985. * @param name Defines the name of the texture
  53986. * @param element Defines the video or canvas the texture is filled with
  53987. * @param options Defines the other none mandatory texture creation options
  53988. */
  53989. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53990. private _createInternalTexture;
  53991. /**
  53992. * Returns the texture matrix used in most of the material.
  53993. */
  53994. getTextureMatrix(): Matrix;
  53995. /**
  53996. * Updates the content of the texture.
  53997. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53998. */
  53999. update(invertY?: Nullable<boolean>): void;
  54000. }
  54001. }
  54002. declare module "babylonjs/Materials/Textures/index" {
  54003. export * from "babylonjs/Materials/Textures/baseTexture";
  54004. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54005. export * from "babylonjs/Materials/Textures/cubeTexture";
  54006. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54007. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54008. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54009. export * from "babylonjs/Materials/Textures/internalTexture";
  54010. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54011. export * from "babylonjs/Materials/Textures/Loaders/index";
  54012. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54013. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54014. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54015. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54016. export * from "babylonjs/Materials/Textures/rawTexture";
  54017. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54018. export * from "babylonjs/Materials/Textures/refractionTexture";
  54019. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54020. export * from "babylonjs/Materials/Textures/texture";
  54021. export * from "babylonjs/Materials/Textures/videoTexture";
  54022. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54023. }
  54024. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54025. /**
  54026. * Enum used to define the target of a block
  54027. */
  54028. export enum NodeMaterialBlockTargets {
  54029. /** Vertex shader */
  54030. Vertex = 1,
  54031. /** Fragment shader */
  54032. Fragment = 2,
  54033. /** Neutral */
  54034. Neutral = 4,
  54035. /** Vertex and Fragment */
  54036. VertexAndFragment = 3
  54037. }
  54038. }
  54039. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54040. /**
  54041. * Defines the kind of connection point for node based material
  54042. */
  54043. export enum NodeMaterialBlockConnectionPointTypes {
  54044. /** Float */
  54045. Float = 1,
  54046. /** Int */
  54047. Int = 2,
  54048. /** Vector2 */
  54049. Vector2 = 4,
  54050. /** Vector3 */
  54051. Vector3 = 8,
  54052. /** Vector4 */
  54053. Vector4 = 16,
  54054. /** Color3 */
  54055. Color3 = 32,
  54056. /** Color4 */
  54057. Color4 = 64,
  54058. /** Matrix */
  54059. Matrix = 128,
  54060. /** Detect type based on connection */
  54061. AutoDetect = 1024,
  54062. /** Output type that will be defined by input type */
  54063. BasedOnInput = 2048
  54064. }
  54065. }
  54066. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54068. /**
  54069. * Root class for all node material optimizers
  54070. */
  54071. export class NodeMaterialOptimizer {
  54072. /**
  54073. * Function used to optimize a NodeMaterial graph
  54074. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54075. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54076. */
  54077. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54078. }
  54079. }
  54080. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54084. import { Scene } from "babylonjs/scene";
  54085. /**
  54086. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54087. */
  54088. export class TransformBlock extends NodeMaterialBlock {
  54089. /**
  54090. * Defines the value to use to complement W value to transform it to a Vector4
  54091. */
  54092. complementW: number;
  54093. /**
  54094. * Defines the value to use to complement z value to transform it to a Vector4
  54095. */
  54096. complementZ: number;
  54097. /**
  54098. * Creates a new TransformBlock
  54099. * @param name defines the block name
  54100. */
  54101. constructor(name: string);
  54102. /**
  54103. * Gets the current class name
  54104. * @returns the class name
  54105. */
  54106. getClassName(): string;
  54107. /**
  54108. * Gets the vector input
  54109. */
  54110. readonly vector: NodeMaterialConnectionPoint;
  54111. /**
  54112. * Gets the output component
  54113. */
  54114. readonly output: NodeMaterialConnectionPoint;
  54115. /**
  54116. * Gets the matrix transform input
  54117. */
  54118. readonly transform: NodeMaterialConnectionPoint;
  54119. protected _buildBlock(state: NodeMaterialBuildState): this;
  54120. serialize(): any;
  54121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54122. protected _dumpPropertiesCode(): string;
  54123. }
  54124. }
  54125. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54129. /**
  54130. * Block used to output the vertex position
  54131. */
  54132. export class VertexOutputBlock extends NodeMaterialBlock {
  54133. /**
  54134. * Creates a new VertexOutputBlock
  54135. * @param name defines the block name
  54136. */
  54137. constructor(name: string);
  54138. /**
  54139. * Gets the current class name
  54140. * @returns the class name
  54141. */
  54142. getClassName(): string;
  54143. /**
  54144. * Gets the vector input component
  54145. */
  54146. readonly vector: NodeMaterialConnectionPoint;
  54147. protected _buildBlock(state: NodeMaterialBuildState): this;
  54148. }
  54149. }
  54150. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54154. /**
  54155. * Block used to output the final color
  54156. */
  54157. export class FragmentOutputBlock extends NodeMaterialBlock {
  54158. /**
  54159. * Create a new FragmentOutputBlock
  54160. * @param name defines the block name
  54161. */
  54162. constructor(name: string);
  54163. /**
  54164. * Gets the current class name
  54165. * @returns the class name
  54166. */
  54167. getClassName(): string;
  54168. /**
  54169. * Gets the rgba input component
  54170. */
  54171. readonly rgba: NodeMaterialConnectionPoint;
  54172. /**
  54173. * Gets the rgb input component
  54174. */
  54175. readonly rgb: NodeMaterialConnectionPoint;
  54176. /**
  54177. * Gets the a input component
  54178. */
  54179. readonly a: NodeMaterialConnectionPoint;
  54180. protected _buildBlock(state: NodeMaterialBuildState): this;
  54181. }
  54182. }
  54183. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54184. /**
  54185. * Enum used to define well known values e.g. values automatically provided by the system
  54186. */
  54187. export enum NodeMaterialWellKnownValues {
  54188. /** World */
  54189. World = 1,
  54190. /** View */
  54191. View = 2,
  54192. /** Projection */
  54193. Projection = 3,
  54194. /** ViewProjection */
  54195. ViewProjection = 4,
  54196. /** WorldView */
  54197. WorldView = 5,
  54198. /** WorldViewProjection */
  54199. WorldViewProjection = 6,
  54200. /** CameraPosition */
  54201. CameraPosition = 7,
  54202. /** Fog Color */
  54203. FogColor = 8
  54204. }
  54205. }
  54206. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54210. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54212. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54213. import { Effect } from "babylonjs/Materials/effect";
  54214. import { Mesh } from "babylonjs/Meshes/mesh";
  54215. import { Nullable } from "babylonjs/types";
  54216. import { Scene } from "babylonjs/scene";
  54217. /**
  54218. * Block used to read a reflection texture from a sampler
  54219. */
  54220. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54221. private _define3DName;
  54222. private _defineCubicName;
  54223. private _defineExplicitName;
  54224. private _defineProjectionName;
  54225. private _defineLocalCubicName;
  54226. private _defineSphericalName;
  54227. private _definePlanarName;
  54228. private _defineEquirectangularName;
  54229. private _defineMirroredEquirectangularFixedName;
  54230. private _defineEquirectangularFixedName;
  54231. private _defineSkyboxName;
  54232. private _cubeSamplerName;
  54233. private _2DSamplerName;
  54234. private _positionUVWName;
  54235. private _directionWName;
  54236. private _reflectionCoordsName;
  54237. private _reflection2DCoordsName;
  54238. private _reflectionColorName;
  54239. private _reflectionMatrixName;
  54240. /**
  54241. * Gets or sets the texture associated with the node
  54242. */
  54243. texture: Nullable<BaseTexture>;
  54244. /**
  54245. * Create a new TextureBlock
  54246. * @param name defines the block name
  54247. */
  54248. constructor(name: string);
  54249. /**
  54250. * Gets the current class name
  54251. * @returns the class name
  54252. */
  54253. getClassName(): string;
  54254. /**
  54255. * Gets the world position input component
  54256. */
  54257. readonly position: NodeMaterialConnectionPoint;
  54258. /**
  54259. * Gets the world position input component
  54260. */
  54261. readonly worldPosition: NodeMaterialConnectionPoint;
  54262. /**
  54263. * Gets the world normal input component
  54264. */
  54265. readonly worldNormal: NodeMaterialConnectionPoint;
  54266. /**
  54267. * Gets the world input component
  54268. */
  54269. readonly world: NodeMaterialConnectionPoint;
  54270. /**
  54271. * Gets the camera (or eye) position component
  54272. */
  54273. readonly cameraPosition: NodeMaterialConnectionPoint;
  54274. /**
  54275. * Gets the view input component
  54276. */
  54277. readonly view: NodeMaterialConnectionPoint;
  54278. /**
  54279. * Gets the rgb output component
  54280. */
  54281. readonly rgb: NodeMaterialConnectionPoint;
  54282. /**
  54283. * Gets the r output component
  54284. */
  54285. readonly r: NodeMaterialConnectionPoint;
  54286. /**
  54287. * Gets the g output component
  54288. */
  54289. readonly g: NodeMaterialConnectionPoint;
  54290. /**
  54291. * Gets the b output component
  54292. */
  54293. readonly b: NodeMaterialConnectionPoint;
  54294. autoConfigure(): void;
  54295. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54296. isReady(): boolean;
  54297. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54298. private _injectVertexCode;
  54299. private _writeOutput;
  54300. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54301. serialize(): any;
  54302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54303. }
  54304. }
  54305. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54307. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54308. import { Scene } from "babylonjs/scene";
  54309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54310. import { Matrix } from "babylonjs/Maths/math.vector";
  54311. import { Mesh } from "babylonjs/Meshes/mesh";
  54312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54313. import { Observable } from "babylonjs/Misc/observable";
  54314. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54315. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54316. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54317. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54318. import { Nullable } from "babylonjs/types";
  54319. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54320. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54321. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54322. /**
  54323. * Interface used to configure the node material editor
  54324. */
  54325. export interface INodeMaterialEditorOptions {
  54326. /** Define the URl to load node editor script */
  54327. editorURL?: string;
  54328. }
  54329. /** @hidden */
  54330. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54331. /** BONES */
  54332. NUM_BONE_INFLUENCERS: number;
  54333. BonesPerMesh: number;
  54334. BONETEXTURE: boolean;
  54335. /** MORPH TARGETS */
  54336. MORPHTARGETS: boolean;
  54337. MORPHTARGETS_NORMAL: boolean;
  54338. MORPHTARGETS_TANGENT: boolean;
  54339. MORPHTARGETS_UV: boolean;
  54340. NUM_MORPH_INFLUENCERS: number;
  54341. /** IMAGE PROCESSING */
  54342. IMAGEPROCESSING: boolean;
  54343. VIGNETTE: boolean;
  54344. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54345. VIGNETTEBLENDMODEOPAQUE: boolean;
  54346. TONEMAPPING: boolean;
  54347. TONEMAPPING_ACES: boolean;
  54348. CONTRAST: boolean;
  54349. EXPOSURE: boolean;
  54350. COLORCURVES: boolean;
  54351. COLORGRADING: boolean;
  54352. COLORGRADING3D: boolean;
  54353. SAMPLER3DGREENDEPTH: boolean;
  54354. SAMPLER3DBGRMAP: boolean;
  54355. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54356. constructor();
  54357. setValue(name: string, value: boolean): void;
  54358. }
  54359. /**
  54360. * Class used to configure NodeMaterial
  54361. */
  54362. export interface INodeMaterialOptions {
  54363. /**
  54364. * Defines if blocks should emit comments
  54365. */
  54366. emitComments: boolean;
  54367. }
  54368. /**
  54369. * Class used to create a node based material built by assembling shader blocks
  54370. */
  54371. export class NodeMaterial extends PushMaterial {
  54372. private static _BuildIdGenerator;
  54373. private _options;
  54374. private _vertexCompilationState;
  54375. private _fragmentCompilationState;
  54376. private _sharedData;
  54377. private _buildId;
  54378. private _buildWasSuccessful;
  54379. private _cachedWorldViewMatrix;
  54380. private _cachedWorldViewProjectionMatrix;
  54381. private _optimizers;
  54382. private _animationFrame;
  54383. /** Define the URl to load node editor script */
  54384. static EditorURL: string;
  54385. private BJSNODEMATERIALEDITOR;
  54386. /** Get the inspector from bundle or global */
  54387. private _getGlobalNodeMaterialEditor;
  54388. /**
  54389. * 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)
  54390. */
  54391. ignoreAlpha: boolean;
  54392. /**
  54393. * Defines the maximum number of lights that can be used in the material
  54394. */
  54395. maxSimultaneousLights: number;
  54396. /**
  54397. * Observable raised when the material is built
  54398. */
  54399. onBuildObservable: Observable<NodeMaterial>;
  54400. /**
  54401. * Gets or sets the root nodes of the material vertex shader
  54402. */
  54403. _vertexOutputNodes: NodeMaterialBlock[];
  54404. /**
  54405. * Gets or sets the root nodes of the material fragment (pixel) shader
  54406. */
  54407. _fragmentOutputNodes: NodeMaterialBlock[];
  54408. /** Gets or sets options to control the node material overall behavior */
  54409. options: INodeMaterialOptions;
  54410. /**
  54411. * Default configuration related to image processing available in the standard Material.
  54412. */
  54413. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54414. /**
  54415. * Gets the image processing configuration used either in this material.
  54416. */
  54417. /**
  54418. * Sets the Default image processing configuration used either in the this material.
  54419. *
  54420. * If sets to null, the scene one is in use.
  54421. */
  54422. imageProcessingConfiguration: ImageProcessingConfiguration;
  54423. /**
  54424. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54425. */
  54426. attachedBlocks: NodeMaterialBlock[];
  54427. /**
  54428. * Create a new node based material
  54429. * @param name defines the material name
  54430. * @param scene defines the hosting scene
  54431. * @param options defines creation option
  54432. */
  54433. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54434. /**
  54435. * Gets the current class name of the material e.g. "NodeMaterial"
  54436. * @returns the class name
  54437. */
  54438. getClassName(): string;
  54439. /**
  54440. * Keep track of the image processing observer to allow dispose and replace.
  54441. */
  54442. private _imageProcessingObserver;
  54443. /**
  54444. * Attaches a new image processing configuration to the Standard Material.
  54445. * @param configuration
  54446. */
  54447. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54448. /**
  54449. * Get a block by its name
  54450. * @param name defines the name of the block to retrieve
  54451. * @returns the required block or null if not found
  54452. */
  54453. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54454. /**
  54455. * Gets the list of input blocks attached to this material
  54456. * @returns an array of InputBlocks
  54457. */
  54458. getInputBlocks(): InputBlock[];
  54459. /**
  54460. * Adds a new optimizer to the list of optimizers
  54461. * @param optimizer defines the optimizers to add
  54462. * @returns the current material
  54463. */
  54464. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54465. /**
  54466. * Remove an optimizer from the list of optimizers
  54467. * @param optimizer defines the optimizers to remove
  54468. * @returns the current material
  54469. */
  54470. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54471. /**
  54472. * Add a new block to the list of output nodes
  54473. * @param node defines the node to add
  54474. * @returns the current material
  54475. */
  54476. addOutputNode(node: NodeMaterialBlock): this;
  54477. /**
  54478. * Remove a block from the list of root nodes
  54479. * @param node defines the node to remove
  54480. * @returns the current material
  54481. */
  54482. removeOutputNode(node: NodeMaterialBlock): this;
  54483. private _addVertexOutputNode;
  54484. private _removeVertexOutputNode;
  54485. private _addFragmentOutputNode;
  54486. private _removeFragmentOutputNode;
  54487. /**
  54488. * Specifies if the material will require alpha blending
  54489. * @returns a boolean specifying if alpha blending is needed
  54490. */
  54491. needAlphaBlending(): boolean;
  54492. /**
  54493. * Specifies if this material should be rendered in alpha test mode
  54494. * @returns a boolean specifying if an alpha test is needed.
  54495. */
  54496. needAlphaTesting(): boolean;
  54497. private _initializeBlock;
  54498. private _resetDualBlocks;
  54499. /**
  54500. * Build the material and generates the inner effect
  54501. * @param verbose defines if the build should log activity
  54502. */
  54503. build(verbose?: boolean): void;
  54504. /**
  54505. * Runs an otpimization phase to try to improve the shader code
  54506. */
  54507. optimize(): void;
  54508. private _prepareDefinesForAttributes;
  54509. /**
  54510. * Get if the submesh is ready to be used and all its information available.
  54511. * Child classes can use it to update shaders
  54512. * @param mesh defines the mesh to check
  54513. * @param subMesh defines which submesh to check
  54514. * @param useInstances specifies that instances should be used
  54515. * @returns a boolean indicating that the submesh is ready or not
  54516. */
  54517. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54518. /**
  54519. * Get a string representing the shaders built by the current node graph
  54520. */
  54521. readonly compiledShaders: string;
  54522. /**
  54523. * Binds the world matrix to the material
  54524. * @param world defines the world transformation matrix
  54525. */
  54526. bindOnlyWorldMatrix(world: Matrix): void;
  54527. /**
  54528. * Binds the submesh to this material by preparing the effect and shader to draw
  54529. * @param world defines the world transformation matrix
  54530. * @param mesh defines the mesh containing the submesh
  54531. * @param subMesh defines the submesh to bind the material to
  54532. */
  54533. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54534. /**
  54535. * Gets the active textures from the material
  54536. * @returns an array of textures
  54537. */
  54538. getActiveTextures(): BaseTexture[];
  54539. /**
  54540. * Gets the list of texture blocks
  54541. * @returns an array of texture blocks
  54542. */
  54543. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54544. /**
  54545. * Specifies if the material uses a texture
  54546. * @param texture defines the texture to check against the material
  54547. * @returns a boolean specifying if the material uses the texture
  54548. */
  54549. hasTexture(texture: BaseTexture): boolean;
  54550. /**
  54551. * Disposes the material
  54552. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54553. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54554. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54555. */
  54556. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54557. /** Creates the node editor window. */
  54558. private _createNodeEditor;
  54559. /**
  54560. * Launch the node material editor
  54561. * @param config Define the configuration of the editor
  54562. * @return a promise fulfilled when the node editor is visible
  54563. */
  54564. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54565. /**
  54566. * Clear the current material
  54567. */
  54568. clear(): void;
  54569. /**
  54570. * Clear the current material and set it to a default state
  54571. */
  54572. setToDefault(): void;
  54573. /**
  54574. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54575. * @param url defines the url to load from
  54576. * @returns a promise that will fullfil when the material is fully loaded
  54577. */
  54578. loadAsync(url: string): Promise<unknown>;
  54579. private _gatherBlocks;
  54580. /**
  54581. * Generate a string containing the code declaration required to create an equivalent of this material
  54582. * @returns a string
  54583. */
  54584. generateCode(): string;
  54585. /**
  54586. * Serializes this material in a JSON representation
  54587. * @returns the serialized material object
  54588. */
  54589. serialize(): any;
  54590. private _restoreConnections;
  54591. /**
  54592. * Clear the current graph and load a new one from a serialization object
  54593. * @param source defines the JSON representation of the material
  54594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54595. */
  54596. loadFromSerialization(source: any, rootUrl?: string): void;
  54597. /**
  54598. * Creates a node material from parsed material data
  54599. * @param source defines the JSON representation of the material
  54600. * @param scene defines the hosting scene
  54601. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54602. * @returns a new node material
  54603. */
  54604. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54605. /**
  54606. * Creates a new node material set to default basic configuration
  54607. * @param name defines the name of the material
  54608. * @param scene defines the hosting scene
  54609. * @returns a new NodeMaterial
  54610. */
  54611. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54612. }
  54613. }
  54614. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54615. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54616. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54617. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54619. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54621. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54622. import { Effect } from "babylonjs/Materials/effect";
  54623. import { Mesh } from "babylonjs/Meshes/mesh";
  54624. import { Nullable } from "babylonjs/types";
  54625. import { Scene } from "babylonjs/scene";
  54626. /**
  54627. * Block used to read a texture from a sampler
  54628. */
  54629. export class TextureBlock extends NodeMaterialBlock {
  54630. private _defineName;
  54631. private _samplerName;
  54632. private _transformedUVName;
  54633. private _textureTransformName;
  54634. private _textureInfoName;
  54635. private _mainUVName;
  54636. private _mainUVDefineName;
  54637. /**
  54638. * Gets or sets the texture associated with the node
  54639. */
  54640. texture: Nullable<BaseTexture>;
  54641. /**
  54642. * Create a new TextureBlock
  54643. * @param name defines the block name
  54644. */
  54645. constructor(name: string);
  54646. /**
  54647. * Gets the current class name
  54648. * @returns the class name
  54649. */
  54650. getClassName(): string;
  54651. /**
  54652. * Gets the uv input component
  54653. */
  54654. readonly uv: NodeMaterialConnectionPoint;
  54655. /**
  54656. * Gets the rgba output component
  54657. */
  54658. readonly rgba: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the rgb output component
  54661. */
  54662. readonly rgb: NodeMaterialConnectionPoint;
  54663. /**
  54664. * Gets the r output component
  54665. */
  54666. readonly r: NodeMaterialConnectionPoint;
  54667. /**
  54668. * Gets the g output component
  54669. */
  54670. readonly g: NodeMaterialConnectionPoint;
  54671. /**
  54672. * Gets the b output component
  54673. */
  54674. readonly b: NodeMaterialConnectionPoint;
  54675. /**
  54676. * Gets the a output component
  54677. */
  54678. readonly a: NodeMaterialConnectionPoint;
  54679. readonly target: NodeMaterialBlockTargets;
  54680. autoConfigure(): void;
  54681. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54683. isReady(): boolean;
  54684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54685. private readonly _isMixed;
  54686. private _injectVertexCode;
  54687. private _writeOutput;
  54688. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54689. protected _dumpPropertiesCode(): string;
  54690. serialize(): any;
  54691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54692. }
  54693. }
  54694. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54697. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54698. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54699. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54700. /**
  54701. * Class used to store shared data between 2 NodeMaterialBuildState
  54702. */
  54703. export class NodeMaterialBuildStateSharedData {
  54704. /**
  54705. * Gets the list of emitted varyings
  54706. */
  54707. temps: string[];
  54708. /**
  54709. * Gets the list of emitted varyings
  54710. */
  54711. varyings: string[];
  54712. /**
  54713. * Gets the varying declaration string
  54714. */
  54715. varyingDeclaration: string;
  54716. /**
  54717. * Input blocks
  54718. */
  54719. inputBlocks: InputBlock[];
  54720. /**
  54721. * Input blocks
  54722. */
  54723. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  54724. /**
  54725. * Bindable blocks (Blocks that need to set data to the effect)
  54726. */
  54727. bindableBlocks: NodeMaterialBlock[];
  54728. /**
  54729. * List of blocks that can provide a compilation fallback
  54730. */
  54731. blocksWithFallbacks: NodeMaterialBlock[];
  54732. /**
  54733. * List of blocks that can provide a define update
  54734. */
  54735. blocksWithDefines: NodeMaterialBlock[];
  54736. /**
  54737. * List of blocks that can provide a repeatable content
  54738. */
  54739. repeatableContentBlocks: NodeMaterialBlock[];
  54740. /**
  54741. * List of blocks that can provide a dynamic list of uniforms
  54742. */
  54743. dynamicUniformBlocks: NodeMaterialBlock[];
  54744. /**
  54745. * List of blocks that can block the isReady function for the material
  54746. */
  54747. blockingBlocks: NodeMaterialBlock[];
  54748. /**
  54749. * Gets the list of animated inputs
  54750. */
  54751. animatedInputs: InputBlock[];
  54752. /**
  54753. * Build Id used to avoid multiple recompilations
  54754. */
  54755. buildId: number;
  54756. /** List of emitted variables */
  54757. variableNames: {
  54758. [key: string]: number;
  54759. };
  54760. /** List of emitted defines */
  54761. defineNames: {
  54762. [key: string]: number;
  54763. };
  54764. /** Should emit comments? */
  54765. emitComments: boolean;
  54766. /** Emit build activity */
  54767. verbose: boolean;
  54768. /**
  54769. * Gets the compilation hints emitted at compilation time
  54770. */
  54771. hints: {
  54772. needWorldViewMatrix: boolean;
  54773. needWorldViewProjectionMatrix: boolean;
  54774. needAlphaBlending: boolean;
  54775. needAlphaTesting: boolean;
  54776. };
  54777. /**
  54778. * List of compilation checks
  54779. */
  54780. checks: {
  54781. emitVertex: boolean;
  54782. emitFragment: boolean;
  54783. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54784. };
  54785. /** Creates a new shared data */
  54786. constructor();
  54787. /**
  54788. * Emits console errors and exceptions if there is a failing check
  54789. */
  54790. emitErrors(): void;
  54791. }
  54792. }
  54793. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54794. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54795. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54796. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54797. /**
  54798. * Class used to store node based material build state
  54799. */
  54800. export class NodeMaterialBuildState {
  54801. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54802. supportUniformBuffers: boolean;
  54803. /**
  54804. * Gets the list of emitted attributes
  54805. */
  54806. attributes: string[];
  54807. /**
  54808. * Gets the list of emitted uniforms
  54809. */
  54810. uniforms: string[];
  54811. /**
  54812. * Gets the list of emitted uniform buffers
  54813. */
  54814. uniformBuffers: string[];
  54815. /**
  54816. * Gets the list of emitted samplers
  54817. */
  54818. samplers: string[];
  54819. /**
  54820. * Gets the list of emitted functions
  54821. */
  54822. functions: {
  54823. [key: string]: string;
  54824. };
  54825. /**
  54826. * Gets the target of the compilation state
  54827. */
  54828. target: NodeMaterialBlockTargets;
  54829. /**
  54830. * Gets the list of emitted counters
  54831. */
  54832. counters: {
  54833. [key: string]: number;
  54834. };
  54835. /**
  54836. * Shared data between multiple NodeMaterialBuildState instances
  54837. */
  54838. sharedData: NodeMaterialBuildStateSharedData;
  54839. /** @hidden */
  54840. _vertexState: NodeMaterialBuildState;
  54841. /** @hidden */
  54842. _attributeDeclaration: string;
  54843. /** @hidden */
  54844. _uniformDeclaration: string;
  54845. /** @hidden */
  54846. _samplerDeclaration: string;
  54847. /** @hidden */
  54848. _varyingTransfer: string;
  54849. private _repeatableContentAnchorIndex;
  54850. /** @hidden */
  54851. _builtCompilationString: string;
  54852. /**
  54853. * Gets the emitted compilation strings
  54854. */
  54855. compilationString: string;
  54856. /**
  54857. * Finalize the compilation strings
  54858. * @param state defines the current compilation state
  54859. */
  54860. finalize(state: NodeMaterialBuildState): void;
  54861. /** @hidden */
  54862. readonly _repeatableContentAnchor: string;
  54863. /** @hidden */
  54864. _getFreeVariableName(prefix: string): string;
  54865. /** @hidden */
  54866. _getFreeDefineName(prefix: string): string;
  54867. /** @hidden */
  54868. _excludeVariableName(name: string): void;
  54869. /** @hidden */
  54870. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54871. /** @hidden */
  54872. _emitFunction(name: string, code: string, comments: string): void;
  54873. /** @hidden */
  54874. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54875. replaceStrings?: {
  54876. search: RegExp;
  54877. replace: string;
  54878. }[];
  54879. repeatKey?: string;
  54880. }): string;
  54881. /** @hidden */
  54882. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54883. repeatKey?: string;
  54884. removeAttributes?: boolean;
  54885. removeUniforms?: boolean;
  54886. removeVaryings?: boolean;
  54887. removeIfDef?: boolean;
  54888. replaceStrings?: {
  54889. search: RegExp;
  54890. replace: string;
  54891. }[];
  54892. }, storeKey?: string): void;
  54893. /** @hidden */
  54894. _registerTempVariable(name: string): boolean;
  54895. /** @hidden */
  54896. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54897. /** @hidden */
  54898. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54899. }
  54900. }
  54901. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54902. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54904. import { Nullable } from "babylonjs/types";
  54905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54906. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54907. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54909. import { Mesh } from "babylonjs/Meshes/mesh";
  54910. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54911. import { Scene } from "babylonjs/scene";
  54912. /**
  54913. * Defines a block that can be used inside a node based material
  54914. */
  54915. export class NodeMaterialBlock {
  54916. private _buildId;
  54917. private _buildTarget;
  54918. private _target;
  54919. private _isFinalMerger;
  54920. private _isInput;
  54921. /** @hidden */
  54922. _codeVariableName: string;
  54923. /** @hidden */
  54924. _inputs: NodeMaterialConnectionPoint[];
  54925. /** @hidden */
  54926. _outputs: NodeMaterialConnectionPoint[];
  54927. /**
  54928. * Gets or sets the name of the block
  54929. */
  54930. name: string;
  54931. /**
  54932. * Gets or sets the unique id of the node
  54933. */
  54934. uniqueId: number;
  54935. /**
  54936. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54937. */
  54938. readonly isFinalMerger: boolean;
  54939. /**
  54940. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54941. */
  54942. readonly isInput: boolean;
  54943. /**
  54944. * Gets or sets the build Id
  54945. */
  54946. buildId: number;
  54947. /**
  54948. * Gets or sets the target of the block
  54949. */
  54950. target: NodeMaterialBlockTargets;
  54951. /**
  54952. * Gets the list of input points
  54953. */
  54954. readonly inputs: NodeMaterialConnectionPoint[];
  54955. /** Gets the list of output points */
  54956. readonly outputs: NodeMaterialConnectionPoint[];
  54957. /**
  54958. * Find an input by its name
  54959. * @param name defines the name of the input to look for
  54960. * @returns the input or null if not found
  54961. */
  54962. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54963. /**
  54964. * Find an output by its name
  54965. * @param name defines the name of the outputto look for
  54966. * @returns the output or null if not found
  54967. */
  54968. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54969. /**
  54970. * Creates a new NodeMaterialBlock
  54971. * @param name defines the block name
  54972. * @param target defines the target of that block (Vertex by default)
  54973. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54974. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54975. */
  54976. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54977. /**
  54978. * Initialize the block and prepare the context for build
  54979. * @param state defines the state that will be used for the build
  54980. */
  54981. initialize(state: NodeMaterialBuildState): void;
  54982. /**
  54983. * Bind data to effect. Will only be called for blocks with isBindable === true
  54984. * @param effect defines the effect to bind data to
  54985. * @param nodeMaterial defines the hosting NodeMaterial
  54986. * @param mesh defines the mesh that will be rendered
  54987. */
  54988. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54989. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54990. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54991. protected _writeFloat(value: number): string;
  54992. /**
  54993. * Gets the current class name e.g. "NodeMaterialBlock"
  54994. * @returns the class name
  54995. */
  54996. getClassName(): string;
  54997. /**
  54998. * Register a new input. Must be called inside a block constructor
  54999. * @param name defines the connection point name
  55000. * @param type defines the connection point type
  55001. * @param isOptional defines a boolean indicating that this input can be omitted
  55002. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55003. * @returns the current block
  55004. */
  55005. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55006. /**
  55007. * Register a new output. Must be called inside a block constructor
  55008. * @param name defines the connection point name
  55009. * @param type defines the connection point type
  55010. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55011. * @returns the current block
  55012. */
  55013. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55014. /**
  55015. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55016. * @param forOutput defines an optional connection point to check compatibility with
  55017. * @returns the first available input or null
  55018. */
  55019. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55020. /**
  55021. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55022. * @param forBlock defines an optional block to check compatibility with
  55023. * @returns the first available input or null
  55024. */
  55025. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55026. /**
  55027. * Gets the sibling of the given output
  55028. * @param current defines the current output
  55029. * @returns the next output in the list or null
  55030. */
  55031. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55032. /**
  55033. * Connect current block with another block
  55034. * @param other defines the block to connect with
  55035. * @param options define the various options to help pick the right connections
  55036. * @returns the current block
  55037. */
  55038. connectTo(other: NodeMaterialBlock, options?: {
  55039. input?: string;
  55040. output?: string;
  55041. outputSwizzle?: string;
  55042. }): this | undefined;
  55043. protected _buildBlock(state: NodeMaterialBuildState): void;
  55044. /**
  55045. * Add uniforms, samplers and uniform buffers at compilation time
  55046. * @param state defines the state to update
  55047. * @param nodeMaterial defines the node material requesting the update
  55048. * @param defines defines the material defines to update
  55049. */
  55050. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55051. /**
  55052. * Add potential fallbacks if shader compilation fails
  55053. * @param mesh defines the mesh to be rendered
  55054. * @param fallbacks defines the current prioritized list of fallbacks
  55055. */
  55056. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55057. /**
  55058. * Update defines for shader compilation
  55059. * @param mesh defines the mesh to be rendered
  55060. * @param nodeMaterial defines the node material requesting the update
  55061. * @param defines defines the material defines to update
  55062. * @param useInstances specifies that instances should be used
  55063. */
  55064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55065. /**
  55066. * Initialize defines for shader compilation
  55067. * @param mesh defines the mesh to be rendered
  55068. * @param nodeMaterial defines the node material requesting the update
  55069. * @param defines defines the material defines to be prepared
  55070. * @param useInstances specifies that instances should be used
  55071. */
  55072. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55073. /**
  55074. * Lets the block try to connect some inputs automatically
  55075. * @param material defines the hosting NodeMaterial
  55076. */
  55077. autoConfigure(material: NodeMaterial): void;
  55078. /**
  55079. * Function called when a block is declared as repeatable content generator
  55080. * @param vertexShaderState defines the current compilation state for the vertex shader
  55081. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55082. * @param mesh defines the mesh to be rendered
  55083. * @param defines defines the material defines to update
  55084. */
  55085. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55086. /**
  55087. * Checks if the block is ready
  55088. * @param mesh defines the mesh to be rendered
  55089. * @param nodeMaterial defines the node material requesting the update
  55090. * @param defines defines the material defines to update
  55091. * @param useInstances specifies that instances should be used
  55092. * @returns true if the block is ready
  55093. */
  55094. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55095. private _processBuild;
  55096. /**
  55097. * Compile the current node and generate the shader code
  55098. * @param state defines the current compilation state (uniforms, samplers, current string)
  55099. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55100. * @returns true if already built
  55101. */
  55102. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55103. protected _inputRename(name: string): string;
  55104. protected _outputRename(name: string): string;
  55105. protected _dumpPropertiesCode(): string;
  55106. /** @hidden */
  55107. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55108. /**
  55109. * Clone the current block to a new identical block
  55110. * @param scene defines the hosting scene
  55111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55112. * @returns a copy of the current block
  55113. */
  55114. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55115. /**
  55116. * Serializes this block in a JSON representation
  55117. * @returns the serialized block object
  55118. */
  55119. serialize(): any;
  55120. /** @hidden */
  55121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55122. }
  55123. }
  55124. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55125. /**
  55126. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55127. */
  55128. export enum NodeMaterialBlockConnectionPointMode {
  55129. /** Value is an uniform */
  55130. Uniform = 0,
  55131. /** Value is a mesh attribute */
  55132. Attribute = 1,
  55133. /** Value is a varying between vertex and fragment shaders */
  55134. Varying = 2,
  55135. /** Mode is undefined */
  55136. Undefined = 3
  55137. }
  55138. }
  55139. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55140. /**
  55141. * Enum defining the type of animations supported by InputBlock
  55142. */
  55143. export enum AnimatedInputBlockTypes {
  55144. /** No animation */
  55145. None = 0,
  55146. /** Time based animation. Will only work for floats */
  55147. Time = 1
  55148. }
  55149. }
  55150. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55152. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55153. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55154. import { Nullable } from "babylonjs/types";
  55155. import { Effect } from "babylonjs/Materials/effect";
  55156. import { Matrix } from "babylonjs/Maths/math.vector";
  55157. import { Scene } from "babylonjs/scene";
  55158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55160. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55161. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55162. /**
  55163. * Block used to expose an input value
  55164. */
  55165. export class InputBlock extends NodeMaterialBlock {
  55166. private _mode;
  55167. private _associatedVariableName;
  55168. private _storedValue;
  55169. private _valueCallback;
  55170. private _type;
  55171. private _animationType;
  55172. /** @hidden */
  55173. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55174. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55175. visibleInInspector: boolean;
  55176. /**
  55177. * Gets or sets the connection point type (default is float)
  55178. */
  55179. readonly type: NodeMaterialBlockConnectionPointTypes;
  55180. /**
  55181. * Creates a new InputBlock
  55182. * @param name defines the block name
  55183. * @param target defines the target of that block (Vertex by default)
  55184. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55185. */
  55186. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55187. /**
  55188. * Gets the output component
  55189. */
  55190. readonly output: NodeMaterialConnectionPoint;
  55191. /**
  55192. * Set the source of this connection point to a vertex attribute
  55193. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55194. * @returns the current connection point
  55195. */
  55196. setAsAttribute(attributeName?: string): InputBlock;
  55197. /**
  55198. * Set the source of this connection point to a well known value
  55199. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  55200. * @returns the current connection point
  55201. */
  55202. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  55203. /**
  55204. * Gets or sets the value of that point.
  55205. * Please note that this value will be ignored if valueCallback is defined
  55206. */
  55207. value: any;
  55208. /**
  55209. * Gets or sets a callback used to get the value of that point.
  55210. * Please note that setting this value will force the connection point to ignore the value property
  55211. */
  55212. valueCallback: () => any;
  55213. /**
  55214. * Gets or sets the associated variable name in the shader
  55215. */
  55216. associatedVariableName: string;
  55217. /** Gets or sets the type of animation applied to the input */
  55218. animationType: AnimatedInputBlockTypes;
  55219. /**
  55220. * Gets a boolean indicating that this connection point not defined yet
  55221. */
  55222. readonly isUndefined: boolean;
  55223. /**
  55224. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55225. * In this case the connection point name must be the name of the uniform to use.
  55226. * Can only be set on inputs
  55227. */
  55228. isUniform: boolean;
  55229. /**
  55230. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55231. * In this case the connection point name must be the name of the attribute to use
  55232. * Can only be set on inputs
  55233. */
  55234. isAttribute: boolean;
  55235. /**
  55236. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55237. * Can only be set on exit points
  55238. */
  55239. isVarying: boolean;
  55240. /**
  55241. * Gets a boolean indicating that the current connection point is a well known value
  55242. */
  55243. readonly isWellKnownValue: boolean;
  55244. /**
  55245. * Gets or sets the current well known value or null if not defined as well know value
  55246. */
  55247. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55248. /**
  55249. * Gets the current class name
  55250. * @returns the class name
  55251. */
  55252. getClassName(): string;
  55253. /**
  55254. * Animate the input if animationType !== None
  55255. * @param scene defines the rendering scene
  55256. */
  55257. animate(scene: Scene): void;
  55258. private _emitDefine;
  55259. /**
  55260. * Set the input block to its default value (based on its type)
  55261. */
  55262. setDefaultValue(): void;
  55263. protected _dumpPropertiesCode(): string;
  55264. private _emit;
  55265. /** @hidden */
  55266. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55267. /** @hidden */
  55268. _transmit(effect: Effect, scene: Scene): void;
  55269. protected _buildBlock(state: NodeMaterialBuildState): void;
  55270. serialize(): any;
  55271. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55272. }
  55273. }
  55274. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55275. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55276. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55277. import { Nullable } from "babylonjs/types";
  55278. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55280. /**
  55281. * Defines a connection point for a block
  55282. */
  55283. export class NodeMaterialConnectionPoint {
  55284. /** @hidden */
  55285. _ownerBlock: NodeMaterialBlock;
  55286. /** @hidden */
  55287. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55288. private _endpoints;
  55289. private _associatedVariableName;
  55290. /** @hidden */
  55291. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55292. private _type;
  55293. /** @hidden */
  55294. _enforceAssociatedVariableName: boolean;
  55295. /**
  55296. * Gets or sets the additional types supported byt this connection point
  55297. */
  55298. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55299. /**
  55300. * Gets or sets the associated variable name in the shader
  55301. */
  55302. associatedVariableName: string;
  55303. /**
  55304. * Gets or sets the connection point type (default is float)
  55305. */
  55306. type: NodeMaterialBlockConnectionPointTypes;
  55307. /**
  55308. * Gets or sets the connection point name
  55309. */
  55310. name: string;
  55311. /**
  55312. * Gets or sets a boolean indicating that this connection point can be omitted
  55313. */
  55314. isOptional: boolean;
  55315. /**
  55316. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55317. */
  55318. define: string;
  55319. /** Gets or sets the target of that connection point */
  55320. target: NodeMaterialBlockTargets;
  55321. /**
  55322. * Gets a boolean indicating that the current point is connected
  55323. */
  55324. readonly isConnected: boolean;
  55325. /**
  55326. * Gets a boolean indicating that the current point is connected to an input block
  55327. */
  55328. readonly isConnectedToInputBlock: boolean;
  55329. /**
  55330. * Gets a the connected input block (if any)
  55331. */
  55332. readonly connectInputBlock: Nullable<InputBlock>;
  55333. /** Get the other side of the connection (if any) */
  55334. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55335. /** Get the block that owns this connection point */
  55336. readonly ownerBlock: NodeMaterialBlock;
  55337. /** Get the block connected on the other side of this connection (if any) */
  55338. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55339. /** Get the block connected on the endpoints of this connection (if any) */
  55340. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55341. /** Gets the list of connected endpoints */
  55342. readonly endpoints: NodeMaterialConnectionPoint[];
  55343. /** Gets a boolean indicating if that output point is connected to at least one input */
  55344. readonly hasEndpoints: boolean;
  55345. /**
  55346. * Creates a new connection point
  55347. * @param name defines the connection point name
  55348. * @param ownerBlock defines the block hosting this connection point
  55349. */
  55350. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55351. /**
  55352. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55353. * @returns the class name
  55354. */
  55355. getClassName(): string;
  55356. /**
  55357. * Gets an boolean indicating if the current point can be connected to another point
  55358. * @param connectionPoint defines the other connection point
  55359. * @returns true if the connection is possible
  55360. */
  55361. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55362. /**
  55363. * Connect this point to another connection point
  55364. * @param connectionPoint defines the other connection point
  55365. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55366. * @returns the current connection point
  55367. */
  55368. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55369. /**
  55370. * Disconnect this point from one of his endpoint
  55371. * @param endpoint defines the other connection point
  55372. * @returns the current connection point
  55373. */
  55374. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55375. /**
  55376. * Serializes this point in a JSON representation
  55377. * @returns the serialized point object
  55378. */
  55379. serialize(): any;
  55380. }
  55381. }
  55382. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55386. import { Mesh } from "babylonjs/Meshes/mesh";
  55387. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55388. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55389. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55390. /**
  55391. * Block used to add support for vertex skinning (bones)
  55392. */
  55393. export class BonesBlock extends NodeMaterialBlock {
  55394. /**
  55395. * Creates a new BonesBlock
  55396. * @param name defines the block name
  55397. */
  55398. constructor(name: string);
  55399. /**
  55400. * Initialize the block and prepare the context for build
  55401. * @param state defines the state that will be used for the build
  55402. */
  55403. initialize(state: NodeMaterialBuildState): void;
  55404. /**
  55405. * Gets the current class name
  55406. * @returns the class name
  55407. */
  55408. getClassName(): string;
  55409. /**
  55410. * Gets the matrix indices input component
  55411. */
  55412. readonly matricesIndices: NodeMaterialConnectionPoint;
  55413. /**
  55414. * Gets the matrix weights input component
  55415. */
  55416. readonly matricesWeights: NodeMaterialConnectionPoint;
  55417. /**
  55418. * Gets the extra matrix indices input component
  55419. */
  55420. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55421. /**
  55422. * Gets the extra matrix weights input component
  55423. */
  55424. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55425. /**
  55426. * Gets the world input component
  55427. */
  55428. readonly world: NodeMaterialConnectionPoint;
  55429. /**
  55430. * Gets the output component
  55431. */
  55432. readonly output: NodeMaterialConnectionPoint;
  55433. autoConfigure(): void;
  55434. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55435. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55436. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55437. protected _buildBlock(state: NodeMaterialBuildState): this;
  55438. }
  55439. }
  55440. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55445. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55446. /**
  55447. * Block used to add support for instances
  55448. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55449. */
  55450. export class InstancesBlock extends NodeMaterialBlock {
  55451. /**
  55452. * Creates a new InstancesBlock
  55453. * @param name defines the block name
  55454. */
  55455. constructor(name: string);
  55456. /**
  55457. * Gets the current class name
  55458. * @returns the class name
  55459. */
  55460. getClassName(): string;
  55461. /**
  55462. * Gets the first world row input component
  55463. */
  55464. readonly world0: NodeMaterialConnectionPoint;
  55465. /**
  55466. * Gets the second world row input component
  55467. */
  55468. readonly world1: NodeMaterialConnectionPoint;
  55469. /**
  55470. * Gets the third world row input component
  55471. */
  55472. readonly world2: NodeMaterialConnectionPoint;
  55473. /**
  55474. * Gets the forth world row input component
  55475. */
  55476. readonly world3: NodeMaterialConnectionPoint;
  55477. /**
  55478. * Gets the world input component
  55479. */
  55480. readonly world: NodeMaterialConnectionPoint;
  55481. /**
  55482. * Gets the output component
  55483. */
  55484. readonly output: NodeMaterialConnectionPoint;
  55485. autoConfigure(): void;
  55486. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55487. protected _buildBlock(state: NodeMaterialBuildState): this;
  55488. }
  55489. }
  55490. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55495. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55496. import { Effect } from "babylonjs/Materials/effect";
  55497. import { Mesh } from "babylonjs/Meshes/mesh";
  55498. /**
  55499. * Block used to add morph targets support to vertex shader
  55500. */
  55501. export class MorphTargetsBlock extends NodeMaterialBlock {
  55502. private _repeatableContentAnchor;
  55503. private _repeatebleContentGenerated;
  55504. /**
  55505. * Create a new MorphTargetsBlock
  55506. * @param name defines the block name
  55507. */
  55508. constructor(name: string);
  55509. /**
  55510. * Gets the current class name
  55511. * @returns the class name
  55512. */
  55513. getClassName(): string;
  55514. /**
  55515. * Gets the position input component
  55516. */
  55517. readonly position: NodeMaterialConnectionPoint;
  55518. /**
  55519. * Gets the normal input component
  55520. */
  55521. readonly normal: NodeMaterialConnectionPoint;
  55522. /**
  55523. * Gets the tangent input component
  55524. */
  55525. readonly tangent: NodeMaterialConnectionPoint;
  55526. /**
  55527. * Gets the tangent input component
  55528. */
  55529. readonly uv: NodeMaterialConnectionPoint;
  55530. /**
  55531. * Gets the position output component
  55532. */
  55533. readonly positionOutput: NodeMaterialConnectionPoint;
  55534. /**
  55535. * Gets the normal output component
  55536. */
  55537. readonly normalOutput: NodeMaterialConnectionPoint;
  55538. /**
  55539. * Gets the tangent output component
  55540. */
  55541. readonly tangentOutput: NodeMaterialConnectionPoint;
  55542. /**
  55543. * Gets the tangent output component
  55544. */
  55545. readonly uvOutput: NodeMaterialConnectionPoint;
  55546. initialize(state: NodeMaterialBuildState): void;
  55547. autoConfigure(): void;
  55548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55549. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55550. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55551. protected _buildBlock(state: NodeMaterialBuildState): this;
  55552. }
  55553. }
  55554. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55555. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55556. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55557. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55558. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55559. }
  55560. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55564. import { Scene } from "babylonjs/scene";
  55565. /**
  55566. * Block used to add an alpha test in the fragment shader
  55567. */
  55568. export class AlphaTestBlock extends NodeMaterialBlock {
  55569. /**
  55570. * Gets or sets the alpha value where alpha testing happens
  55571. */
  55572. alphaCutOff: number;
  55573. /**
  55574. * Create a new AlphaTestBlock
  55575. * @param name defines the block name
  55576. */
  55577. constructor(name: string);
  55578. /**
  55579. * Gets the current class name
  55580. * @returns the class name
  55581. */
  55582. getClassName(): string;
  55583. /**
  55584. * Gets the color input component
  55585. */
  55586. readonly color: NodeMaterialConnectionPoint;
  55587. /**
  55588. * Gets the alpha input component
  55589. */
  55590. readonly alpha: NodeMaterialConnectionPoint;
  55591. protected _buildBlock(state: NodeMaterialBuildState): this;
  55592. protected _dumpPropertiesCode(): string;
  55593. serialize(): any;
  55594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55595. }
  55596. }
  55597. declare module "babylonjs/Materials/Node/Blocks/Fragment/fresnelBlock" {
  55598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55601. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55602. /**
  55603. * Block used to compute fresnel value
  55604. */
  55605. export class FresnelBlock extends NodeMaterialBlock {
  55606. /**
  55607. * Create a new FresnelBlock
  55608. * @param name defines the block name
  55609. */
  55610. constructor(name: string);
  55611. /**
  55612. * Gets the current class name
  55613. * @returns the class name
  55614. */
  55615. getClassName(): string;
  55616. /**
  55617. * Gets the world position input component
  55618. */
  55619. readonly worldPosition: NodeMaterialConnectionPoint;
  55620. /**
  55621. * Gets the world normal input component
  55622. */
  55623. readonly worldNormal: NodeMaterialConnectionPoint;
  55624. /**
  55625. * Gets the camera (or eye) position component
  55626. */
  55627. readonly cameraPosition: NodeMaterialConnectionPoint;
  55628. /**
  55629. * Gets the bias input component
  55630. */
  55631. readonly bias: NodeMaterialConnectionPoint;
  55632. /**
  55633. * Gets the camera (or eye) position component
  55634. */
  55635. readonly power: NodeMaterialConnectionPoint;
  55636. /**
  55637. * Gets the fresnel output component
  55638. */
  55639. readonly fresnel: NodeMaterialConnectionPoint;
  55640. autoConfigure(material: NodeMaterial): void;
  55641. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55642. }
  55643. }
  55644. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55649. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55650. import { Effect } from "babylonjs/Materials/effect";
  55651. import { Mesh } from "babylonjs/Meshes/mesh";
  55652. /**
  55653. * Block used to add image processing support to fragment shader
  55654. */
  55655. export class ImageProcessingBlock extends NodeMaterialBlock {
  55656. /**
  55657. * Create a new ImageProcessingBlock
  55658. * @param name defines the block name
  55659. */
  55660. constructor(name: string);
  55661. /**
  55662. * Gets the current class name
  55663. * @returns the class name
  55664. */
  55665. getClassName(): string;
  55666. /**
  55667. * Gets the color input component
  55668. */
  55669. readonly color: NodeMaterialConnectionPoint;
  55670. /**
  55671. * Gets the output component
  55672. */
  55673. readonly output: NodeMaterialConnectionPoint;
  55674. /**
  55675. * Initialize the block and prepare the context for build
  55676. * @param state defines the state that will be used for the build
  55677. */
  55678. initialize(state: NodeMaterialBuildState): void;
  55679. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55681. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55682. protected _buildBlock(state: NodeMaterialBuildState): this;
  55683. }
  55684. }
  55685. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55686. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55687. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55688. export * from "babylonjs/Materials/Node/Blocks/Fragment/fresnelBlock";
  55689. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55690. }
  55691. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55694. import { Mesh } from "babylonjs/Meshes/mesh";
  55695. import { Effect } from "babylonjs/Materials/effect";
  55696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55698. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55699. /**
  55700. * Block used to add support for scene fog
  55701. */
  55702. export class FogBlock extends NodeMaterialBlock {
  55703. private _fogDistanceName;
  55704. private _fogParameters;
  55705. /**
  55706. * Create a new FogBlock
  55707. * @param name defines the block name
  55708. */
  55709. constructor(name: string);
  55710. /**
  55711. * Gets the current class name
  55712. * @returns the class name
  55713. */
  55714. getClassName(): string;
  55715. /**
  55716. * Gets the world position input component
  55717. */
  55718. readonly worldPosition: NodeMaterialConnectionPoint;
  55719. /**
  55720. * Gets the view input component
  55721. */
  55722. readonly view: NodeMaterialConnectionPoint;
  55723. /**
  55724. * Gets the color input component
  55725. */
  55726. readonly input: NodeMaterialConnectionPoint;
  55727. /**
  55728. * Gets the fog color input component
  55729. */
  55730. readonly fogColor: NodeMaterialConnectionPoint;
  55731. /**
  55732. * Gets the output component
  55733. */
  55734. readonly output: NodeMaterialConnectionPoint;
  55735. autoConfigure(): void;
  55736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55738. protected _buildBlock(state: NodeMaterialBuildState): this;
  55739. }
  55740. }
  55741. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55746. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55747. import { Effect } from "babylonjs/Materials/effect";
  55748. import { Mesh } from "babylonjs/Meshes/mesh";
  55749. import { Light } from "babylonjs/Lights/light";
  55750. import { Nullable } from "babylonjs/types";
  55751. import { Scene } from "babylonjs/scene";
  55752. /**
  55753. * Block used to add light in the fragment shader
  55754. */
  55755. export class LightBlock extends NodeMaterialBlock {
  55756. private _lightId;
  55757. /**
  55758. * Gets or sets the light associated with this block
  55759. */
  55760. light: Nullable<Light>;
  55761. /**
  55762. * Create a new LightBlock
  55763. * @param name defines the block name
  55764. */
  55765. constructor(name: string);
  55766. /**
  55767. * Gets the current class name
  55768. * @returns the class name
  55769. */
  55770. getClassName(): string;
  55771. /**
  55772. * Gets the world position input component
  55773. */
  55774. readonly worldPosition: NodeMaterialConnectionPoint;
  55775. /**
  55776. * Gets the world normal input component
  55777. */
  55778. readonly worldNormal: NodeMaterialConnectionPoint;
  55779. /**
  55780. * Gets the camera (or eye) position component
  55781. */
  55782. readonly cameraPosition: NodeMaterialConnectionPoint;
  55783. /**
  55784. * Gets the diffuse output component
  55785. */
  55786. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55787. /**
  55788. * Gets the specular output component
  55789. */
  55790. readonly specularOutput: NodeMaterialConnectionPoint;
  55791. autoConfigure(): void;
  55792. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55793. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55794. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55795. private _injectVertexCode;
  55796. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55797. serialize(): any;
  55798. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55799. }
  55800. }
  55801. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55802. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55803. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55804. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55805. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55806. }
  55807. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55808. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55809. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55810. }
  55811. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55812. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55815. /**
  55816. * Block used to multiply 2 values
  55817. */
  55818. export class MultiplyBlock extends NodeMaterialBlock {
  55819. /**
  55820. * Creates a new MultiplyBlock
  55821. * @param name defines the block name
  55822. */
  55823. constructor(name: string);
  55824. /**
  55825. * Gets the current class name
  55826. * @returns the class name
  55827. */
  55828. getClassName(): string;
  55829. /**
  55830. * Gets the left operand input component
  55831. */
  55832. readonly left: NodeMaterialConnectionPoint;
  55833. /**
  55834. * Gets the right operand input component
  55835. */
  55836. readonly right: NodeMaterialConnectionPoint;
  55837. /**
  55838. * Gets the output component
  55839. */
  55840. readonly output: NodeMaterialConnectionPoint;
  55841. protected _buildBlock(state: NodeMaterialBuildState): this;
  55842. }
  55843. }
  55844. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55848. /**
  55849. * Block used to add 2 vectors
  55850. */
  55851. export class AddBlock extends NodeMaterialBlock {
  55852. /**
  55853. * Creates a new AddBlock
  55854. * @param name defines the block name
  55855. */
  55856. constructor(name: string);
  55857. /**
  55858. * Gets the current class name
  55859. * @returns the class name
  55860. */
  55861. getClassName(): string;
  55862. /**
  55863. * Gets the left operand input component
  55864. */
  55865. readonly left: NodeMaterialConnectionPoint;
  55866. /**
  55867. * Gets the right operand input component
  55868. */
  55869. readonly right: NodeMaterialConnectionPoint;
  55870. /**
  55871. * Gets the output component
  55872. */
  55873. readonly output: NodeMaterialConnectionPoint;
  55874. protected _buildBlock(state: NodeMaterialBuildState): this;
  55875. }
  55876. }
  55877. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  55878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55881. /**
  55882. * Block used to scale a vector by a float
  55883. */
  55884. export class ScaleBlock extends NodeMaterialBlock {
  55885. /**
  55886. * Creates a new ScaleBlock
  55887. * @param name defines the block name
  55888. */
  55889. constructor(name: string);
  55890. /**
  55891. * Gets the current class name
  55892. * @returns the class name
  55893. */
  55894. getClassName(): string;
  55895. /**
  55896. * Gets the input component
  55897. */
  55898. readonly input: NodeMaterialConnectionPoint;
  55899. /**
  55900. * Gets the factor input component
  55901. */
  55902. readonly factor: NodeMaterialConnectionPoint;
  55903. /**
  55904. * Gets the output component
  55905. */
  55906. readonly output: NodeMaterialConnectionPoint;
  55907. protected _buildBlock(state: NodeMaterialBuildState): this;
  55908. }
  55909. }
  55910. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55914. import { Scene } from "babylonjs/scene";
  55915. /**
  55916. * Block used to clamp a float
  55917. */
  55918. export class ClampBlock extends NodeMaterialBlock {
  55919. /** Gets or sets the minimum range */
  55920. minimum: number;
  55921. /** Gets or sets the maximum range */
  55922. maximum: number;
  55923. /**
  55924. * Creates a new ClampBlock
  55925. * @param name defines the block name
  55926. */
  55927. constructor(name: string);
  55928. /**
  55929. * Gets the current class name
  55930. * @returns the class name
  55931. */
  55932. getClassName(): string;
  55933. /**
  55934. * Gets the value input component
  55935. */
  55936. readonly value: NodeMaterialConnectionPoint;
  55937. /**
  55938. * Gets the output component
  55939. */
  55940. readonly output: NodeMaterialConnectionPoint;
  55941. protected _buildBlock(state: NodeMaterialBuildState): this;
  55942. protected _dumpPropertiesCode(): string;
  55943. serialize(): any;
  55944. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55945. }
  55946. }
  55947. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55951. /**
  55952. * Block used to apply a cross product between 2 vectors
  55953. */
  55954. export class CrossBlock extends NodeMaterialBlock {
  55955. /**
  55956. * Creates a new CrossBlock
  55957. * @param name defines the block name
  55958. */
  55959. constructor(name: string);
  55960. /**
  55961. * Gets the current class name
  55962. * @returns the class name
  55963. */
  55964. getClassName(): string;
  55965. /**
  55966. * Gets the left operand input component
  55967. */
  55968. readonly left: NodeMaterialConnectionPoint;
  55969. /**
  55970. * Gets the right operand input component
  55971. */
  55972. readonly right: NodeMaterialConnectionPoint;
  55973. /**
  55974. * Gets the output component
  55975. */
  55976. readonly output: NodeMaterialConnectionPoint;
  55977. protected _buildBlock(state: NodeMaterialBuildState): this;
  55978. }
  55979. }
  55980. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55983. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55984. /**
  55985. * Block used to apply a dot product between 2 vectors
  55986. */
  55987. export class DotBlock extends NodeMaterialBlock {
  55988. /**
  55989. * Creates a new DotBlock
  55990. * @param name defines the block name
  55991. */
  55992. constructor(name: string);
  55993. /**
  55994. * Gets the current class name
  55995. * @returns the class name
  55996. */
  55997. getClassName(): string;
  55998. /**
  55999. * Gets the left operand input component
  56000. */
  56001. readonly left: NodeMaterialConnectionPoint;
  56002. /**
  56003. * Gets the right operand input component
  56004. */
  56005. readonly right: NodeMaterialConnectionPoint;
  56006. /**
  56007. * Gets the output component
  56008. */
  56009. readonly output: NodeMaterialConnectionPoint;
  56010. protected _buildBlock(state: NodeMaterialBuildState): this;
  56011. }
  56012. }
  56013. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56017. import { Vector2 } from "babylonjs/Maths/math.vector";
  56018. import { Scene } from "babylonjs/scene";
  56019. /**
  56020. * Block used to remap a float from a range to a new one
  56021. */
  56022. export class RemapBlock extends NodeMaterialBlock {
  56023. /**
  56024. * Gets or sets the source range
  56025. */
  56026. sourceRange: Vector2;
  56027. /**
  56028. * Gets or sets the target range
  56029. */
  56030. targetRange: Vector2;
  56031. /**
  56032. * Creates a new RemapBlock
  56033. * @param name defines the block name
  56034. */
  56035. constructor(name: string);
  56036. /**
  56037. * Gets the current class name
  56038. * @returns the class name
  56039. */
  56040. getClassName(): string;
  56041. /**
  56042. * Gets the input component
  56043. */
  56044. readonly input: NodeMaterialConnectionPoint;
  56045. /**
  56046. * Gets the output component
  56047. */
  56048. readonly output: NodeMaterialConnectionPoint;
  56049. protected _buildBlock(state: NodeMaterialBuildState): this;
  56050. protected _dumpPropertiesCode(): string;
  56051. serialize(): any;
  56052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56053. }
  56054. }
  56055. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56059. /**
  56060. * Block used to normalize a vector
  56061. */
  56062. export class NormalizeBlock extends NodeMaterialBlock {
  56063. /**
  56064. * Creates a new NormalizeBlock
  56065. * @param name defines the block name
  56066. */
  56067. constructor(name: string);
  56068. /**
  56069. * Gets the current class name
  56070. * @returns the class name
  56071. */
  56072. getClassName(): string;
  56073. /**
  56074. * Gets the input component
  56075. */
  56076. readonly input: NodeMaterialConnectionPoint;
  56077. /**
  56078. * Gets the output component
  56079. */
  56080. readonly output: NodeMaterialConnectionPoint;
  56081. protected _buildBlock(state: NodeMaterialBuildState): this;
  56082. }
  56083. }
  56084. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56088. /**
  56089. * Operations supported by the Trigonometry block
  56090. */
  56091. export enum TrigonometryBlockOperations {
  56092. /** Cos */
  56093. Cos = 0,
  56094. /** Sin */
  56095. Sin = 1,
  56096. /** Abs */
  56097. Abs = 2,
  56098. /** Exp */
  56099. Exp = 3,
  56100. /** Exp2 */
  56101. Exp2 = 4,
  56102. /** Round */
  56103. Round = 5,
  56104. /** Floor */
  56105. Floor = 6,
  56106. /** Ceiling */
  56107. Ceiling = 7
  56108. }
  56109. /**
  56110. * Block used to apply trigonometry operation to floats
  56111. */
  56112. export class TrigonometryBlock extends NodeMaterialBlock {
  56113. /**
  56114. * Gets or sets the operation applied by the block
  56115. */
  56116. operation: TrigonometryBlockOperations;
  56117. /**
  56118. * Creates a new TrigonometryBlock
  56119. * @param name defines the block name
  56120. */
  56121. constructor(name: string);
  56122. /**
  56123. * Gets the current class name
  56124. * @returns the class name
  56125. */
  56126. getClassName(): string;
  56127. /**
  56128. * Gets the input component
  56129. */
  56130. readonly input: NodeMaterialConnectionPoint;
  56131. /**
  56132. * Gets the output component
  56133. */
  56134. readonly output: NodeMaterialConnectionPoint;
  56135. protected _buildBlock(state: NodeMaterialBuildState): this;
  56136. }
  56137. }
  56138. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56142. /**
  56143. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56144. */
  56145. export class ColorMergerBlock extends NodeMaterialBlock {
  56146. /**
  56147. * Create a new ColorMergerBlock
  56148. * @param name defines the block name
  56149. */
  56150. constructor(name: string);
  56151. /**
  56152. * Gets the current class name
  56153. * @returns the class name
  56154. */
  56155. getClassName(): string;
  56156. /**
  56157. * Gets the r component (input)
  56158. */
  56159. readonly r: NodeMaterialConnectionPoint;
  56160. /**
  56161. * Gets the g component (input)
  56162. */
  56163. readonly g: NodeMaterialConnectionPoint;
  56164. /**
  56165. * Gets the b component (input)
  56166. */
  56167. readonly b: NodeMaterialConnectionPoint;
  56168. /**
  56169. * Gets the a component (input)
  56170. */
  56171. readonly a: NodeMaterialConnectionPoint;
  56172. /**
  56173. * Gets the rgba component (output)
  56174. */
  56175. readonly rgba: NodeMaterialConnectionPoint;
  56176. /**
  56177. * Gets the rgb component (output)
  56178. */
  56179. readonly rgb: NodeMaterialConnectionPoint;
  56180. protected _buildBlock(state: NodeMaterialBuildState): this;
  56181. }
  56182. }
  56183. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56187. /**
  56188. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56189. */
  56190. export class VectorMergerBlock extends NodeMaterialBlock {
  56191. /**
  56192. * Create a new VectorMergerBlock
  56193. * @param name defines the block name
  56194. */
  56195. constructor(name: string);
  56196. /**
  56197. * Gets the current class name
  56198. * @returns the class name
  56199. */
  56200. getClassName(): string;
  56201. /**
  56202. * Gets the x component (input)
  56203. */
  56204. readonly x: NodeMaterialConnectionPoint;
  56205. /**
  56206. * Gets the y component (input)
  56207. */
  56208. readonly y: NodeMaterialConnectionPoint;
  56209. /**
  56210. * Gets the z component (input)
  56211. */
  56212. readonly z: NodeMaterialConnectionPoint;
  56213. /**
  56214. * Gets the w component (input)
  56215. */
  56216. readonly w: NodeMaterialConnectionPoint;
  56217. /**
  56218. * Gets the xyzw component (output)
  56219. */
  56220. readonly xyzw: NodeMaterialConnectionPoint;
  56221. /**
  56222. * Gets the xyz component (output)
  56223. */
  56224. readonly xyz: NodeMaterialConnectionPoint;
  56225. /**
  56226. * Gets the xy component (output)
  56227. */
  56228. readonly xy: NodeMaterialConnectionPoint;
  56229. protected _buildBlock(state: NodeMaterialBuildState): this;
  56230. }
  56231. }
  56232. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56235. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56236. /**
  56237. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56238. */
  56239. export class ColorSplitterBlock extends NodeMaterialBlock {
  56240. /**
  56241. * Create a new ColorSplitterBlock
  56242. * @param name defines the block name
  56243. */
  56244. constructor(name: string);
  56245. /**
  56246. * Gets the current class name
  56247. * @returns the class name
  56248. */
  56249. getClassName(): string;
  56250. /**
  56251. * Gets the rgba component (input)
  56252. */
  56253. readonly rgba: NodeMaterialConnectionPoint;
  56254. /**
  56255. * Gets the rgb component (input)
  56256. */
  56257. readonly rgbIn: NodeMaterialConnectionPoint;
  56258. /**
  56259. * Gets the rgb component (output)
  56260. */
  56261. readonly rgbOut: NodeMaterialConnectionPoint;
  56262. /**
  56263. * Gets the r component (output)
  56264. */
  56265. readonly r: NodeMaterialConnectionPoint;
  56266. /**
  56267. * Gets the g component (output)
  56268. */
  56269. readonly g: NodeMaterialConnectionPoint;
  56270. /**
  56271. * Gets the b component (output)
  56272. */
  56273. readonly b: NodeMaterialConnectionPoint;
  56274. /**
  56275. * Gets the a component (output)
  56276. */
  56277. readonly a: NodeMaterialConnectionPoint;
  56278. protected _inputRename(name: string): string;
  56279. protected _outputRename(name: string): string;
  56280. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56281. }
  56282. }
  56283. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56287. /**
  56288. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56289. */
  56290. export class VectorSplitterBlock extends NodeMaterialBlock {
  56291. /**
  56292. * Create a new VectorSplitterBlock
  56293. * @param name defines the block name
  56294. */
  56295. constructor(name: string);
  56296. /**
  56297. * Gets the current class name
  56298. * @returns the class name
  56299. */
  56300. getClassName(): string;
  56301. /**
  56302. * Gets the xyzw component (input)
  56303. */
  56304. readonly xyzw: NodeMaterialConnectionPoint;
  56305. /**
  56306. * Gets the xyz component (input)
  56307. */
  56308. readonly xyzIn: NodeMaterialConnectionPoint;
  56309. /**
  56310. * Gets the xy component (input)
  56311. */
  56312. readonly xyIn: NodeMaterialConnectionPoint;
  56313. /**
  56314. * Gets the xyz component (output)
  56315. */
  56316. readonly xyzOut: NodeMaterialConnectionPoint;
  56317. /**
  56318. * Gets the xy component (output)
  56319. */
  56320. readonly xyOut: NodeMaterialConnectionPoint;
  56321. /**
  56322. * Gets the x component (output)
  56323. */
  56324. readonly x: NodeMaterialConnectionPoint;
  56325. /**
  56326. * Gets the y component (output)
  56327. */
  56328. readonly y: NodeMaterialConnectionPoint;
  56329. /**
  56330. * Gets the z component (output)
  56331. */
  56332. readonly z: NodeMaterialConnectionPoint;
  56333. /**
  56334. * Gets the w component (output)
  56335. */
  56336. readonly w: NodeMaterialConnectionPoint;
  56337. protected _inputRename(name: string): string;
  56338. protected _outputRename(name: string): string;
  56339. protected _buildBlock(state: NodeMaterialBuildState): this;
  56340. }
  56341. }
  56342. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56346. /**
  56347. * Block used to lerp 2 values
  56348. */
  56349. export class LerpBlock extends NodeMaterialBlock {
  56350. /**
  56351. * Creates a new LerpBlock
  56352. * @param name defines the block name
  56353. */
  56354. constructor(name: string);
  56355. /**
  56356. * Gets the current class name
  56357. * @returns the class name
  56358. */
  56359. getClassName(): string;
  56360. /**
  56361. * Gets the left operand input component
  56362. */
  56363. readonly left: NodeMaterialConnectionPoint;
  56364. /**
  56365. * Gets the right operand input component
  56366. */
  56367. readonly right: NodeMaterialConnectionPoint;
  56368. /**
  56369. * Gets the gradient operand input component
  56370. */
  56371. readonly gradient: NodeMaterialConnectionPoint;
  56372. /**
  56373. * Gets the output component
  56374. */
  56375. readonly output: NodeMaterialConnectionPoint;
  56376. protected _buildBlock(state: NodeMaterialBuildState): this;
  56377. }
  56378. }
  56379. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56383. /**
  56384. * Block used to divide 2 vectors
  56385. */
  56386. export class DivideBlock extends NodeMaterialBlock {
  56387. /**
  56388. * Creates a new DivideBlock
  56389. * @param name defines the block name
  56390. */
  56391. constructor(name: string);
  56392. /**
  56393. * Gets the current class name
  56394. * @returns the class name
  56395. */
  56396. getClassName(): string;
  56397. /**
  56398. * Gets the left operand input component
  56399. */
  56400. readonly left: NodeMaterialConnectionPoint;
  56401. /**
  56402. * Gets the right operand input component
  56403. */
  56404. readonly right: NodeMaterialConnectionPoint;
  56405. /**
  56406. * Gets the output component
  56407. */
  56408. readonly output: NodeMaterialConnectionPoint;
  56409. protected _buildBlock(state: NodeMaterialBuildState): this;
  56410. }
  56411. }
  56412. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56416. /**
  56417. * Block used to subtract 2 vectors
  56418. */
  56419. export class SubtractBlock extends NodeMaterialBlock {
  56420. /**
  56421. * Creates a new SubtractBlock
  56422. * @param name defines the block name
  56423. */
  56424. constructor(name: string);
  56425. /**
  56426. * Gets the current class name
  56427. * @returns the class name
  56428. */
  56429. getClassName(): string;
  56430. /**
  56431. * Gets the left operand input component
  56432. */
  56433. readonly left: NodeMaterialConnectionPoint;
  56434. /**
  56435. * Gets the right operand input component
  56436. */
  56437. readonly right: NodeMaterialConnectionPoint;
  56438. /**
  56439. * Gets the output component
  56440. */
  56441. readonly output: NodeMaterialConnectionPoint;
  56442. protected _buildBlock(state: NodeMaterialBuildState): this;
  56443. }
  56444. }
  56445. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  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. /**
  56450. * Block used to step a value
  56451. */
  56452. export class StepBlock extends NodeMaterialBlock {
  56453. /**
  56454. * Creates a new AddBlock
  56455. * @param name defines the block name
  56456. */
  56457. constructor(name: string);
  56458. /**
  56459. * Gets the current class name
  56460. * @returns the class name
  56461. */
  56462. getClassName(): string;
  56463. /**
  56464. * Gets the value operand input component
  56465. */
  56466. readonly value: NodeMaterialConnectionPoint;
  56467. /**
  56468. * Gets the edge operand input component
  56469. */
  56470. readonly edge: NodeMaterialConnectionPoint;
  56471. /**
  56472. * Gets the output component
  56473. */
  56474. readonly output: NodeMaterialConnectionPoint;
  56475. protected _buildBlock(state: NodeMaterialBuildState): this;
  56476. }
  56477. }
  56478. declare module "babylonjs/Materials/Node/Blocks/index" {
  56479. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  56480. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56481. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56482. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56483. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56484. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56485. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  56486. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56487. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56488. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56489. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56490. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  56491. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  56492. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  56493. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  56494. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  56495. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  56496. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  56497. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  56498. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  56499. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  56500. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  56501. }
  56502. declare module "babylonjs/Materials/Node/Optimizers/index" {
  56503. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56504. }
  56505. declare module "babylonjs/Materials/Node/index" {
  56506. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  56507. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  56508. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56509. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  56510. export * from "babylonjs/Materials/Node/nodeMaterial";
  56511. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  56512. export * from "babylonjs/Materials/Node/Blocks/index";
  56513. export * from "babylonjs/Materials/Node/Optimizers/index";
  56514. }
  56515. declare module "babylonjs/Materials/effectRenderer" {
  56516. import { Nullable } from "babylonjs/types";
  56517. import { Texture } from "babylonjs/Materials/Textures/texture";
  56518. import { Engine } from "babylonjs/Engines/engine";
  56519. import { Viewport } from "babylonjs/Maths/math.viewport";
  56520. import { Observable } from "babylonjs/Misc/observable";
  56521. import { Effect } from "babylonjs/Materials/effect";
  56522. import "babylonjs/Shaders/postprocess.vertex";
  56523. /**
  56524. * Effect Render Options
  56525. */
  56526. export interface IEffectRendererOptions {
  56527. /**
  56528. * Defines the vertices positions.
  56529. */
  56530. positions?: number[];
  56531. /**
  56532. * Defines the indices.
  56533. */
  56534. indices?: number[];
  56535. }
  56536. /**
  56537. * Helper class to render one or more effects
  56538. */
  56539. export class EffectRenderer {
  56540. private engine;
  56541. private static _DefaultOptions;
  56542. private _vertexBuffers;
  56543. private _indexBuffer;
  56544. private _ringBufferIndex;
  56545. private _ringScreenBuffer;
  56546. private _fullscreenViewport;
  56547. private _getNextFrameBuffer;
  56548. /**
  56549. * Creates an effect renderer
  56550. * @param engine the engine to use for rendering
  56551. * @param options defines the options of the effect renderer
  56552. */
  56553. constructor(engine: Engine, options?: IEffectRendererOptions);
  56554. /**
  56555. * Sets the current viewport in normalized coordinates 0-1
  56556. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56557. */
  56558. setViewport(viewport?: Viewport): void;
  56559. /**
  56560. * Sets the current effect wrapper to use during draw.
  56561. * The effect needs to be ready before calling this api.
  56562. * This also sets the default full screen position attribute.
  56563. * @param effectWrapper Defines the effect to draw with
  56564. */
  56565. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56566. /**
  56567. * Draws a full screen quad.
  56568. */
  56569. draw(): void;
  56570. /**
  56571. * renders one or more effects to a specified texture
  56572. * @param effectWrappers list of effects to renderer
  56573. * @param outputTexture texture to draw to, if null it will render to the screen
  56574. */
  56575. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56576. /**
  56577. * Disposes of the effect renderer
  56578. */
  56579. dispose(): void;
  56580. }
  56581. /**
  56582. * Options to create an EffectWrapper
  56583. */
  56584. interface EffectWrapperCreationOptions {
  56585. /**
  56586. * Engine to use to create the effect
  56587. */
  56588. engine: Engine;
  56589. /**
  56590. * Fragment shader for the effect
  56591. */
  56592. fragmentShader: string;
  56593. /**
  56594. * Vertex shader for the effect
  56595. */
  56596. vertexShader?: string;
  56597. /**
  56598. * Attributes to use in the shader
  56599. */
  56600. attributeNames?: Array<string>;
  56601. /**
  56602. * Uniforms to use in the shader
  56603. */
  56604. uniformNames?: Array<string>;
  56605. /**
  56606. * Texture sampler names to use in the shader
  56607. */
  56608. samplerNames?: Array<string>;
  56609. /**
  56610. * The friendly name of the effect displayed in Spector.
  56611. */
  56612. name?: string;
  56613. }
  56614. /**
  56615. * Wraps an effect to be used for rendering
  56616. */
  56617. export class EffectWrapper {
  56618. /**
  56619. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56620. */
  56621. onApplyObservable: Observable<{}>;
  56622. /**
  56623. * The underlying effect
  56624. */
  56625. effect: Effect;
  56626. /**
  56627. * Creates an effect to be renderer
  56628. * @param creationOptions options to create the effect
  56629. */
  56630. constructor(creationOptions: EffectWrapperCreationOptions);
  56631. /**
  56632. * Disposes of the effect wrapper
  56633. */
  56634. dispose(): void;
  56635. }
  56636. }
  56637. declare module "babylonjs/Materials/index" {
  56638. export * from "babylonjs/Materials/Background/index";
  56639. export * from "babylonjs/Materials/colorCurves";
  56640. export * from "babylonjs/Materials/effect";
  56641. export * from "babylonjs/Materials/fresnelParameters";
  56642. export * from "babylonjs/Materials/imageProcessingConfiguration";
  56643. export * from "babylonjs/Materials/material";
  56644. export * from "babylonjs/Materials/materialDefines";
  56645. export * from "babylonjs/Materials/materialHelper";
  56646. export * from "babylonjs/Materials/multiMaterial";
  56647. export * from "babylonjs/Materials/PBR/index";
  56648. export * from "babylonjs/Materials/pushMaterial";
  56649. export * from "babylonjs/Materials/shaderMaterial";
  56650. export * from "babylonjs/Materials/standardMaterial";
  56651. export * from "babylonjs/Materials/Textures/index";
  56652. export * from "babylonjs/Materials/uniformBuffer";
  56653. export * from "babylonjs/Materials/materialFlags";
  56654. export * from "babylonjs/Materials/Node/index";
  56655. export * from "babylonjs/Materials/effectRenderer";
  56656. }
  56657. declare module "babylonjs/Maths/index" {
  56658. export * from "babylonjs/Maths/math.scalar";
  56659. export * from "babylonjs/Maths/math";
  56660. export * from "babylonjs/Maths/sphericalPolynomial";
  56661. }
  56662. declare module "babylonjs/Misc/workerPool" {
  56663. import { IDisposable } from "babylonjs/scene";
  56664. /**
  56665. * Helper class to push actions to a pool of workers.
  56666. */
  56667. export class WorkerPool implements IDisposable {
  56668. private _workerInfos;
  56669. private _pendingActions;
  56670. /**
  56671. * Constructor
  56672. * @param workers Array of workers to use for actions
  56673. */
  56674. constructor(workers: Array<Worker>);
  56675. /**
  56676. * Terminates all workers and clears any pending actions.
  56677. */
  56678. dispose(): void;
  56679. /**
  56680. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56681. * pended until a worker has completed its action.
  56682. * @param action The action to perform. Call onComplete when the action is complete.
  56683. */
  56684. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56685. private _execute;
  56686. }
  56687. }
  56688. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56689. import { IDisposable } from "babylonjs/scene";
  56690. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56691. /**
  56692. * Configuration for Draco compression
  56693. */
  56694. export interface IDracoCompressionConfiguration {
  56695. /**
  56696. * Configuration for the decoder.
  56697. */
  56698. decoder: {
  56699. /**
  56700. * The url to the WebAssembly module.
  56701. */
  56702. wasmUrl?: string;
  56703. /**
  56704. * The url to the WebAssembly binary.
  56705. */
  56706. wasmBinaryUrl?: string;
  56707. /**
  56708. * The url to the fallback JavaScript module.
  56709. */
  56710. fallbackUrl?: string;
  56711. };
  56712. }
  56713. /**
  56714. * Draco compression (https://google.github.io/draco/)
  56715. *
  56716. * This class wraps the Draco module.
  56717. *
  56718. * **Encoder**
  56719. *
  56720. * The encoder is not currently implemented.
  56721. *
  56722. * **Decoder**
  56723. *
  56724. * 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.
  56725. *
  56726. * To update the configuration, use the following code:
  56727. * ```javascript
  56728. * DracoCompression.Configuration = {
  56729. * decoder: {
  56730. * wasmUrl: "<url to the WebAssembly library>",
  56731. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56732. * fallbackUrl: "<url to the fallback JavaScript library>",
  56733. * }
  56734. * };
  56735. * ```
  56736. *
  56737. * 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.
  56738. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56739. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56740. *
  56741. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56742. * ```javascript
  56743. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56744. * ```
  56745. *
  56746. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56747. */
  56748. export class DracoCompression implements IDisposable {
  56749. private _workerPoolPromise?;
  56750. private _decoderModulePromise?;
  56751. /**
  56752. * The configuration. Defaults to the following urls:
  56753. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56754. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56755. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56756. */
  56757. static Configuration: IDracoCompressionConfiguration;
  56758. /**
  56759. * Returns true if the decoder configuration is available.
  56760. */
  56761. static readonly DecoderAvailable: boolean;
  56762. /**
  56763. * Default number of workers to create when creating the draco compression object.
  56764. */
  56765. static DefaultNumWorkers: number;
  56766. private static GetDefaultNumWorkers;
  56767. private static _Default;
  56768. /**
  56769. * Default instance for the draco compression object.
  56770. */
  56771. static readonly Default: DracoCompression;
  56772. /**
  56773. * Constructor
  56774. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56775. */
  56776. constructor(numWorkers?: number);
  56777. /**
  56778. * Stop all async operations and release resources.
  56779. */
  56780. dispose(): void;
  56781. /**
  56782. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56783. * @returns a promise that resolves when ready
  56784. */
  56785. whenReadyAsync(): Promise<void>;
  56786. /**
  56787. * Decode Draco compressed mesh data to vertex data.
  56788. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56789. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56790. * @returns A promise that resolves with the decoded vertex data
  56791. */
  56792. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56793. [kind: string]: number;
  56794. }): Promise<VertexData>;
  56795. }
  56796. }
  56797. declare module "babylonjs/Meshes/Compression/index" {
  56798. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56799. }
  56800. declare module "babylonjs/Meshes/csg" {
  56801. import { Nullable } from "babylonjs/types";
  56802. import { Scene } from "babylonjs/scene";
  56803. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56804. import { Mesh } from "babylonjs/Meshes/mesh";
  56805. import { Material } from "babylonjs/Materials/material";
  56806. /**
  56807. * Class for building Constructive Solid Geometry
  56808. */
  56809. export class CSG {
  56810. private polygons;
  56811. /**
  56812. * The world matrix
  56813. */
  56814. matrix: Matrix;
  56815. /**
  56816. * Stores the position
  56817. */
  56818. position: Vector3;
  56819. /**
  56820. * Stores the rotation
  56821. */
  56822. rotation: Vector3;
  56823. /**
  56824. * Stores the rotation quaternion
  56825. */
  56826. rotationQuaternion: Nullable<Quaternion>;
  56827. /**
  56828. * Stores the scaling vector
  56829. */
  56830. scaling: Vector3;
  56831. /**
  56832. * Convert the Mesh to CSG
  56833. * @param mesh The Mesh to convert to CSG
  56834. * @returns A new CSG from the Mesh
  56835. */
  56836. static FromMesh(mesh: Mesh): CSG;
  56837. /**
  56838. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56839. * @param polygons Polygons used to construct a CSG solid
  56840. */
  56841. private static FromPolygons;
  56842. /**
  56843. * Clones, or makes a deep copy, of the CSG
  56844. * @returns A new CSG
  56845. */
  56846. clone(): CSG;
  56847. /**
  56848. * Unions this CSG with another CSG
  56849. * @param csg The CSG to union against this CSG
  56850. * @returns The unioned CSG
  56851. */
  56852. union(csg: CSG): CSG;
  56853. /**
  56854. * Unions this CSG with another CSG in place
  56855. * @param csg The CSG to union against this CSG
  56856. */
  56857. unionInPlace(csg: CSG): void;
  56858. /**
  56859. * Subtracts this CSG with another CSG
  56860. * @param csg The CSG to subtract against this CSG
  56861. * @returns A new CSG
  56862. */
  56863. subtract(csg: CSG): CSG;
  56864. /**
  56865. * Subtracts this CSG with another CSG in place
  56866. * @param csg The CSG to subtact against this CSG
  56867. */
  56868. subtractInPlace(csg: CSG): void;
  56869. /**
  56870. * Intersect this CSG with another CSG
  56871. * @param csg The CSG to intersect against this CSG
  56872. * @returns A new CSG
  56873. */
  56874. intersect(csg: CSG): CSG;
  56875. /**
  56876. * Intersects this CSG with another CSG in place
  56877. * @param csg The CSG to intersect against this CSG
  56878. */
  56879. intersectInPlace(csg: CSG): void;
  56880. /**
  56881. * Return a new CSG solid with solid and empty space switched. This solid is
  56882. * not modified.
  56883. * @returns A new CSG solid with solid and empty space switched
  56884. */
  56885. inverse(): CSG;
  56886. /**
  56887. * Inverses the CSG in place
  56888. */
  56889. inverseInPlace(): void;
  56890. /**
  56891. * This is used to keep meshes transformations so they can be restored
  56892. * when we build back a Babylon Mesh
  56893. * NB : All CSG operations are performed in world coordinates
  56894. * @param csg The CSG to copy the transform attributes from
  56895. * @returns This CSG
  56896. */
  56897. copyTransformAttributes(csg: CSG): CSG;
  56898. /**
  56899. * Build Raw mesh from CSG
  56900. * Coordinates here are in world space
  56901. * @param name The name of the mesh geometry
  56902. * @param scene The Scene
  56903. * @param keepSubMeshes Specifies if the submeshes should be kept
  56904. * @returns A new Mesh
  56905. */
  56906. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56907. /**
  56908. * Build Mesh from CSG taking material and transforms into account
  56909. * @param name The name of the Mesh
  56910. * @param material The material of the Mesh
  56911. * @param scene The Scene
  56912. * @param keepSubMeshes Specifies if submeshes should be kept
  56913. * @returns The new Mesh
  56914. */
  56915. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56916. }
  56917. }
  56918. declare module "babylonjs/Meshes/trailMesh" {
  56919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56920. import { Mesh } from "babylonjs/Meshes/mesh";
  56921. import { Scene } from "babylonjs/scene";
  56922. /**
  56923. * Class used to create a trail following a mesh
  56924. */
  56925. export class TrailMesh extends Mesh {
  56926. private _generator;
  56927. private _autoStart;
  56928. private _running;
  56929. private _diameter;
  56930. private _length;
  56931. private _sectionPolygonPointsCount;
  56932. private _sectionVectors;
  56933. private _sectionNormalVectors;
  56934. private _beforeRenderObserver;
  56935. /**
  56936. * @constructor
  56937. * @param name The value used by scene.getMeshByName() to do a lookup.
  56938. * @param generator The mesh to generate a trail.
  56939. * @param scene The scene to add this mesh to.
  56940. * @param diameter Diameter of trailing mesh. Default is 1.
  56941. * @param length Length of trailing mesh. Default is 60.
  56942. * @param autoStart Automatically start trailing mesh. Default true.
  56943. */
  56944. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56945. /**
  56946. * "TrailMesh"
  56947. * @returns "TrailMesh"
  56948. */
  56949. getClassName(): string;
  56950. private _createMesh;
  56951. /**
  56952. * Start trailing mesh.
  56953. */
  56954. start(): void;
  56955. /**
  56956. * Stop trailing mesh.
  56957. */
  56958. stop(): void;
  56959. /**
  56960. * Update trailing mesh geometry.
  56961. */
  56962. update(): void;
  56963. /**
  56964. * Returns a new TrailMesh object.
  56965. * @param name is a string, the name given to the new mesh
  56966. * @param newGenerator use new generator object for cloned trail mesh
  56967. * @returns a new mesh
  56968. */
  56969. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56970. /**
  56971. * Serializes this trail mesh
  56972. * @param serializationObject object to write serialization to
  56973. */
  56974. serialize(serializationObject: any): void;
  56975. /**
  56976. * Parses a serialized trail mesh
  56977. * @param parsedMesh the serialized mesh
  56978. * @param scene the scene to create the trail mesh in
  56979. * @returns the created trail mesh
  56980. */
  56981. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56982. }
  56983. }
  56984. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56985. import { Nullable } from "babylonjs/types";
  56986. import { Scene } from "babylonjs/scene";
  56987. import { Vector4 } from "babylonjs/Maths/math.vector";
  56988. import { Color4 } from "babylonjs/Maths/math.color";
  56989. import { Mesh } from "babylonjs/Meshes/mesh";
  56990. /**
  56991. * Class containing static functions to help procedurally build meshes
  56992. */
  56993. export class TiledBoxBuilder {
  56994. /**
  56995. * Creates a box mesh
  56996. * 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)
  56997. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57001. * @param name defines the name of the mesh
  57002. * @param options defines the options used to create the mesh
  57003. * @param scene defines the hosting scene
  57004. * @returns the box mesh
  57005. */
  57006. static CreateTiledBox(name: string, options: {
  57007. pattern?: number;
  57008. width?: number;
  57009. height?: number;
  57010. depth?: number;
  57011. tileSize?: number;
  57012. tileWidth?: number;
  57013. tileHeight?: number;
  57014. alignHorizontal?: number;
  57015. alignVertical?: number;
  57016. faceUV?: Vector4[];
  57017. faceColors?: Color4[];
  57018. sideOrientation?: number;
  57019. updatable?: boolean;
  57020. }, scene?: Nullable<Scene>): Mesh;
  57021. }
  57022. }
  57023. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57024. import { Vector4 } from "babylonjs/Maths/math.vector";
  57025. import { Mesh } from "babylonjs/Meshes/mesh";
  57026. /**
  57027. * Class containing static functions to help procedurally build meshes
  57028. */
  57029. export class TorusKnotBuilder {
  57030. /**
  57031. * Creates a torus knot mesh
  57032. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57033. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57034. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57035. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57039. * @param name defines the name of the mesh
  57040. * @param options defines the options used to create the mesh
  57041. * @param scene defines the hosting scene
  57042. * @returns the torus knot mesh
  57043. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57044. */
  57045. static CreateTorusKnot(name: string, options: {
  57046. radius?: number;
  57047. tube?: number;
  57048. radialSegments?: number;
  57049. tubularSegments?: number;
  57050. p?: number;
  57051. q?: number;
  57052. updatable?: boolean;
  57053. sideOrientation?: number;
  57054. frontUVs?: Vector4;
  57055. backUVs?: Vector4;
  57056. }, scene: any): Mesh;
  57057. }
  57058. }
  57059. declare module "babylonjs/Meshes/polygonMesh" {
  57060. import { Scene } from "babylonjs/scene";
  57061. import { Vector2 } from "babylonjs/Maths/math.vector";
  57062. import { Mesh } from "babylonjs/Meshes/mesh";
  57063. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57064. import { Path2 } from "babylonjs/Maths/math.path";
  57065. /**
  57066. * Polygon
  57067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57068. */
  57069. export class Polygon {
  57070. /**
  57071. * Creates a rectangle
  57072. * @param xmin bottom X coord
  57073. * @param ymin bottom Y coord
  57074. * @param xmax top X coord
  57075. * @param ymax top Y coord
  57076. * @returns points that make the resulting rectation
  57077. */
  57078. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57079. /**
  57080. * Creates a circle
  57081. * @param radius radius of circle
  57082. * @param cx scale in x
  57083. * @param cy scale in y
  57084. * @param numberOfSides number of sides that make up the circle
  57085. * @returns points that make the resulting circle
  57086. */
  57087. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57088. /**
  57089. * Creates a polygon from input string
  57090. * @param input Input polygon data
  57091. * @returns the parsed points
  57092. */
  57093. static Parse(input: string): Vector2[];
  57094. /**
  57095. * Starts building a polygon from x and y coordinates
  57096. * @param x x coordinate
  57097. * @param y y coordinate
  57098. * @returns the started path2
  57099. */
  57100. static StartingAt(x: number, y: number): Path2;
  57101. }
  57102. /**
  57103. * Builds a polygon
  57104. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57105. */
  57106. export class PolygonMeshBuilder {
  57107. private _points;
  57108. private _outlinepoints;
  57109. private _holes;
  57110. private _name;
  57111. private _scene;
  57112. private _epoints;
  57113. private _eholes;
  57114. private _addToepoint;
  57115. /**
  57116. * Babylon reference to the earcut plugin.
  57117. */
  57118. bjsEarcut: any;
  57119. /**
  57120. * Creates a PolygonMeshBuilder
  57121. * @param name name of the builder
  57122. * @param contours Path of the polygon
  57123. * @param scene scene to add to when creating the mesh
  57124. * @param earcutInjection can be used to inject your own earcut reference
  57125. */
  57126. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57127. /**
  57128. * Adds a whole within the polygon
  57129. * @param hole Array of points defining the hole
  57130. * @returns this
  57131. */
  57132. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57133. /**
  57134. * Creates the polygon
  57135. * @param updatable If the mesh should be updatable
  57136. * @param depth The depth of the mesh created
  57137. * @returns the created mesh
  57138. */
  57139. build(updatable?: boolean, depth?: number): Mesh;
  57140. /**
  57141. * Creates the polygon
  57142. * @param depth The depth of the mesh created
  57143. * @returns the created VertexData
  57144. */
  57145. buildVertexData(depth?: number): VertexData;
  57146. /**
  57147. * Adds a side to the polygon
  57148. * @param positions points that make the polygon
  57149. * @param normals normals of the polygon
  57150. * @param uvs uvs of the polygon
  57151. * @param indices indices of the polygon
  57152. * @param bounds bounds of the polygon
  57153. * @param points points of the polygon
  57154. * @param depth depth of the polygon
  57155. * @param flip flip of the polygon
  57156. */
  57157. private addSide;
  57158. }
  57159. }
  57160. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57161. import { Scene } from "babylonjs/scene";
  57162. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57163. import { Color4 } from "babylonjs/Maths/math.color";
  57164. import { Mesh } from "babylonjs/Meshes/mesh";
  57165. import { Nullable } from "babylonjs/types";
  57166. /**
  57167. * Class containing static functions to help procedurally build meshes
  57168. */
  57169. export class PolygonBuilder {
  57170. /**
  57171. * Creates a polygon mesh
  57172. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57173. * * 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
  57174. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57177. * * Remember you can only change the shape positions, not their number when updating a polygon
  57178. * @param name defines the name of the mesh
  57179. * @param options defines the options used to create the mesh
  57180. * @param scene defines the hosting scene
  57181. * @param earcutInjection can be used to inject your own earcut reference
  57182. * @returns the polygon mesh
  57183. */
  57184. static CreatePolygon(name: string, options: {
  57185. shape: Vector3[];
  57186. holes?: Vector3[][];
  57187. depth?: number;
  57188. faceUV?: Vector4[];
  57189. faceColors?: Color4[];
  57190. updatable?: boolean;
  57191. sideOrientation?: number;
  57192. frontUVs?: Vector4;
  57193. backUVs?: Vector4;
  57194. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57195. /**
  57196. * Creates an extruded polygon mesh, with depth in the Y direction.
  57197. * * 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)
  57198. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57199. * @param name defines the name of the mesh
  57200. * @param options defines the options used to create the mesh
  57201. * @param scene defines the hosting scene
  57202. * @param earcutInjection can be used to inject your own earcut reference
  57203. * @returns the polygon mesh
  57204. */
  57205. static ExtrudePolygon(name: string, options: {
  57206. shape: Vector3[];
  57207. holes?: Vector3[][];
  57208. depth?: number;
  57209. faceUV?: Vector4[];
  57210. faceColors?: Color4[];
  57211. updatable?: boolean;
  57212. sideOrientation?: number;
  57213. frontUVs?: Vector4;
  57214. backUVs?: Vector4;
  57215. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57216. }
  57217. }
  57218. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  57219. import { Scene } from "babylonjs/scene";
  57220. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57221. import { Mesh } from "babylonjs/Meshes/mesh";
  57222. import { Nullable } from "babylonjs/types";
  57223. /**
  57224. * Class containing static functions to help procedurally build meshes
  57225. */
  57226. export class LatheBuilder {
  57227. /**
  57228. * Creates lathe mesh.
  57229. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57230. * * 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
  57231. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57232. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57233. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57234. * * 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
  57235. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57236. * * 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
  57237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57241. * @param name defines the name of the mesh
  57242. * @param options defines the options used to create the mesh
  57243. * @param scene defines the hosting scene
  57244. * @returns the lathe mesh
  57245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57246. */
  57247. static CreateLathe(name: string, options: {
  57248. shape: Vector3[];
  57249. radius?: number;
  57250. tessellation?: number;
  57251. clip?: number;
  57252. arc?: number;
  57253. closed?: boolean;
  57254. updatable?: boolean;
  57255. sideOrientation?: number;
  57256. frontUVs?: Vector4;
  57257. backUVs?: Vector4;
  57258. cap?: number;
  57259. invertUV?: boolean;
  57260. }, scene?: Nullable<Scene>): Mesh;
  57261. }
  57262. }
  57263. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  57264. import { Nullable } from "babylonjs/types";
  57265. import { Scene } from "babylonjs/scene";
  57266. import { Vector4 } from "babylonjs/Maths/math.vector";
  57267. import { Mesh } from "babylonjs/Meshes/mesh";
  57268. /**
  57269. * Class containing static functions to help procedurally build meshes
  57270. */
  57271. export class TiledPlaneBuilder {
  57272. /**
  57273. * Creates a tiled plane mesh
  57274. * * The parameter `pattern` will, depending on value, do nothing or
  57275. * * * flip (reflect about central vertical) alternate tiles across and up
  57276. * * * flip every tile on alternate rows
  57277. * * * rotate (180 degs) alternate tiles across and up
  57278. * * * rotate every tile on alternate rows
  57279. * * * flip and rotate alternate tiles across and up
  57280. * * * flip and rotate every tile on alternate rows
  57281. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57282. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57284. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57285. * * 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)
  57286. * * 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)
  57287. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57288. * @param name defines the name of the mesh
  57289. * @param options defines the options used to create the mesh
  57290. * @param scene defines the hosting scene
  57291. * @returns the box mesh
  57292. */
  57293. static CreateTiledPlane(name: string, options: {
  57294. pattern?: number;
  57295. tileSize?: number;
  57296. tileWidth?: number;
  57297. tileHeight?: number;
  57298. size?: number;
  57299. width?: number;
  57300. height?: number;
  57301. alignHorizontal?: number;
  57302. alignVertical?: number;
  57303. sideOrientation?: number;
  57304. frontUVs?: Vector4;
  57305. backUVs?: Vector4;
  57306. updatable?: boolean;
  57307. }, scene?: Nullable<Scene>): Mesh;
  57308. }
  57309. }
  57310. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  57311. import { Nullable } from "babylonjs/types";
  57312. import { Scene } from "babylonjs/scene";
  57313. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57314. import { Mesh } from "babylonjs/Meshes/mesh";
  57315. /**
  57316. * Class containing static functions to help procedurally build meshes
  57317. */
  57318. export class TubeBuilder {
  57319. /**
  57320. * Creates a tube mesh.
  57321. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57322. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57323. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57324. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57325. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57326. * * 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)
  57327. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57328. * * 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
  57329. * * 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
  57330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57334. * @param name defines the name of the mesh
  57335. * @param options defines the options used to create the mesh
  57336. * @param scene defines the hosting scene
  57337. * @returns the tube mesh
  57338. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57339. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57340. */
  57341. static CreateTube(name: string, options: {
  57342. path: Vector3[];
  57343. radius?: number;
  57344. tessellation?: number;
  57345. radiusFunction?: {
  57346. (i: number, distance: number): number;
  57347. };
  57348. cap?: number;
  57349. arc?: number;
  57350. updatable?: boolean;
  57351. sideOrientation?: number;
  57352. frontUVs?: Vector4;
  57353. backUVs?: Vector4;
  57354. instance?: Mesh;
  57355. invertUV?: boolean;
  57356. }, scene?: Nullable<Scene>): Mesh;
  57357. }
  57358. }
  57359. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  57360. import { Scene } from "babylonjs/scene";
  57361. import { Vector4 } from "babylonjs/Maths/math.vector";
  57362. import { Mesh } from "babylonjs/Meshes/mesh";
  57363. import { Nullable } from "babylonjs/types";
  57364. /**
  57365. * Class containing static functions to help procedurally build meshes
  57366. */
  57367. export class IcoSphereBuilder {
  57368. /**
  57369. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57370. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57371. * * 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`)
  57372. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57373. * * 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
  57374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57377. * @param name defines the name of the mesh
  57378. * @param options defines the options used to create the mesh
  57379. * @param scene defines the hosting scene
  57380. * @returns the icosahedron mesh
  57381. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57382. */
  57383. static CreateIcoSphere(name: string, options: {
  57384. radius?: number;
  57385. radiusX?: number;
  57386. radiusY?: number;
  57387. radiusZ?: number;
  57388. flat?: boolean;
  57389. subdivisions?: number;
  57390. sideOrientation?: number;
  57391. frontUVs?: Vector4;
  57392. backUVs?: Vector4;
  57393. updatable?: boolean;
  57394. }, scene?: Nullable<Scene>): Mesh;
  57395. }
  57396. }
  57397. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  57398. import { Vector3 } from "babylonjs/Maths/math.vector";
  57399. import { Mesh } from "babylonjs/Meshes/mesh";
  57400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57401. /**
  57402. * Class containing static functions to help procedurally build meshes
  57403. */
  57404. export class DecalBuilder {
  57405. /**
  57406. * Creates a decal mesh.
  57407. * 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
  57408. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57409. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57410. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57411. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57412. * @param name defines the name of the mesh
  57413. * @param sourceMesh defines the mesh where the decal must be applied
  57414. * @param options defines the options used to create the mesh
  57415. * @param scene defines the hosting scene
  57416. * @returns the decal mesh
  57417. * @see https://doc.babylonjs.com/how_to/decals
  57418. */
  57419. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57420. position?: Vector3;
  57421. normal?: Vector3;
  57422. size?: Vector3;
  57423. angle?: number;
  57424. }): Mesh;
  57425. }
  57426. }
  57427. declare module "babylonjs/Meshes/meshBuilder" {
  57428. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  57429. import { Nullable } from "babylonjs/types";
  57430. import { Scene } from "babylonjs/scene";
  57431. import { Mesh } from "babylonjs/Meshes/mesh";
  57432. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57433. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  57434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57435. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57436. import { Plane } from "babylonjs/Maths/math.plane";
  57437. /**
  57438. * Class containing static functions to help procedurally build meshes
  57439. */
  57440. export class MeshBuilder {
  57441. /**
  57442. * Creates a box mesh
  57443. * * The parameter `size` sets the size (float) of each box side (default 1)
  57444. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57445. * * 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)
  57446. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57450. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57451. * @param name defines the name of the mesh
  57452. * @param options defines the options used to create the mesh
  57453. * @param scene defines the hosting scene
  57454. * @returns the box mesh
  57455. */
  57456. static CreateBox(name: string, options: {
  57457. size?: number;
  57458. width?: number;
  57459. height?: number;
  57460. depth?: number;
  57461. faceUV?: Vector4[];
  57462. faceColors?: Color4[];
  57463. sideOrientation?: number;
  57464. frontUVs?: Vector4;
  57465. backUVs?: Vector4;
  57466. updatable?: boolean;
  57467. }, scene?: Nullable<Scene>): Mesh;
  57468. /**
  57469. * Creates a tiled box mesh
  57470. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57472. * @param name defines the name of the mesh
  57473. * @param options defines the options used to create the mesh
  57474. * @param scene defines the hosting scene
  57475. * @returns the tiled box mesh
  57476. */
  57477. static CreateTiledBox(name: string, options: {
  57478. pattern?: number;
  57479. size?: number;
  57480. width?: number;
  57481. height?: number;
  57482. depth: number;
  57483. tileSize?: number;
  57484. tileWidth?: number;
  57485. tileHeight?: number;
  57486. faceUV?: Vector4[];
  57487. faceColors?: Color4[];
  57488. alignHorizontal?: number;
  57489. alignVertical?: number;
  57490. sideOrientation?: number;
  57491. updatable?: boolean;
  57492. }, scene?: Nullable<Scene>): Mesh;
  57493. /**
  57494. * Creates a sphere mesh
  57495. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57496. * * 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`)
  57497. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57498. * * 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
  57499. * * 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)
  57500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57503. * @param name defines the name of the mesh
  57504. * @param options defines the options used to create the mesh
  57505. * @param scene defines the hosting scene
  57506. * @returns the sphere mesh
  57507. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57508. */
  57509. static CreateSphere(name: string, options: {
  57510. segments?: number;
  57511. diameter?: number;
  57512. diameterX?: number;
  57513. diameterY?: number;
  57514. diameterZ?: number;
  57515. arc?: number;
  57516. slice?: number;
  57517. sideOrientation?: number;
  57518. frontUVs?: Vector4;
  57519. backUVs?: Vector4;
  57520. updatable?: boolean;
  57521. }, scene?: Nullable<Scene>): Mesh;
  57522. /**
  57523. * Creates a plane polygonal mesh. By default, this is a disc
  57524. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57525. * * 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
  57526. * * 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
  57527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57530. * @param name defines the name of the mesh
  57531. * @param options defines the options used to create the mesh
  57532. * @param scene defines the hosting scene
  57533. * @returns the plane polygonal mesh
  57534. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57535. */
  57536. static CreateDisc(name: string, options: {
  57537. radius?: number;
  57538. tessellation?: number;
  57539. arc?: number;
  57540. updatable?: boolean;
  57541. sideOrientation?: number;
  57542. frontUVs?: Vector4;
  57543. backUVs?: Vector4;
  57544. }, scene?: Nullable<Scene>): Mesh;
  57545. /**
  57546. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57547. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57548. * * 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`)
  57549. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57550. * * 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
  57551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57554. * @param name defines the name of the mesh
  57555. * @param options defines the options used to create the mesh
  57556. * @param scene defines the hosting scene
  57557. * @returns the icosahedron mesh
  57558. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57559. */
  57560. static CreateIcoSphere(name: string, options: {
  57561. radius?: number;
  57562. radiusX?: number;
  57563. radiusY?: number;
  57564. radiusZ?: number;
  57565. flat?: boolean;
  57566. subdivisions?: number;
  57567. sideOrientation?: number;
  57568. frontUVs?: Vector4;
  57569. backUVs?: Vector4;
  57570. updatable?: boolean;
  57571. }, scene?: Nullable<Scene>): Mesh;
  57572. /**
  57573. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57574. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57575. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57576. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57577. * * 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
  57578. * * 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
  57579. * * 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
  57580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57582. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57583. * * 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
  57584. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57585. * * 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
  57586. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57588. * @param name defines the name of the mesh
  57589. * @param options defines the options used to create the mesh
  57590. * @param scene defines the hosting scene
  57591. * @returns the ribbon mesh
  57592. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57593. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57594. */
  57595. static CreateRibbon(name: string, options: {
  57596. pathArray: Vector3[][];
  57597. closeArray?: boolean;
  57598. closePath?: boolean;
  57599. offset?: number;
  57600. updatable?: boolean;
  57601. sideOrientation?: number;
  57602. frontUVs?: Vector4;
  57603. backUVs?: Vector4;
  57604. instance?: Mesh;
  57605. invertUV?: boolean;
  57606. uvs?: Vector2[];
  57607. colors?: Color4[];
  57608. }, scene?: Nullable<Scene>): Mesh;
  57609. /**
  57610. * Creates a cylinder or a cone mesh
  57611. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57612. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57613. * * 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.
  57614. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57615. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57616. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57617. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57618. * * 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).
  57619. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57620. * * 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).
  57621. * * 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
  57622. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57623. * * 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
  57624. * * 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.
  57625. * * If `enclose` is false, a ring surface is one element.
  57626. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57627. * * 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
  57628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57631. * @param name defines the name of the mesh
  57632. * @param options defines the options used to create the mesh
  57633. * @param scene defines the hosting scene
  57634. * @returns the cylinder mesh
  57635. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57636. */
  57637. static CreateCylinder(name: string, options: {
  57638. height?: number;
  57639. diameterTop?: number;
  57640. diameterBottom?: number;
  57641. diameter?: number;
  57642. tessellation?: number;
  57643. subdivisions?: number;
  57644. arc?: number;
  57645. faceColors?: Color4[];
  57646. faceUV?: Vector4[];
  57647. updatable?: boolean;
  57648. hasRings?: boolean;
  57649. enclose?: boolean;
  57650. cap?: number;
  57651. sideOrientation?: number;
  57652. frontUVs?: Vector4;
  57653. backUVs?: Vector4;
  57654. }, scene?: Nullable<Scene>): Mesh;
  57655. /**
  57656. * Creates a torus mesh
  57657. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57658. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57659. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57663. * @param name defines the name of the mesh
  57664. * @param options defines the options used to create the mesh
  57665. * @param scene defines the hosting scene
  57666. * @returns the torus mesh
  57667. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57668. */
  57669. static CreateTorus(name: string, options: {
  57670. diameter?: number;
  57671. thickness?: number;
  57672. tessellation?: number;
  57673. updatable?: boolean;
  57674. sideOrientation?: number;
  57675. frontUVs?: Vector4;
  57676. backUVs?: Vector4;
  57677. }, scene?: Nullable<Scene>): Mesh;
  57678. /**
  57679. * Creates a torus knot mesh
  57680. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57681. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57682. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57683. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57687. * @param name defines the name of the mesh
  57688. * @param options defines the options used to create the mesh
  57689. * @param scene defines the hosting scene
  57690. * @returns the torus knot mesh
  57691. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57692. */
  57693. static CreateTorusKnot(name: string, options: {
  57694. radius?: number;
  57695. tube?: number;
  57696. radialSegments?: number;
  57697. tubularSegments?: number;
  57698. p?: number;
  57699. q?: number;
  57700. updatable?: boolean;
  57701. sideOrientation?: number;
  57702. frontUVs?: Vector4;
  57703. backUVs?: Vector4;
  57704. }, scene?: Nullable<Scene>): Mesh;
  57705. /**
  57706. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57707. * * 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
  57708. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57709. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57710. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57711. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57712. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57713. * * 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
  57714. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57717. * @param name defines the name of the new line system
  57718. * @param options defines the options used to create the line system
  57719. * @param scene defines the hosting scene
  57720. * @returns a new line system mesh
  57721. */
  57722. static CreateLineSystem(name: string, options: {
  57723. lines: Vector3[][];
  57724. updatable?: boolean;
  57725. instance?: Nullable<LinesMesh>;
  57726. colors?: Nullable<Color4[][]>;
  57727. useVertexAlpha?: boolean;
  57728. }, scene: Nullable<Scene>): LinesMesh;
  57729. /**
  57730. * Creates a line mesh
  57731. * 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
  57732. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57733. * * The parameter `points` is an array successive Vector3
  57734. * * 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
  57735. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57736. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57737. * * When updating an instance, remember that only point positions can change, not the number of points
  57738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57740. * @param name defines the name of the new line system
  57741. * @param options defines the options used to create the line system
  57742. * @param scene defines the hosting scene
  57743. * @returns a new line mesh
  57744. */
  57745. static CreateLines(name: string, options: {
  57746. points: Vector3[];
  57747. updatable?: boolean;
  57748. instance?: Nullable<LinesMesh>;
  57749. colors?: Color4[];
  57750. useVertexAlpha?: boolean;
  57751. }, scene?: Nullable<Scene>): LinesMesh;
  57752. /**
  57753. * Creates a dashed line mesh
  57754. * * 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
  57755. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57756. * * The parameter `points` is an array successive Vector3
  57757. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57758. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57759. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57760. * * 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
  57761. * * When updating an instance, remember that only point positions can change, not the number of points
  57762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57763. * @param name defines the name of the mesh
  57764. * @param options defines the options used to create the mesh
  57765. * @param scene defines the hosting scene
  57766. * @returns the dashed line mesh
  57767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57768. */
  57769. static CreateDashedLines(name: string, options: {
  57770. points: Vector3[];
  57771. dashSize?: number;
  57772. gapSize?: number;
  57773. dashNb?: number;
  57774. updatable?: boolean;
  57775. instance?: LinesMesh;
  57776. }, scene?: Nullable<Scene>): LinesMesh;
  57777. /**
  57778. * 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.
  57779. * * 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.
  57780. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57781. * * 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.
  57782. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57783. * * 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
  57784. * * 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
  57785. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57790. * @param name defines the name of the mesh
  57791. * @param options defines the options used to create the mesh
  57792. * @param scene defines the hosting scene
  57793. * @returns the extruded shape mesh
  57794. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57796. */
  57797. static ExtrudeShape(name: string, options: {
  57798. shape: Vector3[];
  57799. path: Vector3[];
  57800. scale?: number;
  57801. rotation?: number;
  57802. cap?: number;
  57803. updatable?: boolean;
  57804. sideOrientation?: number;
  57805. frontUVs?: Vector4;
  57806. backUVs?: Vector4;
  57807. instance?: Mesh;
  57808. invertUV?: boolean;
  57809. }, scene?: Nullable<Scene>): Mesh;
  57810. /**
  57811. * Creates an custom extruded shape mesh.
  57812. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57813. * * 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.
  57814. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57815. * * 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
  57816. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57817. * * 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
  57818. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57819. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57820. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57821. * * 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
  57822. * * 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
  57823. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57826. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57828. * @param name defines the name of the mesh
  57829. * @param options defines the options used to create the mesh
  57830. * @param scene defines the hosting scene
  57831. * @returns the custom extruded shape mesh
  57832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57833. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57835. */
  57836. static ExtrudeShapeCustom(name: string, options: {
  57837. shape: Vector3[];
  57838. path: Vector3[];
  57839. scaleFunction?: any;
  57840. rotationFunction?: any;
  57841. ribbonCloseArray?: boolean;
  57842. ribbonClosePath?: boolean;
  57843. cap?: number;
  57844. updatable?: boolean;
  57845. sideOrientation?: number;
  57846. frontUVs?: Vector4;
  57847. backUVs?: Vector4;
  57848. instance?: Mesh;
  57849. invertUV?: boolean;
  57850. }, scene?: Nullable<Scene>): Mesh;
  57851. /**
  57852. * Creates lathe mesh.
  57853. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57854. * * 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
  57855. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57856. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57857. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57858. * * 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
  57859. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57860. * * 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
  57861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57863. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57865. * @param name defines the name of the mesh
  57866. * @param options defines the options used to create the mesh
  57867. * @param scene defines the hosting scene
  57868. * @returns the lathe mesh
  57869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57870. */
  57871. static CreateLathe(name: string, options: {
  57872. shape: Vector3[];
  57873. radius?: number;
  57874. tessellation?: number;
  57875. clip?: number;
  57876. arc?: number;
  57877. closed?: boolean;
  57878. updatable?: boolean;
  57879. sideOrientation?: number;
  57880. frontUVs?: Vector4;
  57881. backUVs?: Vector4;
  57882. cap?: number;
  57883. invertUV?: boolean;
  57884. }, scene?: Nullable<Scene>): Mesh;
  57885. /**
  57886. * Creates a tiled plane mesh
  57887. * * You can set a limited pattern arrangement with the tiles
  57888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57891. * @param name defines the name of the mesh
  57892. * @param options defines the options used to create the mesh
  57893. * @param scene defines the hosting scene
  57894. * @returns the plane mesh
  57895. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57896. */
  57897. static CreateTiledPlane(name: string, options: {
  57898. pattern?: number;
  57899. tileSize?: number;
  57900. tileWidth?: number;
  57901. tileHeight?: number;
  57902. size?: number;
  57903. width?: number;
  57904. height?: number;
  57905. alignHorizontal?: number;
  57906. alignVertical?: number;
  57907. sideOrientation?: number;
  57908. frontUVs?: Vector4;
  57909. backUVs?: Vector4;
  57910. updatable?: boolean;
  57911. }, scene?: Nullable<Scene>): Mesh;
  57912. /**
  57913. * Creates a plane mesh
  57914. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57915. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57916. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57920. * @param name defines the name of the mesh
  57921. * @param options defines the options used to create the mesh
  57922. * @param scene defines the hosting scene
  57923. * @returns the plane mesh
  57924. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57925. */
  57926. static CreatePlane(name: string, options: {
  57927. size?: number;
  57928. width?: number;
  57929. height?: number;
  57930. sideOrientation?: number;
  57931. frontUVs?: Vector4;
  57932. backUVs?: Vector4;
  57933. updatable?: boolean;
  57934. sourcePlane?: Plane;
  57935. }, scene?: Nullable<Scene>): Mesh;
  57936. /**
  57937. * Creates a ground mesh
  57938. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57939. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57941. * @param name defines the name of the mesh
  57942. * @param options defines the options used to create the mesh
  57943. * @param scene defines the hosting scene
  57944. * @returns the ground mesh
  57945. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57946. */
  57947. static CreateGround(name: string, options: {
  57948. width?: number;
  57949. height?: number;
  57950. subdivisions?: number;
  57951. subdivisionsX?: number;
  57952. subdivisionsY?: number;
  57953. updatable?: boolean;
  57954. }, scene?: Nullable<Scene>): Mesh;
  57955. /**
  57956. * Creates a tiled ground mesh
  57957. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57958. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57959. * * 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
  57960. * * 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
  57961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57962. * @param name defines the name of the mesh
  57963. * @param options defines the options used to create the mesh
  57964. * @param scene defines the hosting scene
  57965. * @returns the tiled ground mesh
  57966. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57967. */
  57968. static CreateTiledGround(name: string, options: {
  57969. xmin: number;
  57970. zmin: number;
  57971. xmax: number;
  57972. zmax: number;
  57973. subdivisions?: {
  57974. w: number;
  57975. h: number;
  57976. };
  57977. precision?: {
  57978. w: number;
  57979. h: number;
  57980. };
  57981. updatable?: boolean;
  57982. }, scene?: Nullable<Scene>): Mesh;
  57983. /**
  57984. * Creates a ground mesh from a height map
  57985. * * The parameter `url` sets the URL of the height map image resource.
  57986. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57987. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57988. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57989. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57990. * * 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.
  57991. * * 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).
  57992. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57994. * @param name defines the name of the mesh
  57995. * @param url defines the url to the height map
  57996. * @param options defines the options used to create the mesh
  57997. * @param scene defines the hosting scene
  57998. * @returns the ground mesh
  57999. * @see https://doc.babylonjs.com/babylon101/height_map
  58000. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58001. */
  58002. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58003. width?: number;
  58004. height?: number;
  58005. subdivisions?: number;
  58006. minHeight?: number;
  58007. maxHeight?: number;
  58008. colorFilter?: Color3;
  58009. alphaFilter?: number;
  58010. updatable?: boolean;
  58011. onReady?: (mesh: GroundMesh) => void;
  58012. }, scene?: Nullable<Scene>): GroundMesh;
  58013. /**
  58014. * Creates a polygon mesh
  58015. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58016. * * 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
  58017. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58020. * * Remember you can only change the shape positions, not their number when updating a polygon
  58021. * @param name defines the name of the mesh
  58022. * @param options defines the options used to create the mesh
  58023. * @param scene defines the hosting scene
  58024. * @param earcutInjection can be used to inject your own earcut reference
  58025. * @returns the polygon mesh
  58026. */
  58027. static CreatePolygon(name: string, options: {
  58028. shape: Vector3[];
  58029. holes?: Vector3[][];
  58030. depth?: number;
  58031. faceUV?: Vector4[];
  58032. faceColors?: Color4[];
  58033. updatable?: boolean;
  58034. sideOrientation?: number;
  58035. frontUVs?: Vector4;
  58036. backUVs?: Vector4;
  58037. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58038. /**
  58039. * Creates an extruded polygon mesh, with depth in the Y direction.
  58040. * * 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)
  58041. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58042. * @param name defines the name of the mesh
  58043. * @param options defines the options used to create the mesh
  58044. * @param scene defines the hosting scene
  58045. * @param earcutInjection can be used to inject your own earcut reference
  58046. * @returns the polygon mesh
  58047. */
  58048. static ExtrudePolygon(name: string, options: {
  58049. shape: Vector3[];
  58050. holes?: Vector3[][];
  58051. depth?: number;
  58052. faceUV?: Vector4[];
  58053. faceColors?: Color4[];
  58054. updatable?: boolean;
  58055. sideOrientation?: number;
  58056. frontUVs?: Vector4;
  58057. backUVs?: Vector4;
  58058. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58059. /**
  58060. * Creates a tube mesh.
  58061. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58062. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58063. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58064. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58065. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58066. * * 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)
  58067. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58068. * * 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
  58069. * * 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
  58070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58072. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58074. * @param name defines the name of the mesh
  58075. * @param options defines the options used to create the mesh
  58076. * @param scene defines the hosting scene
  58077. * @returns the tube mesh
  58078. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58079. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58080. */
  58081. static CreateTube(name: string, options: {
  58082. path: Vector3[];
  58083. radius?: number;
  58084. tessellation?: number;
  58085. radiusFunction?: {
  58086. (i: number, distance: number): number;
  58087. };
  58088. cap?: number;
  58089. arc?: number;
  58090. updatable?: boolean;
  58091. sideOrientation?: number;
  58092. frontUVs?: Vector4;
  58093. backUVs?: Vector4;
  58094. instance?: Mesh;
  58095. invertUV?: boolean;
  58096. }, scene?: Nullable<Scene>): Mesh;
  58097. /**
  58098. * Creates a polyhedron mesh
  58099. * * 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
  58100. * * The parameter `size` (positive float, default 1) sets the polygon size
  58101. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58102. * * 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`
  58103. * * 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
  58104. * * 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)`)
  58105. * * 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
  58106. * * 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
  58107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58110. * @param name defines the name of the mesh
  58111. * @param options defines the options used to create the mesh
  58112. * @param scene defines the hosting scene
  58113. * @returns the polyhedron mesh
  58114. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58115. */
  58116. static CreatePolyhedron(name: string, options: {
  58117. type?: number;
  58118. size?: number;
  58119. sizeX?: number;
  58120. sizeY?: number;
  58121. sizeZ?: number;
  58122. custom?: any;
  58123. faceUV?: Vector4[];
  58124. faceColors?: Color4[];
  58125. flat?: boolean;
  58126. updatable?: boolean;
  58127. sideOrientation?: number;
  58128. frontUVs?: Vector4;
  58129. backUVs?: Vector4;
  58130. }, scene?: Nullable<Scene>): Mesh;
  58131. /**
  58132. * Creates a decal mesh.
  58133. * 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
  58134. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58135. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58136. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58137. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58138. * @param name defines the name of the mesh
  58139. * @param sourceMesh defines the mesh where the decal must be applied
  58140. * @param options defines the options used to create the mesh
  58141. * @param scene defines the hosting scene
  58142. * @returns the decal mesh
  58143. * @see https://doc.babylonjs.com/how_to/decals
  58144. */
  58145. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58146. position?: Vector3;
  58147. normal?: Vector3;
  58148. size?: Vector3;
  58149. angle?: number;
  58150. }): Mesh;
  58151. }
  58152. }
  58153. declare module "babylonjs/Meshes/meshSimplification" {
  58154. import { Mesh } from "babylonjs/Meshes/mesh";
  58155. /**
  58156. * A simplifier interface for future simplification implementations
  58157. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58158. */
  58159. export interface ISimplifier {
  58160. /**
  58161. * Simplification of a given mesh according to the given settings.
  58162. * Since this requires computation, it is assumed that the function runs async.
  58163. * @param settings The settings of the simplification, including quality and distance
  58164. * @param successCallback A callback that will be called after the mesh was simplified.
  58165. * @param errorCallback in case of an error, this callback will be called. optional.
  58166. */
  58167. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58168. }
  58169. /**
  58170. * Expected simplification settings.
  58171. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58172. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58173. */
  58174. export interface ISimplificationSettings {
  58175. /**
  58176. * Gets or sets the expected quality
  58177. */
  58178. quality: number;
  58179. /**
  58180. * Gets or sets the distance when this optimized version should be used
  58181. */
  58182. distance: number;
  58183. /**
  58184. * Gets an already optimized mesh
  58185. */
  58186. optimizeMesh?: boolean;
  58187. }
  58188. /**
  58189. * Class used to specify simplification options
  58190. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58191. */
  58192. export class SimplificationSettings implements ISimplificationSettings {
  58193. /** expected quality */
  58194. quality: number;
  58195. /** distance when this optimized version should be used */
  58196. distance: number;
  58197. /** already optimized mesh */
  58198. optimizeMesh?: boolean | undefined;
  58199. /**
  58200. * Creates a SimplificationSettings
  58201. * @param quality expected quality
  58202. * @param distance distance when this optimized version should be used
  58203. * @param optimizeMesh already optimized mesh
  58204. */
  58205. constructor(
  58206. /** expected quality */
  58207. quality: number,
  58208. /** distance when this optimized version should be used */
  58209. distance: number,
  58210. /** already optimized mesh */
  58211. optimizeMesh?: boolean | undefined);
  58212. }
  58213. /**
  58214. * Interface used to define a simplification task
  58215. */
  58216. export interface ISimplificationTask {
  58217. /**
  58218. * Array of settings
  58219. */
  58220. settings: Array<ISimplificationSettings>;
  58221. /**
  58222. * Simplification type
  58223. */
  58224. simplificationType: SimplificationType;
  58225. /**
  58226. * Mesh to simplify
  58227. */
  58228. mesh: Mesh;
  58229. /**
  58230. * Callback called on success
  58231. */
  58232. successCallback?: () => void;
  58233. /**
  58234. * Defines if parallel processing can be used
  58235. */
  58236. parallelProcessing: boolean;
  58237. }
  58238. /**
  58239. * Queue used to order the simplification tasks
  58240. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58241. */
  58242. export class SimplificationQueue {
  58243. private _simplificationArray;
  58244. /**
  58245. * Gets a boolean indicating that the process is still running
  58246. */
  58247. running: boolean;
  58248. /**
  58249. * Creates a new queue
  58250. */
  58251. constructor();
  58252. /**
  58253. * Adds a new simplification task
  58254. * @param task defines a task to add
  58255. */
  58256. addTask(task: ISimplificationTask): void;
  58257. /**
  58258. * Execute next task
  58259. */
  58260. executeNext(): void;
  58261. /**
  58262. * Execute a simplification task
  58263. * @param task defines the task to run
  58264. */
  58265. runSimplification(task: ISimplificationTask): void;
  58266. private getSimplifier;
  58267. }
  58268. /**
  58269. * The implemented types of simplification
  58270. * At the moment only Quadratic Error Decimation is implemented
  58271. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58272. */
  58273. export enum SimplificationType {
  58274. /** Quadratic error decimation */
  58275. QUADRATIC = 0
  58276. }
  58277. }
  58278. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  58279. import { Scene } from "babylonjs/scene";
  58280. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  58281. import { ISceneComponent } from "babylonjs/sceneComponent";
  58282. module "babylonjs/scene" {
  58283. interface Scene {
  58284. /** @hidden (Backing field) */
  58285. _simplificationQueue: SimplificationQueue;
  58286. /**
  58287. * Gets or sets the simplification queue attached to the scene
  58288. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58289. */
  58290. simplificationQueue: SimplificationQueue;
  58291. }
  58292. }
  58293. module "babylonjs/Meshes/mesh" {
  58294. interface Mesh {
  58295. /**
  58296. * Simplify the mesh according to the given array of settings.
  58297. * Function will return immediately and will simplify async
  58298. * @param settings a collection of simplification settings
  58299. * @param parallelProcessing should all levels calculate parallel or one after the other
  58300. * @param simplificationType the type of simplification to run
  58301. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58302. * @returns the current mesh
  58303. */
  58304. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58305. }
  58306. }
  58307. /**
  58308. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58309. * created in a scene
  58310. */
  58311. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58312. /**
  58313. * The component name helpfull to identify the component in the list of scene components.
  58314. */
  58315. readonly name: string;
  58316. /**
  58317. * The scene the component belongs to.
  58318. */
  58319. scene: Scene;
  58320. /**
  58321. * Creates a new instance of the component for the given scene
  58322. * @param scene Defines the scene to register the component in
  58323. */
  58324. constructor(scene: Scene);
  58325. /**
  58326. * Registers the component in a given scene
  58327. */
  58328. register(): void;
  58329. /**
  58330. * Rebuilds the elements related to this component in case of
  58331. * context lost for instance.
  58332. */
  58333. rebuild(): void;
  58334. /**
  58335. * Disposes the component and the associated ressources
  58336. */
  58337. dispose(): void;
  58338. private _beforeCameraUpdate;
  58339. }
  58340. }
  58341. declare module "babylonjs/Meshes/Builders/index" {
  58342. export * from "babylonjs/Meshes/Builders/boxBuilder";
  58343. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  58344. export * from "babylonjs/Meshes/Builders/discBuilder";
  58345. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  58346. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  58347. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  58348. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  58349. export * from "babylonjs/Meshes/Builders/torusBuilder";
  58350. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  58351. export * from "babylonjs/Meshes/Builders/linesBuilder";
  58352. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  58353. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  58354. export * from "babylonjs/Meshes/Builders/latheBuilder";
  58355. export * from "babylonjs/Meshes/Builders/planeBuilder";
  58356. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  58357. export * from "babylonjs/Meshes/Builders/groundBuilder";
  58358. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  58359. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  58360. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  58361. export * from "babylonjs/Meshes/Builders/decalBuilder";
  58362. }
  58363. declare module "babylonjs/Meshes/index" {
  58364. export * from "babylonjs/Meshes/abstractMesh";
  58365. export * from "babylonjs/Meshes/buffer";
  58366. export * from "babylonjs/Meshes/Compression/index";
  58367. export * from "babylonjs/Meshes/csg";
  58368. export * from "babylonjs/Meshes/geometry";
  58369. export * from "babylonjs/Meshes/groundMesh";
  58370. export * from "babylonjs/Meshes/trailMesh";
  58371. export * from "babylonjs/Meshes/instancedMesh";
  58372. export * from "babylonjs/Meshes/linesMesh";
  58373. export * from "babylonjs/Meshes/mesh";
  58374. export * from "babylonjs/Meshes/mesh.vertexData";
  58375. export * from "babylonjs/Meshes/meshBuilder";
  58376. export * from "babylonjs/Meshes/meshSimplification";
  58377. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  58378. export * from "babylonjs/Meshes/polygonMesh";
  58379. export * from "babylonjs/Meshes/subMesh";
  58380. export * from "babylonjs/Meshes/meshLODLevel";
  58381. export * from "babylonjs/Meshes/transformNode";
  58382. export * from "babylonjs/Meshes/Builders/index";
  58383. export * from "babylonjs/Meshes/dataBuffer";
  58384. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  58385. }
  58386. declare module "babylonjs/Morph/index" {
  58387. export * from "babylonjs/Morph/morphTarget";
  58388. export * from "babylonjs/Morph/morphTargetManager";
  58389. }
  58390. declare module "babylonjs/Navigation/INavigationEngine" {
  58391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58392. import { Vector3 } from "babylonjs/Maths/math";
  58393. import { Mesh } from "babylonjs/Meshes/mesh";
  58394. import { Scene } from "babylonjs/scene";
  58395. /**
  58396. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58397. */
  58398. export interface INavigationEnginePlugin {
  58399. /**
  58400. * plugin name
  58401. */
  58402. name: string;
  58403. /**
  58404. * Creates a navigation mesh
  58405. * @param meshes array of all the geometry used to compute the navigatio mesh
  58406. * @param parameters bunch of parameters used to filter geometry
  58407. */
  58408. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58409. /**
  58410. * Create a navigation mesh debug mesh
  58411. * @param scene is where the mesh will be added
  58412. * @returns debug display mesh
  58413. */
  58414. createDebugNavMesh(scene: Scene): Mesh;
  58415. /**
  58416. * Get a navigation mesh constrained position, closest to the parameter position
  58417. * @param position world position
  58418. * @returns the closest point to position constrained by the navigation mesh
  58419. */
  58420. getClosestPoint(position: Vector3): Vector3;
  58421. /**
  58422. * Get a navigation mesh constrained position, within a particular radius
  58423. * @param position world position
  58424. * @param maxRadius the maximum distance to the constrained world position
  58425. * @returns the closest point to position constrained by the navigation mesh
  58426. */
  58427. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58428. /**
  58429. * Compute the final position from a segment made of destination-position
  58430. * @param position world position
  58431. * @param destination world position
  58432. * @returns the resulting point along the navmesh
  58433. */
  58434. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58435. /**
  58436. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58437. * @param start world position
  58438. * @param end world position
  58439. * @returns array containing world position composing the path
  58440. */
  58441. computePath(start: Vector3, end: Vector3): Vector3[];
  58442. /**
  58443. * If this plugin is supported
  58444. * @returns true if plugin is supported
  58445. */
  58446. isSupported(): boolean;
  58447. /**
  58448. * Create a new Crowd so you can add agents
  58449. * @param maxAgents the maximum agent count in the crowd
  58450. * @param maxAgentRadius the maximum radius an agent can have
  58451. * @param scene to attach the crowd to
  58452. * @returns the crowd you can add agents to
  58453. */
  58454. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58455. /**
  58456. * Release all resources
  58457. */
  58458. dispose(): void;
  58459. }
  58460. /**
  58461. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58462. */
  58463. export interface ICrowd {
  58464. /**
  58465. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58466. * You can attach anything to that node. The node position is updated in the scene update tick.
  58467. * @param pos world position that will be constrained by the navigation mesh
  58468. * @param parameters agent parameters
  58469. * @param transform hooked to the agent that will be update by the scene
  58470. * @returns agent index
  58471. */
  58472. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58473. /**
  58474. * Returns the agent position in world space
  58475. * @param index agent index returned by addAgent
  58476. * @returns world space position
  58477. */
  58478. getAgentPosition(index: number): Vector3;
  58479. /**
  58480. * Gets the agent velocity in world space
  58481. * @param index agent index returned by addAgent
  58482. * @returns world space velocity
  58483. */
  58484. getAgentVelocity(index: number): Vector3;
  58485. /**
  58486. * remove a particular agent previously created
  58487. * @param index agent index returned by addAgent
  58488. */
  58489. removeAgent(index: number): void;
  58490. /**
  58491. * get the list of all agents attached to this crowd
  58492. * @returns list of agent indices
  58493. */
  58494. getAgents(): number[];
  58495. /**
  58496. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58497. * @param deltaTime in seconds
  58498. */
  58499. update(deltaTime: number): void;
  58500. /**
  58501. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58502. * @param index agent index returned by addAgent
  58503. * @param destination targeted world position
  58504. */
  58505. agentGoto(index: number, destination: Vector3): void;
  58506. /**
  58507. * Release all resources
  58508. */
  58509. dispose(): void;
  58510. }
  58511. /**
  58512. * Configures an agent
  58513. */
  58514. export interface IAgentParameters {
  58515. /**
  58516. * Agent radius. [Limit: >= 0]
  58517. */
  58518. radius: number;
  58519. /**
  58520. * Agent height. [Limit: > 0]
  58521. */
  58522. height: number;
  58523. /**
  58524. * Maximum allowed acceleration. [Limit: >= 0]
  58525. */
  58526. maxAcceleration: number;
  58527. /**
  58528. * Maximum allowed speed. [Limit: >= 0]
  58529. */
  58530. maxSpeed: number;
  58531. /**
  58532. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58533. */
  58534. collisionQueryRange: number;
  58535. /**
  58536. * The path visibility optimization range. [Limit: > 0]
  58537. */
  58538. pathOptimizationRange: number;
  58539. /**
  58540. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58541. */
  58542. separationWeight: number;
  58543. }
  58544. /**
  58545. * Configures the navigation mesh creation
  58546. */
  58547. export interface INavMeshParameters {
  58548. /**
  58549. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58550. */
  58551. cs: number;
  58552. /**
  58553. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58554. */
  58555. ch: number;
  58556. /**
  58557. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58558. */
  58559. walkableSlopeAngle: number;
  58560. /**
  58561. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58562. * be considered walkable. [Limit: >= 3] [Units: vx]
  58563. */
  58564. walkableHeight: number;
  58565. /**
  58566. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58567. */
  58568. walkableClimb: number;
  58569. /**
  58570. * The distance to erode/shrink the walkable area of the heightfield away from
  58571. * obstructions. [Limit: >=0] [Units: vx]
  58572. */
  58573. walkableRadius: number;
  58574. /**
  58575. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58576. */
  58577. maxEdgeLen: number;
  58578. /**
  58579. * The maximum distance a simplfied contour's border edges should deviate
  58580. * the original raw contour. [Limit: >=0] [Units: vx]
  58581. */
  58582. maxSimplificationError: number;
  58583. /**
  58584. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58585. */
  58586. minRegionArea: number;
  58587. /**
  58588. * Any regions with a span count smaller than this value will, if possible,
  58589. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58590. */
  58591. mergeRegionArea: number;
  58592. /**
  58593. * The maximum number of vertices allowed for polygons generated during the
  58594. * contour to polygon conversion process. [Limit: >= 3]
  58595. */
  58596. maxVertsPerPoly: number;
  58597. /**
  58598. * Sets the sampling distance to use when generating the detail mesh.
  58599. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58600. */
  58601. detailSampleDist: number;
  58602. /**
  58603. * The maximum distance the detail mesh surface should deviate from heightfield
  58604. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58605. */
  58606. detailSampleMaxError: number;
  58607. }
  58608. }
  58609. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  58610. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  58611. import { Mesh } from "babylonjs/Meshes/mesh";
  58612. import { Scene } from "babylonjs/scene";
  58613. import { Vector3 } from "babylonjs/Maths/math";
  58614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58615. /**
  58616. * RecastJS navigation plugin
  58617. */
  58618. export class RecastJSPlugin implements INavigationEnginePlugin {
  58619. /**
  58620. * Reference to the Recast library
  58621. */
  58622. bjsRECAST: any;
  58623. /**
  58624. * plugin name
  58625. */
  58626. name: string;
  58627. /**
  58628. * the first navmesh created. We might extend this to support multiple navmeshes
  58629. */
  58630. navMesh: any;
  58631. /**
  58632. * Initializes the recastJS plugin
  58633. * @param recastInjection can be used to inject your own recast reference
  58634. */
  58635. constructor(recastInjection?: any);
  58636. /**
  58637. * Creates a navigation mesh
  58638. * @param meshes array of all the geometry used to compute the navigatio mesh
  58639. * @param parameters bunch of parameters used to filter geometry
  58640. */
  58641. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58642. /**
  58643. * Create a navigation mesh debug mesh
  58644. * @param scene is where the mesh will be added
  58645. * @returns debug display mesh
  58646. */
  58647. createDebugNavMesh(scene: Scene): Mesh;
  58648. /**
  58649. * Get a navigation mesh constrained position, closest to the parameter position
  58650. * @param position world position
  58651. * @returns the closest point to position constrained by the navigation mesh
  58652. */
  58653. getClosestPoint(position: Vector3): Vector3;
  58654. /**
  58655. * Get a navigation mesh constrained position, within a particular radius
  58656. * @param position world position
  58657. * @param maxRadius the maximum distance to the constrained world position
  58658. * @returns the closest point to position constrained by the navigation mesh
  58659. */
  58660. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58661. /**
  58662. * Compute the final position from a segment made of destination-position
  58663. * @param position world position
  58664. * @param destination world position
  58665. * @returns the resulting point along the navmesh
  58666. */
  58667. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58668. /**
  58669. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58670. * @param start world position
  58671. * @param end world position
  58672. * @returns array containing world position composing the path
  58673. */
  58674. computePath(start: Vector3, end: Vector3): Vector3[];
  58675. /**
  58676. * Create a new Crowd so you can add agents
  58677. * @param maxAgents the maximum agent count in the crowd
  58678. * @param maxAgentRadius the maximum radius an agent can have
  58679. * @param scene to attach the crowd to
  58680. * @returns the crowd you can add agents to
  58681. */
  58682. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58683. /**
  58684. * Disposes
  58685. */
  58686. dispose(): void;
  58687. /**
  58688. * If this plugin is supported
  58689. * @returns true if plugin is supported
  58690. */
  58691. isSupported(): boolean;
  58692. }
  58693. /**
  58694. * Recast detour crowd implementation
  58695. */
  58696. export class RecastJSCrowd implements ICrowd {
  58697. /**
  58698. * Recast/detour plugin
  58699. */
  58700. bjsRECASTPlugin: RecastJSPlugin;
  58701. /**
  58702. * Link to the detour crowd
  58703. */
  58704. recastCrowd: any;
  58705. /**
  58706. * One transform per agent
  58707. */
  58708. transforms: TransformNode[];
  58709. /**
  58710. * All agents created
  58711. */
  58712. agents: number[];
  58713. /**
  58714. * Link to the scene is kept to unregister the crowd from the scene
  58715. */
  58716. private _scene;
  58717. /**
  58718. * Observer for crowd updates
  58719. */
  58720. private _onBeforeAnimationsObserver;
  58721. /**
  58722. * Constructor
  58723. * @param plugin recastJS plugin
  58724. * @param maxAgents the maximum agent count in the crowd
  58725. * @param maxAgentRadius the maximum radius an agent can have
  58726. * @param scene to attach the crowd to
  58727. * @returns the crowd you can add agents to
  58728. */
  58729. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58730. /**
  58731. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58732. * You can attach anything to that node. The node position is updated in the scene update tick.
  58733. * @param pos world position that will be constrained by the navigation mesh
  58734. * @param parameters agent parameters
  58735. * @param transform hooked to the agent that will be update by the scene
  58736. * @returns agent index
  58737. */
  58738. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58739. /**
  58740. * Returns the agent position in world space
  58741. * @param index agent index returned by addAgent
  58742. * @returns world space position
  58743. */
  58744. getAgentPosition(index: number): Vector3;
  58745. /**
  58746. * Returns the agent velocity in world space
  58747. * @param index agent index returned by addAgent
  58748. * @returns world space velocity
  58749. */
  58750. getAgentVelocity(index: number): Vector3;
  58751. /**
  58752. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58753. * @param index agent index returned by addAgent
  58754. * @param destination targeted world position
  58755. */
  58756. agentGoto(index: number, destination: Vector3): void;
  58757. /**
  58758. * remove a particular agent previously created
  58759. * @param index agent index returned by addAgent
  58760. */
  58761. removeAgent(index: number): void;
  58762. /**
  58763. * get the list of all agents attached to this crowd
  58764. * @returns list of agent indices
  58765. */
  58766. getAgents(): number[];
  58767. /**
  58768. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58769. * @param deltaTime in seconds
  58770. */
  58771. update(deltaTime: number): void;
  58772. /**
  58773. * Release all resources
  58774. */
  58775. dispose(): void;
  58776. }
  58777. }
  58778. declare module "babylonjs/Navigation/Plugins/index" {
  58779. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58780. }
  58781. declare module "babylonjs/Navigation/index" {
  58782. export * from "babylonjs/Navigation/INavigationEngine";
  58783. export * from "babylonjs/Navigation/Plugins/index";
  58784. }
  58785. declare module "babylonjs/Offline/database" {
  58786. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58787. /**
  58788. * Class used to enable access to IndexedDB
  58789. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58790. */
  58791. export class Database implements IOfflineProvider {
  58792. private _callbackManifestChecked;
  58793. private _currentSceneUrl;
  58794. private _db;
  58795. private _enableSceneOffline;
  58796. private _enableTexturesOffline;
  58797. private _manifestVersionFound;
  58798. private _mustUpdateRessources;
  58799. private _hasReachedQuota;
  58800. private _isSupported;
  58801. private _idbFactory;
  58802. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58803. private static IsUASupportingBlobStorage;
  58804. /**
  58805. * Gets a boolean indicating if Database storate is enabled (off by default)
  58806. */
  58807. static IDBStorageEnabled: boolean;
  58808. /**
  58809. * Gets a boolean indicating if scene must be saved in the database
  58810. */
  58811. readonly enableSceneOffline: boolean;
  58812. /**
  58813. * Gets a boolean indicating if textures must be saved in the database
  58814. */
  58815. readonly enableTexturesOffline: boolean;
  58816. /**
  58817. * Creates a new Database
  58818. * @param urlToScene defines the url to load the scene
  58819. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58820. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58821. */
  58822. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58823. private static _ParseURL;
  58824. private static _ReturnFullUrlLocation;
  58825. private _checkManifestFile;
  58826. /**
  58827. * Open the database and make it available
  58828. * @param successCallback defines the callback to call on success
  58829. * @param errorCallback defines the callback to call on error
  58830. */
  58831. open(successCallback: () => void, errorCallback: () => void): void;
  58832. /**
  58833. * Loads an image from the database
  58834. * @param url defines the url to load from
  58835. * @param image defines the target DOM image
  58836. */
  58837. loadImage(url: string, image: HTMLImageElement): void;
  58838. private _loadImageFromDBAsync;
  58839. private _saveImageIntoDBAsync;
  58840. private _checkVersionFromDB;
  58841. private _loadVersionFromDBAsync;
  58842. private _saveVersionIntoDBAsync;
  58843. /**
  58844. * Loads a file from database
  58845. * @param url defines the URL to load from
  58846. * @param sceneLoaded defines a callback to call on success
  58847. * @param progressCallBack defines a callback to call when progress changed
  58848. * @param errorCallback defines a callback to call on error
  58849. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58850. */
  58851. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58852. private _loadFileAsync;
  58853. private _saveFileAsync;
  58854. /**
  58855. * Validates if xhr data is correct
  58856. * @param xhr defines the request to validate
  58857. * @param dataType defines the expected data type
  58858. * @returns true if data is correct
  58859. */
  58860. private static _ValidateXHRData;
  58861. }
  58862. }
  58863. declare module "babylonjs/Offline/index" {
  58864. export * from "babylonjs/Offline/database";
  58865. export * from "babylonjs/Offline/IOfflineProvider";
  58866. }
  58867. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  58868. /** @hidden */
  58869. export var gpuUpdateParticlesPixelShader: {
  58870. name: string;
  58871. shader: string;
  58872. };
  58873. }
  58874. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  58875. /** @hidden */
  58876. export var gpuUpdateParticlesVertexShader: {
  58877. name: string;
  58878. shader: string;
  58879. };
  58880. }
  58881. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  58882. /** @hidden */
  58883. export var clipPlaneFragmentDeclaration2: {
  58884. name: string;
  58885. shader: string;
  58886. };
  58887. }
  58888. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  58889. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  58890. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58891. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58892. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58893. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58894. /** @hidden */
  58895. export var gpuRenderParticlesPixelShader: {
  58896. name: string;
  58897. shader: string;
  58898. };
  58899. }
  58900. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  58901. /** @hidden */
  58902. export var clipPlaneVertexDeclaration2: {
  58903. name: string;
  58904. shader: string;
  58905. };
  58906. }
  58907. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  58908. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  58909. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58910. /** @hidden */
  58911. export var gpuRenderParticlesVertexShader: {
  58912. name: string;
  58913. shader: string;
  58914. };
  58915. }
  58916. declare module "babylonjs/Particles/gpuParticleSystem" {
  58917. import { Nullable } from "babylonjs/types";
  58918. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  58919. import { Observable } from "babylonjs/Misc/observable";
  58920. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58921. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58922. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  58923. import { Scene, IDisposable } from "babylonjs/scene";
  58924. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  58925. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58926. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  58927. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  58928. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  58929. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  58930. /**
  58931. * This represents a GPU particle system in Babylon
  58932. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58933. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58934. */
  58935. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58936. /**
  58937. * The layer mask we are rendering the particles through.
  58938. */
  58939. layerMask: number;
  58940. private _capacity;
  58941. private _activeCount;
  58942. private _currentActiveCount;
  58943. private _accumulatedCount;
  58944. private _renderEffect;
  58945. private _updateEffect;
  58946. private _buffer0;
  58947. private _buffer1;
  58948. private _spriteBuffer;
  58949. private _updateVAO;
  58950. private _renderVAO;
  58951. private _targetIndex;
  58952. private _sourceBuffer;
  58953. private _targetBuffer;
  58954. private _engine;
  58955. private _currentRenderId;
  58956. private _started;
  58957. private _stopped;
  58958. private _timeDelta;
  58959. private _randomTexture;
  58960. private _randomTexture2;
  58961. private _attributesStrideSize;
  58962. private _updateEffectOptions;
  58963. private _randomTextureSize;
  58964. private _actualFrame;
  58965. private readonly _rawTextureWidth;
  58966. /**
  58967. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58968. */
  58969. static readonly IsSupported: boolean;
  58970. /**
  58971. * An event triggered when the system is disposed.
  58972. */
  58973. onDisposeObservable: Observable<GPUParticleSystem>;
  58974. /**
  58975. * Gets the maximum number of particles active at the same time.
  58976. * @returns The max number of active particles.
  58977. */
  58978. getCapacity(): number;
  58979. /**
  58980. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58981. * to override the particles.
  58982. */
  58983. forceDepthWrite: boolean;
  58984. /**
  58985. * Gets or set the number of active particles
  58986. */
  58987. activeParticleCount: number;
  58988. private _preWarmDone;
  58989. /**
  58990. * Is this system ready to be used/rendered
  58991. * @return true if the system is ready
  58992. */
  58993. isReady(): boolean;
  58994. /**
  58995. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58996. * @returns True if it has been started, otherwise false.
  58997. */
  58998. isStarted(): boolean;
  58999. /**
  59000. * Starts the particle system and begins to emit
  59001. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59002. */
  59003. start(delay?: number): void;
  59004. /**
  59005. * Stops the particle system.
  59006. */
  59007. stop(): void;
  59008. /**
  59009. * Remove all active particles
  59010. */
  59011. reset(): void;
  59012. /**
  59013. * Returns the string "GPUParticleSystem"
  59014. * @returns a string containing the class name
  59015. */
  59016. getClassName(): string;
  59017. private _colorGradientsTexture;
  59018. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59019. /**
  59020. * Adds a new color gradient
  59021. * @param gradient defines the gradient to use (between 0 and 1)
  59022. * @param color1 defines the color to affect to the specified gradient
  59023. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59024. * @returns the current particle system
  59025. */
  59026. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59027. /**
  59028. * Remove a specific color gradient
  59029. * @param gradient defines the gradient to remove
  59030. * @returns the current particle system
  59031. */
  59032. removeColorGradient(gradient: number): GPUParticleSystem;
  59033. private _angularSpeedGradientsTexture;
  59034. private _sizeGradientsTexture;
  59035. private _velocityGradientsTexture;
  59036. private _limitVelocityGradientsTexture;
  59037. private _dragGradientsTexture;
  59038. private _addFactorGradient;
  59039. /**
  59040. * Adds a new size gradient
  59041. * @param gradient defines the gradient to use (between 0 and 1)
  59042. * @param factor defines the size factor to affect to the specified gradient
  59043. * @returns the current particle system
  59044. */
  59045. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59046. /**
  59047. * Remove a specific size gradient
  59048. * @param gradient defines the gradient to remove
  59049. * @returns the current particle system
  59050. */
  59051. removeSizeGradient(gradient: number): GPUParticleSystem;
  59052. /**
  59053. * Adds a new angular speed gradient
  59054. * @param gradient defines the gradient to use (between 0 and 1)
  59055. * @param factor defines the angular speed to affect to the specified gradient
  59056. * @returns the current particle system
  59057. */
  59058. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59059. /**
  59060. * Remove a specific angular speed gradient
  59061. * @param gradient defines the gradient to remove
  59062. * @returns the current particle system
  59063. */
  59064. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59065. /**
  59066. * Adds a new velocity gradient
  59067. * @param gradient defines the gradient to use (between 0 and 1)
  59068. * @param factor defines the velocity to affect to the specified gradient
  59069. * @returns the current particle system
  59070. */
  59071. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59072. /**
  59073. * Remove a specific velocity gradient
  59074. * @param gradient defines the gradient to remove
  59075. * @returns the current particle system
  59076. */
  59077. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59078. /**
  59079. * Adds a new limit velocity gradient
  59080. * @param gradient defines the gradient to use (between 0 and 1)
  59081. * @param factor defines the limit velocity value to affect to the specified gradient
  59082. * @returns the current particle system
  59083. */
  59084. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59085. /**
  59086. * Remove a specific limit velocity gradient
  59087. * @param gradient defines the gradient to remove
  59088. * @returns the current particle system
  59089. */
  59090. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59091. /**
  59092. * Adds a new drag gradient
  59093. * @param gradient defines the gradient to use (between 0 and 1)
  59094. * @param factor defines the drag value to affect to the specified gradient
  59095. * @returns the current particle system
  59096. */
  59097. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59098. /**
  59099. * Remove a specific drag gradient
  59100. * @param gradient defines the gradient to remove
  59101. * @returns the current particle system
  59102. */
  59103. removeDragGradient(gradient: number): GPUParticleSystem;
  59104. /**
  59105. * Not supported by GPUParticleSystem
  59106. * @param gradient defines the gradient to use (between 0 and 1)
  59107. * @param factor defines the emit rate value to affect to the specified gradient
  59108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59109. * @returns the current particle system
  59110. */
  59111. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59112. /**
  59113. * Not supported by GPUParticleSystem
  59114. * @param gradient defines the gradient to remove
  59115. * @returns the current particle system
  59116. */
  59117. removeEmitRateGradient(gradient: number): IParticleSystem;
  59118. /**
  59119. * Not supported by GPUParticleSystem
  59120. * @param gradient defines the gradient to use (between 0 and 1)
  59121. * @param factor defines the start size value to affect to the specified gradient
  59122. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59123. * @returns the current particle system
  59124. */
  59125. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59126. /**
  59127. * Not supported by GPUParticleSystem
  59128. * @param gradient defines the gradient to remove
  59129. * @returns the current particle system
  59130. */
  59131. removeStartSizeGradient(gradient: number): IParticleSystem;
  59132. /**
  59133. * Not supported by GPUParticleSystem
  59134. * @param gradient defines the gradient to use (between 0 and 1)
  59135. * @param min defines the color remap minimal range
  59136. * @param max defines the color remap maximal range
  59137. * @returns the current particle system
  59138. */
  59139. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59140. /**
  59141. * Not supported by GPUParticleSystem
  59142. * @param gradient defines the gradient to remove
  59143. * @returns the current particle system
  59144. */
  59145. removeColorRemapGradient(): IParticleSystem;
  59146. /**
  59147. * Not supported by GPUParticleSystem
  59148. * @param gradient defines the gradient to use (between 0 and 1)
  59149. * @param min defines the alpha remap minimal range
  59150. * @param max defines the alpha remap maximal range
  59151. * @returns the current particle system
  59152. */
  59153. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59154. /**
  59155. * Not supported by GPUParticleSystem
  59156. * @param gradient defines the gradient to remove
  59157. * @returns the current particle system
  59158. */
  59159. removeAlphaRemapGradient(): IParticleSystem;
  59160. /**
  59161. * Not supported by GPUParticleSystem
  59162. * @param gradient defines the gradient to use (between 0 and 1)
  59163. * @param color defines the color to affect to the specified gradient
  59164. * @returns the current particle system
  59165. */
  59166. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59167. /**
  59168. * Not supported by GPUParticleSystem
  59169. * @param gradient defines the gradient to remove
  59170. * @returns the current particle system
  59171. */
  59172. removeRampGradient(): IParticleSystem;
  59173. /**
  59174. * Not supported by GPUParticleSystem
  59175. * @returns the list of ramp gradients
  59176. */
  59177. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59178. /**
  59179. * Not supported by GPUParticleSystem
  59180. * Gets or sets a boolean indicating that ramp gradients must be used
  59181. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59182. */
  59183. useRampGradients: boolean;
  59184. /**
  59185. * Not supported by GPUParticleSystem
  59186. * @param gradient defines the gradient to use (between 0 and 1)
  59187. * @param factor defines the life time factor to affect to the specified gradient
  59188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59189. * @returns the current particle system
  59190. */
  59191. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59192. /**
  59193. * Not supported by GPUParticleSystem
  59194. * @param gradient defines the gradient to remove
  59195. * @returns the current particle system
  59196. */
  59197. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59198. /**
  59199. * Instantiates a GPU particle system.
  59200. * 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.
  59201. * @param name The name of the particle system
  59202. * @param options The options used to create the system
  59203. * @param scene The scene the particle system belongs to
  59204. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59205. */
  59206. constructor(name: string, options: Partial<{
  59207. capacity: number;
  59208. randomTextureSize: number;
  59209. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59210. protected _reset(): void;
  59211. private _createUpdateVAO;
  59212. private _createRenderVAO;
  59213. private _initialize;
  59214. /** @hidden */
  59215. _recreateUpdateEffect(): void;
  59216. /** @hidden */
  59217. _recreateRenderEffect(): void;
  59218. /**
  59219. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59220. * @param preWarm defines if we are in the pre-warmimg phase
  59221. */
  59222. animate(preWarm?: boolean): void;
  59223. private _createFactorGradientTexture;
  59224. private _createSizeGradientTexture;
  59225. private _createAngularSpeedGradientTexture;
  59226. private _createVelocityGradientTexture;
  59227. private _createLimitVelocityGradientTexture;
  59228. private _createDragGradientTexture;
  59229. private _createColorGradientTexture;
  59230. /**
  59231. * Renders the particle system in its current state
  59232. * @param preWarm defines if the system should only update the particles but not render them
  59233. * @returns the current number of particles
  59234. */
  59235. render(preWarm?: boolean): number;
  59236. /**
  59237. * Rebuilds the particle system
  59238. */
  59239. rebuild(): void;
  59240. private _releaseBuffers;
  59241. private _releaseVAOs;
  59242. /**
  59243. * Disposes the particle system and free the associated resources
  59244. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59245. */
  59246. dispose(disposeTexture?: boolean): void;
  59247. /**
  59248. * Clones the particle system.
  59249. * @param name The name of the cloned object
  59250. * @param newEmitter The new emitter to use
  59251. * @returns the cloned particle system
  59252. */
  59253. clone(name: string, newEmitter: any): GPUParticleSystem;
  59254. /**
  59255. * Serializes the particle system to a JSON object.
  59256. * @returns the JSON object
  59257. */
  59258. serialize(): any;
  59259. /**
  59260. * Parses a JSON object to create a GPU particle system.
  59261. * @param parsedParticleSystem The JSON object to parse
  59262. * @param scene The scene to create the particle system in
  59263. * @param rootUrl The root url to use to load external dependencies like texture
  59264. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59265. * @returns the parsed GPU particle system
  59266. */
  59267. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59268. }
  59269. }
  59270. declare module "babylonjs/Particles/particleSystemSet" {
  59271. import { Nullable } from "babylonjs/types";
  59272. import { Color3 } from "babylonjs/Maths/math.color";
  59273. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59275. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59276. import { Scene, IDisposable } from "babylonjs/scene";
  59277. /**
  59278. * Represents a set of particle systems working together to create a specific effect
  59279. */
  59280. export class ParticleSystemSet implements IDisposable {
  59281. private _emitterCreationOptions;
  59282. private _emitterNode;
  59283. /**
  59284. * Gets the particle system list
  59285. */
  59286. systems: IParticleSystem[];
  59287. /**
  59288. * Gets the emitter node used with this set
  59289. */
  59290. readonly emitterNode: Nullable<TransformNode>;
  59291. /**
  59292. * Creates a new emitter mesh as a sphere
  59293. * @param options defines the options used to create the sphere
  59294. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59295. * @param scene defines the hosting scene
  59296. */
  59297. setEmitterAsSphere(options: {
  59298. diameter: number;
  59299. segments: number;
  59300. color: Color3;
  59301. }, renderingGroupId: number, scene: Scene): void;
  59302. /**
  59303. * Starts all particle systems of the set
  59304. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59305. */
  59306. start(emitter?: AbstractMesh): void;
  59307. /**
  59308. * Release all associated resources
  59309. */
  59310. dispose(): void;
  59311. /**
  59312. * Serialize the set into a JSON compatible object
  59313. * @returns a JSON compatible representation of the set
  59314. */
  59315. serialize(): any;
  59316. /**
  59317. * Parse a new ParticleSystemSet from a serialized source
  59318. * @param data defines a JSON compatible representation of the set
  59319. * @param scene defines the hosting scene
  59320. * @param gpu defines if we want GPU particles or CPU particles
  59321. * @returns a new ParticleSystemSet
  59322. */
  59323. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59324. }
  59325. }
  59326. declare module "babylonjs/Particles/particleHelper" {
  59327. import { Nullable } from "babylonjs/types";
  59328. import { Scene } from "babylonjs/scene";
  59329. import { Vector3 } from "babylonjs/Maths/math.vector";
  59330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59331. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59332. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  59333. /**
  59334. * This class is made for on one-liner static method to help creating particle system set.
  59335. */
  59336. export class ParticleHelper {
  59337. /**
  59338. * Gets or sets base Assets URL
  59339. */
  59340. static BaseAssetsUrl: string;
  59341. /**
  59342. * Create a default particle system that you can tweak
  59343. * @param emitter defines the emitter to use
  59344. * @param capacity defines the system capacity (default is 500 particles)
  59345. * @param scene defines the hosting scene
  59346. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59347. * @returns the new Particle system
  59348. */
  59349. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59350. /**
  59351. * This is the main static method (one-liner) of this helper to create different particle systems
  59352. * @param type This string represents the type to the particle system to create
  59353. * @param scene The scene where the particle system should live
  59354. * @param gpu If the system will use gpu
  59355. * @returns the ParticleSystemSet created
  59356. */
  59357. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59358. /**
  59359. * Static function used to export a particle system to a ParticleSystemSet variable.
  59360. * Please note that the emitter shape is not exported
  59361. * @param systems defines the particle systems to export
  59362. * @returns the created particle system set
  59363. */
  59364. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59365. }
  59366. }
  59367. declare module "babylonjs/Particles/particleSystemComponent" {
  59368. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59369. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  59370. import "babylonjs/Shaders/particles.vertex";
  59371. module "babylonjs/Engines/engine" {
  59372. interface Engine {
  59373. /**
  59374. * Create an effect to use with particle systems.
  59375. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59376. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59377. * @param uniformsNames defines a list of attribute names
  59378. * @param samplers defines an array of string used to represent textures
  59379. * @param defines defines the string containing the defines to use to compile the shaders
  59380. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59381. * @param onCompiled defines a function to call when the effect creation is successful
  59382. * @param onError defines a function to call when the effect creation has failed
  59383. * @returns the new Effect
  59384. */
  59385. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59386. }
  59387. }
  59388. module "babylonjs/Meshes/mesh" {
  59389. interface Mesh {
  59390. /**
  59391. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59392. * @returns an array of IParticleSystem
  59393. */
  59394. getEmittedParticleSystems(): IParticleSystem[];
  59395. /**
  59396. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59397. * @returns an array of IParticleSystem
  59398. */
  59399. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59400. }
  59401. }
  59402. /**
  59403. * @hidden
  59404. */
  59405. export var _IDoNeedToBeInTheBuild: number;
  59406. }
  59407. declare module "babylonjs/Particles/index" {
  59408. export * from "babylonjs/Particles/baseParticleSystem";
  59409. export * from "babylonjs/Particles/EmitterTypes/index";
  59410. export * from "babylonjs/Particles/gpuParticleSystem";
  59411. export * from "babylonjs/Particles/IParticleSystem";
  59412. export * from "babylonjs/Particles/particle";
  59413. export * from "babylonjs/Particles/particleHelper";
  59414. export * from "babylonjs/Particles/particleSystem";
  59415. export * from "babylonjs/Particles/particleSystemComponent";
  59416. export * from "babylonjs/Particles/particleSystemSet";
  59417. export * from "babylonjs/Particles/solidParticle";
  59418. export * from "babylonjs/Particles/solidParticleSystem";
  59419. export * from "babylonjs/Particles/subEmitter";
  59420. }
  59421. declare module "babylonjs/Physics/physicsEngineComponent" {
  59422. import { Nullable } from "babylonjs/types";
  59423. import { Observable, Observer } from "babylonjs/Misc/observable";
  59424. import { Vector3 } from "babylonjs/Maths/math.vector";
  59425. import { Mesh } from "babylonjs/Meshes/mesh";
  59426. import { ISceneComponent } from "babylonjs/sceneComponent";
  59427. import { Scene } from "babylonjs/scene";
  59428. import { Node } from "babylonjs/node";
  59429. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  59430. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59431. module "babylonjs/scene" {
  59432. interface Scene {
  59433. /** @hidden (Backing field) */
  59434. _physicsEngine: Nullable<IPhysicsEngine>;
  59435. /**
  59436. * Gets the current physics engine
  59437. * @returns a IPhysicsEngine or null if none attached
  59438. */
  59439. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59440. /**
  59441. * Enables physics to the current scene
  59442. * @param gravity defines the scene's gravity for the physics engine
  59443. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59444. * @return a boolean indicating if the physics engine was initialized
  59445. */
  59446. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59447. /**
  59448. * Disables and disposes the physics engine associated with the scene
  59449. */
  59450. disablePhysicsEngine(): void;
  59451. /**
  59452. * Gets a boolean indicating if there is an active physics engine
  59453. * @returns a boolean indicating if there is an active physics engine
  59454. */
  59455. isPhysicsEnabled(): boolean;
  59456. /**
  59457. * Deletes a physics compound impostor
  59458. * @param compound defines the compound to delete
  59459. */
  59460. deleteCompoundImpostor(compound: any): void;
  59461. /**
  59462. * An event triggered when physic simulation is about to be run
  59463. */
  59464. onBeforePhysicsObservable: Observable<Scene>;
  59465. /**
  59466. * An event triggered when physic simulation has been done
  59467. */
  59468. onAfterPhysicsObservable: Observable<Scene>;
  59469. }
  59470. }
  59471. module "babylonjs/Meshes/abstractMesh" {
  59472. interface AbstractMesh {
  59473. /** @hidden */
  59474. _physicsImpostor: Nullable<PhysicsImpostor>;
  59475. /**
  59476. * Gets or sets impostor used for physic simulation
  59477. * @see http://doc.babylonjs.com/features/physics_engine
  59478. */
  59479. physicsImpostor: Nullable<PhysicsImpostor>;
  59480. /**
  59481. * Gets the current physics impostor
  59482. * @see http://doc.babylonjs.com/features/physics_engine
  59483. * @returns a physics impostor or null
  59484. */
  59485. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59486. /** Apply a physic impulse to the mesh
  59487. * @param force defines the force to apply
  59488. * @param contactPoint defines where to apply the force
  59489. * @returns the current mesh
  59490. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59491. */
  59492. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59493. /**
  59494. * Creates a physic joint between two meshes
  59495. * @param otherMesh defines the other mesh to use
  59496. * @param pivot1 defines the pivot to use on this mesh
  59497. * @param pivot2 defines the pivot to use on the other mesh
  59498. * @param options defines additional options (can be plugin dependent)
  59499. * @returns the current mesh
  59500. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59501. */
  59502. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59503. /** @hidden */
  59504. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59505. }
  59506. }
  59507. /**
  59508. * Defines the physics engine scene component responsible to manage a physics engine
  59509. */
  59510. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59511. /**
  59512. * The component name helpful to identify the component in the list of scene components.
  59513. */
  59514. readonly name: string;
  59515. /**
  59516. * The scene the component belongs to.
  59517. */
  59518. scene: Scene;
  59519. /**
  59520. * Creates a new instance of the component for the given scene
  59521. * @param scene Defines the scene to register the component in
  59522. */
  59523. constructor(scene: Scene);
  59524. /**
  59525. * Registers the component in a given scene
  59526. */
  59527. register(): void;
  59528. /**
  59529. * Rebuilds the elements related to this component in case of
  59530. * context lost for instance.
  59531. */
  59532. rebuild(): void;
  59533. /**
  59534. * Disposes the component and the associated ressources
  59535. */
  59536. dispose(): void;
  59537. }
  59538. }
  59539. declare module "babylonjs/Physics/physicsHelper" {
  59540. import { Nullable } from "babylonjs/types";
  59541. import { Vector3 } from "babylonjs/Maths/math.vector";
  59542. import { Mesh } from "babylonjs/Meshes/mesh";
  59543. import { Scene } from "babylonjs/scene";
  59544. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59545. /**
  59546. * A helper for physics simulations
  59547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59548. */
  59549. export class PhysicsHelper {
  59550. private _scene;
  59551. private _physicsEngine;
  59552. /**
  59553. * Initializes the Physics helper
  59554. * @param scene Babylon.js scene
  59555. */
  59556. constructor(scene: Scene);
  59557. /**
  59558. * Applies a radial explosion impulse
  59559. * @param origin the origin of the explosion
  59560. * @param radiusOrEventOptions the radius or the options of radial explosion
  59561. * @param strength the explosion strength
  59562. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59563. * @returns A physics radial explosion event, or null
  59564. */
  59565. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59566. /**
  59567. * Applies a radial explosion force
  59568. * @param origin the origin of the explosion
  59569. * @param radiusOrEventOptions the radius or the options of radial explosion
  59570. * @param strength the explosion strength
  59571. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59572. * @returns A physics radial explosion event, or null
  59573. */
  59574. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59575. /**
  59576. * Creates a gravitational field
  59577. * @param origin the origin of the explosion
  59578. * @param radiusOrEventOptions the radius or the options of radial explosion
  59579. * @param strength the explosion strength
  59580. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59581. * @returns A physics gravitational field event, or null
  59582. */
  59583. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59584. /**
  59585. * Creates a physics updraft event
  59586. * @param origin the origin of the updraft
  59587. * @param radiusOrEventOptions the radius or the options of the updraft
  59588. * @param strength the strength of the updraft
  59589. * @param height the height of the updraft
  59590. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59591. * @returns A physics updraft event, or null
  59592. */
  59593. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59594. /**
  59595. * Creates a physics vortex event
  59596. * @param origin the of the vortex
  59597. * @param radiusOrEventOptions the radius or the options of the vortex
  59598. * @param strength the strength of the vortex
  59599. * @param height the height of the vortex
  59600. * @returns a Physics vortex event, or null
  59601. * A physics vortex event or null
  59602. */
  59603. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59604. }
  59605. /**
  59606. * Represents a physics radial explosion event
  59607. */
  59608. class PhysicsRadialExplosionEvent {
  59609. private _scene;
  59610. private _options;
  59611. private _sphere;
  59612. private _dataFetched;
  59613. /**
  59614. * Initializes a radial explosioin event
  59615. * @param _scene BabylonJS scene
  59616. * @param _options The options for the vortex event
  59617. */
  59618. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59619. /**
  59620. * Returns the data related to the radial explosion event (sphere).
  59621. * @returns The radial explosion event data
  59622. */
  59623. getData(): PhysicsRadialExplosionEventData;
  59624. /**
  59625. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59626. * @param impostor A physics imposter
  59627. * @param origin the origin of the explosion
  59628. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59629. */
  59630. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59631. /**
  59632. * Triggers affecterd impostors callbacks
  59633. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59634. */
  59635. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59636. /**
  59637. * Disposes the sphere.
  59638. * @param force Specifies if the sphere should be disposed by force
  59639. */
  59640. dispose(force?: boolean): void;
  59641. /*** Helpers ***/
  59642. private _prepareSphere;
  59643. private _intersectsWithSphere;
  59644. }
  59645. /**
  59646. * Represents a gravitational field event
  59647. */
  59648. class PhysicsGravitationalFieldEvent {
  59649. private _physicsHelper;
  59650. private _scene;
  59651. private _origin;
  59652. private _options;
  59653. private _tickCallback;
  59654. private _sphere;
  59655. private _dataFetched;
  59656. /**
  59657. * Initializes the physics gravitational field event
  59658. * @param _physicsHelper A physics helper
  59659. * @param _scene BabylonJS scene
  59660. * @param _origin The origin position of the gravitational field event
  59661. * @param _options The options for the vortex event
  59662. */
  59663. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59664. /**
  59665. * Returns the data related to the gravitational field event (sphere).
  59666. * @returns A gravitational field event
  59667. */
  59668. getData(): PhysicsGravitationalFieldEventData;
  59669. /**
  59670. * Enables the gravitational field.
  59671. */
  59672. enable(): void;
  59673. /**
  59674. * Disables the gravitational field.
  59675. */
  59676. disable(): void;
  59677. /**
  59678. * Disposes the sphere.
  59679. * @param force The force to dispose from the gravitational field event
  59680. */
  59681. dispose(force?: boolean): void;
  59682. private _tick;
  59683. }
  59684. /**
  59685. * Represents a physics updraft event
  59686. */
  59687. class PhysicsUpdraftEvent {
  59688. private _scene;
  59689. private _origin;
  59690. private _options;
  59691. private _physicsEngine;
  59692. private _originTop;
  59693. private _originDirection;
  59694. private _tickCallback;
  59695. private _cylinder;
  59696. private _cylinderPosition;
  59697. private _dataFetched;
  59698. /**
  59699. * Initializes the physics updraft event
  59700. * @param _scene BabylonJS scene
  59701. * @param _origin The origin position of the updraft
  59702. * @param _options The options for the updraft event
  59703. */
  59704. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59705. /**
  59706. * Returns the data related to the updraft event (cylinder).
  59707. * @returns A physics updraft event
  59708. */
  59709. getData(): PhysicsUpdraftEventData;
  59710. /**
  59711. * Enables the updraft.
  59712. */
  59713. enable(): void;
  59714. /**
  59715. * Disables the updraft.
  59716. */
  59717. disable(): void;
  59718. /**
  59719. * Disposes the cylinder.
  59720. * @param force Specifies if the updraft should be disposed by force
  59721. */
  59722. dispose(force?: boolean): void;
  59723. private getImpostorHitData;
  59724. private _tick;
  59725. /*** Helpers ***/
  59726. private _prepareCylinder;
  59727. private _intersectsWithCylinder;
  59728. }
  59729. /**
  59730. * Represents a physics vortex event
  59731. */
  59732. class PhysicsVortexEvent {
  59733. private _scene;
  59734. private _origin;
  59735. private _options;
  59736. private _physicsEngine;
  59737. private _originTop;
  59738. private _tickCallback;
  59739. private _cylinder;
  59740. private _cylinderPosition;
  59741. private _dataFetched;
  59742. /**
  59743. * Initializes the physics vortex event
  59744. * @param _scene The BabylonJS scene
  59745. * @param _origin The origin position of the vortex
  59746. * @param _options The options for the vortex event
  59747. */
  59748. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59749. /**
  59750. * Returns the data related to the vortex event (cylinder).
  59751. * @returns The physics vortex event data
  59752. */
  59753. getData(): PhysicsVortexEventData;
  59754. /**
  59755. * Enables the vortex.
  59756. */
  59757. enable(): void;
  59758. /**
  59759. * Disables the cortex.
  59760. */
  59761. disable(): void;
  59762. /**
  59763. * Disposes the sphere.
  59764. * @param force
  59765. */
  59766. dispose(force?: boolean): void;
  59767. private getImpostorHitData;
  59768. private _tick;
  59769. /*** Helpers ***/
  59770. private _prepareCylinder;
  59771. private _intersectsWithCylinder;
  59772. }
  59773. /**
  59774. * Options fot the radial explosion event
  59775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59776. */
  59777. export class PhysicsRadialExplosionEventOptions {
  59778. /**
  59779. * The radius of the sphere for the radial explosion.
  59780. */
  59781. radius: number;
  59782. /**
  59783. * The strenth of the explosion.
  59784. */
  59785. strength: number;
  59786. /**
  59787. * The strenght of the force in correspondence to the distance of the affected object
  59788. */
  59789. falloff: PhysicsRadialImpulseFalloff;
  59790. /**
  59791. * Sphere options for the radial explosion.
  59792. */
  59793. sphere: {
  59794. segments: number;
  59795. diameter: number;
  59796. };
  59797. /**
  59798. * Sphere options for the radial explosion.
  59799. */
  59800. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59801. }
  59802. /**
  59803. * Options fot the updraft event
  59804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59805. */
  59806. export class PhysicsUpdraftEventOptions {
  59807. /**
  59808. * The radius of the cylinder for the vortex
  59809. */
  59810. radius: number;
  59811. /**
  59812. * The strenth of the updraft.
  59813. */
  59814. strength: number;
  59815. /**
  59816. * The height of the cylinder for the updraft.
  59817. */
  59818. height: number;
  59819. /**
  59820. * The mode for the the updraft.
  59821. */
  59822. updraftMode: PhysicsUpdraftMode;
  59823. }
  59824. /**
  59825. * Options fot the vortex event
  59826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59827. */
  59828. export class PhysicsVortexEventOptions {
  59829. /**
  59830. * The radius of the cylinder for the vortex
  59831. */
  59832. radius: number;
  59833. /**
  59834. * The strenth of the vortex.
  59835. */
  59836. strength: number;
  59837. /**
  59838. * The height of the cylinder for the vortex.
  59839. */
  59840. height: number;
  59841. /**
  59842. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59843. */
  59844. centripetalForceThreshold: number;
  59845. /**
  59846. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59847. */
  59848. centripetalForceMultiplier: number;
  59849. /**
  59850. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59851. */
  59852. centrifugalForceMultiplier: number;
  59853. /**
  59854. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59855. */
  59856. updraftForceMultiplier: number;
  59857. }
  59858. /**
  59859. * The strenght of the force in correspondence to the distance of the affected object
  59860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59861. */
  59862. export enum PhysicsRadialImpulseFalloff {
  59863. /** Defines that impulse is constant in strength across it's whole radius */
  59864. Constant = 0,
  59865. /** Defines that impulse gets weaker if it's further from the origin */
  59866. Linear = 1
  59867. }
  59868. /**
  59869. * The strength of the force in correspondence to the distance of the affected object
  59870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59871. */
  59872. export enum PhysicsUpdraftMode {
  59873. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59874. Center = 0,
  59875. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59876. Perpendicular = 1
  59877. }
  59878. /**
  59879. * Interface for a physics hit data
  59880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59881. */
  59882. export interface PhysicsHitData {
  59883. /**
  59884. * The force applied at the contact point
  59885. */
  59886. force: Vector3;
  59887. /**
  59888. * The contact point
  59889. */
  59890. contactPoint: Vector3;
  59891. /**
  59892. * The distance from the origin to the contact point
  59893. */
  59894. distanceFromOrigin: number;
  59895. }
  59896. /**
  59897. * Interface for radial explosion event data
  59898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59899. */
  59900. export interface PhysicsRadialExplosionEventData {
  59901. /**
  59902. * A sphere used for the radial explosion event
  59903. */
  59904. sphere: Mesh;
  59905. }
  59906. /**
  59907. * Interface for gravitational field event data
  59908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59909. */
  59910. export interface PhysicsGravitationalFieldEventData {
  59911. /**
  59912. * A sphere mesh used for the gravitational field event
  59913. */
  59914. sphere: Mesh;
  59915. }
  59916. /**
  59917. * Interface for updraft event data
  59918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59919. */
  59920. export interface PhysicsUpdraftEventData {
  59921. /**
  59922. * A cylinder used for the updraft event
  59923. */
  59924. cylinder: Mesh;
  59925. }
  59926. /**
  59927. * Interface for vortex event data
  59928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59929. */
  59930. export interface PhysicsVortexEventData {
  59931. /**
  59932. * A cylinder used for the vortex event
  59933. */
  59934. cylinder: Mesh;
  59935. }
  59936. /**
  59937. * Interface for an affected physics impostor
  59938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59939. */
  59940. export interface PhysicsAffectedImpostorWithData {
  59941. /**
  59942. * The impostor affected by the effect
  59943. */
  59944. impostor: PhysicsImpostor;
  59945. /**
  59946. * The data about the hit/horce from the explosion
  59947. */
  59948. hitData: PhysicsHitData;
  59949. }
  59950. }
  59951. declare module "babylonjs/Physics/Plugins/index" {
  59952. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59953. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59954. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59955. }
  59956. declare module "babylonjs/Physics/index" {
  59957. export * from "babylonjs/Physics/IPhysicsEngine";
  59958. export * from "babylonjs/Physics/physicsEngine";
  59959. export * from "babylonjs/Physics/physicsEngineComponent";
  59960. export * from "babylonjs/Physics/physicsHelper";
  59961. export * from "babylonjs/Physics/physicsImpostor";
  59962. export * from "babylonjs/Physics/physicsJoint";
  59963. export * from "babylonjs/Physics/Plugins/index";
  59964. }
  59965. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59966. /** @hidden */
  59967. export var blackAndWhitePixelShader: {
  59968. name: string;
  59969. shader: string;
  59970. };
  59971. }
  59972. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59973. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59974. import { Camera } from "babylonjs/Cameras/camera";
  59975. import { Engine } from "babylonjs/Engines/engine";
  59976. import "babylonjs/Shaders/blackAndWhite.fragment";
  59977. /**
  59978. * Post process used to render in black and white
  59979. */
  59980. export class BlackAndWhitePostProcess extends PostProcess {
  59981. /**
  59982. * Linear about to convert he result to black and white (default: 1)
  59983. */
  59984. degree: number;
  59985. /**
  59986. * Creates a black and white post process
  59987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59988. * @param name The name of the effect.
  59989. * @param options The required width/height ratio to downsize to before computing the render pass.
  59990. * @param camera The camera to apply the render pass to.
  59991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59992. * @param engine The engine which the post process will be applied. (default: current engine)
  59993. * @param reusable If the post process can be reused on the same frame. (default: false)
  59994. */
  59995. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59996. }
  59997. }
  59998. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59999. import { Nullable } from "babylonjs/types";
  60000. import { Camera } from "babylonjs/Cameras/camera";
  60001. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60002. import { Engine } from "babylonjs/Engines/engine";
  60003. /**
  60004. * This represents a set of one or more post processes in Babylon.
  60005. * A post process can be used to apply a shader to a texture after it is rendered.
  60006. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60007. */
  60008. export class PostProcessRenderEffect {
  60009. private _postProcesses;
  60010. private _getPostProcesses;
  60011. private _singleInstance;
  60012. private _cameras;
  60013. private _indicesForCamera;
  60014. /**
  60015. * Name of the effect
  60016. * @hidden
  60017. */
  60018. _name: string;
  60019. /**
  60020. * Instantiates a post process render effect.
  60021. * A post process can be used to apply a shader to a texture after it is rendered.
  60022. * @param engine The engine the effect is tied to
  60023. * @param name The name of the effect
  60024. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60025. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60026. */
  60027. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60028. /**
  60029. * Checks if all the post processes in the effect are supported.
  60030. */
  60031. readonly isSupported: boolean;
  60032. /**
  60033. * Updates the current state of the effect
  60034. * @hidden
  60035. */
  60036. _update(): void;
  60037. /**
  60038. * Attaches the effect on cameras
  60039. * @param cameras The camera to attach to.
  60040. * @hidden
  60041. */
  60042. _attachCameras(cameras: Camera): void;
  60043. /**
  60044. * Attaches the effect on cameras
  60045. * @param cameras The camera to attach to.
  60046. * @hidden
  60047. */
  60048. _attachCameras(cameras: Camera[]): void;
  60049. /**
  60050. * Detaches the effect on cameras
  60051. * @param cameras The camera to detatch from.
  60052. * @hidden
  60053. */
  60054. _detachCameras(cameras: Camera): void;
  60055. /**
  60056. * Detatches the effect on cameras
  60057. * @param cameras The camera to detatch from.
  60058. * @hidden
  60059. */
  60060. _detachCameras(cameras: Camera[]): void;
  60061. /**
  60062. * Enables the effect on given cameras
  60063. * @param cameras The camera to enable.
  60064. * @hidden
  60065. */
  60066. _enable(cameras: Camera): void;
  60067. /**
  60068. * Enables the effect on given cameras
  60069. * @param cameras The camera to enable.
  60070. * @hidden
  60071. */
  60072. _enable(cameras: Nullable<Camera[]>): void;
  60073. /**
  60074. * Disables the effect on the given cameras
  60075. * @param cameras The camera to disable.
  60076. * @hidden
  60077. */
  60078. _disable(cameras: Camera): void;
  60079. /**
  60080. * Disables the effect on the given cameras
  60081. * @param cameras The camera to disable.
  60082. * @hidden
  60083. */
  60084. _disable(cameras: Nullable<Camera[]>): void;
  60085. /**
  60086. * Gets a list of the post processes contained in the effect.
  60087. * @param camera The camera to get the post processes on.
  60088. * @returns The list of the post processes in the effect.
  60089. */
  60090. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60091. }
  60092. }
  60093. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60094. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60095. /** @hidden */
  60096. export var extractHighlightsPixelShader: {
  60097. name: string;
  60098. shader: string;
  60099. };
  60100. }
  60101. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60102. import { Nullable } from "babylonjs/types";
  60103. import { Camera } from "babylonjs/Cameras/camera";
  60104. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60105. import { Engine } from "babylonjs/Engines/engine";
  60106. import "babylonjs/Shaders/extractHighlights.fragment";
  60107. /**
  60108. * 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.
  60109. */
  60110. export class ExtractHighlightsPostProcess extends PostProcess {
  60111. /**
  60112. * The luminance threshold, pixels below this value will be set to black.
  60113. */
  60114. threshold: number;
  60115. /** @hidden */
  60116. _exposure: number;
  60117. /**
  60118. * Post process which has the input texture to be used when performing highlight extraction
  60119. * @hidden
  60120. */
  60121. _inputPostProcess: Nullable<PostProcess>;
  60122. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60123. }
  60124. }
  60125. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60126. /** @hidden */
  60127. export var bloomMergePixelShader: {
  60128. name: string;
  60129. shader: string;
  60130. };
  60131. }
  60132. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  60133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60134. import { Nullable } from "babylonjs/types";
  60135. import { Engine } from "babylonjs/Engines/engine";
  60136. import { Camera } from "babylonjs/Cameras/camera";
  60137. import "babylonjs/Shaders/bloomMerge.fragment";
  60138. /**
  60139. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60140. */
  60141. export class BloomMergePostProcess extends PostProcess {
  60142. /** Weight of the bloom to be added to the original input. */
  60143. weight: number;
  60144. /**
  60145. * Creates a new instance of @see BloomMergePostProcess
  60146. * @param name The name of the effect.
  60147. * @param originalFromInput Post process which's input will be used for the merge.
  60148. * @param blurred Blurred highlights post process which's output will be used.
  60149. * @param weight Weight of the bloom to be added to the original input.
  60150. * @param options The required width/height ratio to downsize to before computing the render pass.
  60151. * @param camera The camera to apply the render pass to.
  60152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60153. * @param engine The engine which the post process will be applied. (default: current engine)
  60154. * @param reusable If the post process can be reused on the same frame. (default: false)
  60155. * @param textureType Type of textures used when performing the post process. (default: 0)
  60156. * @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)
  60157. */
  60158. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60159. /** Weight of the bloom to be added to the original input. */
  60160. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60161. }
  60162. }
  60163. declare module "babylonjs/PostProcesses/bloomEffect" {
  60164. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60165. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60166. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60167. import { Camera } from "babylonjs/Cameras/camera";
  60168. import { Scene } from "babylonjs/scene";
  60169. /**
  60170. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60171. */
  60172. export class BloomEffect extends PostProcessRenderEffect {
  60173. private bloomScale;
  60174. /**
  60175. * @hidden Internal
  60176. */
  60177. _effects: Array<PostProcess>;
  60178. /**
  60179. * @hidden Internal
  60180. */
  60181. _downscale: ExtractHighlightsPostProcess;
  60182. private _blurX;
  60183. private _blurY;
  60184. private _merge;
  60185. /**
  60186. * The luminance threshold to find bright areas of the image to bloom.
  60187. */
  60188. threshold: number;
  60189. /**
  60190. * The strength of the bloom.
  60191. */
  60192. weight: number;
  60193. /**
  60194. * Specifies the size of the bloom blur kernel, relative to the final output size
  60195. */
  60196. kernel: number;
  60197. /**
  60198. * Creates a new instance of @see BloomEffect
  60199. * @param scene The scene the effect belongs to.
  60200. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60201. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60202. * @param bloomWeight The the strength of bloom.
  60203. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60204. * @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)
  60205. */
  60206. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60207. /**
  60208. * Disposes each of the internal effects for a given camera.
  60209. * @param camera The camera to dispose the effect on.
  60210. */
  60211. disposeEffects(camera: Camera): void;
  60212. /**
  60213. * @hidden Internal
  60214. */
  60215. _updateEffects(): void;
  60216. /**
  60217. * Internal
  60218. * @returns if all the contained post processes are ready.
  60219. * @hidden
  60220. */
  60221. _isReady(): boolean;
  60222. }
  60223. }
  60224. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  60225. /** @hidden */
  60226. export var chromaticAberrationPixelShader: {
  60227. name: string;
  60228. shader: string;
  60229. };
  60230. }
  60231. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  60232. import { Vector2 } from "babylonjs/Maths/math.vector";
  60233. import { Nullable } from "babylonjs/types";
  60234. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60235. import { Camera } from "babylonjs/Cameras/camera";
  60236. import { Engine } from "babylonjs/Engines/engine";
  60237. import "babylonjs/Shaders/chromaticAberration.fragment";
  60238. /**
  60239. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60240. */
  60241. export class ChromaticAberrationPostProcess extends PostProcess {
  60242. /**
  60243. * The amount of seperation of rgb channels (default: 30)
  60244. */
  60245. aberrationAmount: number;
  60246. /**
  60247. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60248. */
  60249. radialIntensity: number;
  60250. /**
  60251. * 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))
  60252. */
  60253. direction: Vector2;
  60254. /**
  60255. * 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))
  60256. */
  60257. centerPosition: Vector2;
  60258. /**
  60259. * Creates a new instance ChromaticAberrationPostProcess
  60260. * @param name The name of the effect.
  60261. * @param screenWidth The width of the screen to apply the effect on.
  60262. * @param screenHeight The height of the screen to apply the effect on.
  60263. * @param options The required width/height ratio to downsize to before computing the render pass.
  60264. * @param camera The camera to apply the render pass to.
  60265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60266. * @param engine The engine which the post process will be applied. (default: current engine)
  60267. * @param reusable If the post process can be reused on the same frame. (default: false)
  60268. * @param textureType Type of textures used when performing the post process. (default: 0)
  60269. * @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)
  60270. */
  60271. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60272. }
  60273. }
  60274. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  60275. /** @hidden */
  60276. export var circleOfConfusionPixelShader: {
  60277. name: string;
  60278. shader: string;
  60279. };
  60280. }
  60281. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  60282. import { Nullable } from "babylonjs/types";
  60283. import { Engine } from "babylonjs/Engines/engine";
  60284. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60285. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60286. import { Camera } from "babylonjs/Cameras/camera";
  60287. import "babylonjs/Shaders/circleOfConfusion.fragment";
  60288. /**
  60289. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60290. */
  60291. export class CircleOfConfusionPostProcess extends PostProcess {
  60292. /**
  60293. * 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.
  60294. */
  60295. lensSize: number;
  60296. /**
  60297. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60298. */
  60299. fStop: number;
  60300. /**
  60301. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60302. */
  60303. focusDistance: number;
  60304. /**
  60305. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60306. */
  60307. focalLength: number;
  60308. private _depthTexture;
  60309. /**
  60310. * Creates a new instance CircleOfConfusionPostProcess
  60311. * @param name The name of the effect.
  60312. * @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.
  60313. * @param options The required width/height ratio to downsize to before computing the render pass.
  60314. * @param camera The camera to apply the render pass to.
  60315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60316. * @param engine The engine which the post process will be applied. (default: current engine)
  60317. * @param reusable If the post process can be reused on the same frame. (default: false)
  60318. * @param textureType Type of textures used when performing the post process. (default: 0)
  60319. * @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)
  60320. */
  60321. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60322. /**
  60323. * 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.
  60324. */
  60325. depthTexture: RenderTargetTexture;
  60326. }
  60327. }
  60328. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  60329. /** @hidden */
  60330. export var colorCorrectionPixelShader: {
  60331. name: string;
  60332. shader: string;
  60333. };
  60334. }
  60335. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  60336. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60337. import { Engine } from "babylonjs/Engines/engine";
  60338. import { Camera } from "babylonjs/Cameras/camera";
  60339. import "babylonjs/Shaders/colorCorrection.fragment";
  60340. /**
  60341. *
  60342. * This post-process allows the modification of rendered colors by using
  60343. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60344. *
  60345. * The object needs to be provided an url to a texture containing the color
  60346. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60347. * Use an image editing software to tweak the LUT to match your needs.
  60348. *
  60349. * For an example of a color LUT, see here:
  60350. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60351. * For explanations on color grading, see here:
  60352. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60353. *
  60354. */
  60355. export class ColorCorrectionPostProcess extends PostProcess {
  60356. private _colorTableTexture;
  60357. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60358. }
  60359. }
  60360. declare module "babylonjs/Shaders/convolution.fragment" {
  60361. /** @hidden */
  60362. export var convolutionPixelShader: {
  60363. name: string;
  60364. shader: string;
  60365. };
  60366. }
  60367. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  60368. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60369. import { Nullable } from "babylonjs/types";
  60370. import { Camera } from "babylonjs/Cameras/camera";
  60371. import { Engine } from "babylonjs/Engines/engine";
  60372. import "babylonjs/Shaders/convolution.fragment";
  60373. /**
  60374. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60375. * input texture to perform effects such as edge detection or sharpening
  60376. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60377. */
  60378. export class ConvolutionPostProcess extends PostProcess {
  60379. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60380. kernel: number[];
  60381. /**
  60382. * Creates a new instance ConvolutionPostProcess
  60383. * @param name The name of the effect.
  60384. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60385. * @param options The required width/height ratio to downsize to before computing the render pass.
  60386. * @param camera The camera to apply the render pass to.
  60387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60388. * @param engine The engine which the post process will be applied. (default: current engine)
  60389. * @param reusable If the post process can be reused on the same frame. (default: false)
  60390. * @param textureType Type of textures used when performing the post process. (default: 0)
  60391. */
  60392. constructor(name: string,
  60393. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60394. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60395. /**
  60396. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60397. */
  60398. static EdgeDetect0Kernel: number[];
  60399. /**
  60400. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60401. */
  60402. static EdgeDetect1Kernel: number[];
  60403. /**
  60404. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60405. */
  60406. static EdgeDetect2Kernel: number[];
  60407. /**
  60408. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60409. */
  60410. static SharpenKernel: number[];
  60411. /**
  60412. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60413. */
  60414. static EmbossKernel: number[];
  60415. /**
  60416. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60417. */
  60418. static GaussianKernel: number[];
  60419. }
  60420. }
  60421. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  60422. import { Nullable } from "babylonjs/types";
  60423. import { Vector2 } from "babylonjs/Maths/math.vector";
  60424. import { Camera } from "babylonjs/Cameras/camera";
  60425. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60426. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60427. import { Engine } from "babylonjs/Engines/engine";
  60428. import { Scene } from "babylonjs/scene";
  60429. /**
  60430. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60431. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60432. * based on samples that have a large difference in distance than the center pixel.
  60433. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60434. */
  60435. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60436. direction: Vector2;
  60437. /**
  60438. * Creates a new instance CircleOfConfusionPostProcess
  60439. * @param name The name of the effect.
  60440. * @param scene The scene the effect belongs to.
  60441. * @param direction The direction the blur should be applied.
  60442. * @param kernel The size of the kernel used to blur.
  60443. * @param options The required width/height ratio to downsize to before computing the render pass.
  60444. * @param camera The camera to apply the render pass to.
  60445. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60446. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60448. * @param engine The engine which the post process will be applied. (default: current engine)
  60449. * @param reusable If the post process can be reused on the same frame. (default: false)
  60450. * @param textureType Type of textures used when performing the post process. (default: 0)
  60451. * @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)
  60452. */
  60453. 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);
  60454. }
  60455. }
  60456. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  60457. /** @hidden */
  60458. export var depthOfFieldMergePixelShader: {
  60459. name: string;
  60460. shader: string;
  60461. };
  60462. }
  60463. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  60464. import { Nullable } from "babylonjs/types";
  60465. import { Camera } from "babylonjs/Cameras/camera";
  60466. import { Effect } from "babylonjs/Materials/effect";
  60467. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60468. import { Engine } from "babylonjs/Engines/engine";
  60469. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  60470. /**
  60471. * Options to be set when merging outputs from the default pipeline.
  60472. */
  60473. export class DepthOfFieldMergePostProcessOptions {
  60474. /**
  60475. * The original image to merge on top of
  60476. */
  60477. originalFromInput: PostProcess;
  60478. /**
  60479. * Parameters to perform the merge of the depth of field effect
  60480. */
  60481. depthOfField?: {
  60482. circleOfConfusion: PostProcess;
  60483. blurSteps: Array<PostProcess>;
  60484. };
  60485. /**
  60486. * Parameters to perform the merge of bloom effect
  60487. */
  60488. bloom?: {
  60489. blurred: PostProcess;
  60490. weight: number;
  60491. };
  60492. }
  60493. /**
  60494. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60495. */
  60496. export class DepthOfFieldMergePostProcess extends PostProcess {
  60497. private blurSteps;
  60498. /**
  60499. * Creates a new instance of DepthOfFieldMergePostProcess
  60500. * @param name The name of the effect.
  60501. * @param originalFromInput Post process which's input will be used for the merge.
  60502. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60503. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60504. * @param options The required width/height ratio to downsize to before computing the render pass.
  60505. * @param camera The camera to apply the render pass to.
  60506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60507. * @param engine The engine which the post process will be applied. (default: current engine)
  60508. * @param reusable If the post process can be reused on the same frame. (default: false)
  60509. * @param textureType Type of textures used when performing the post process. (default: 0)
  60510. * @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)
  60511. */
  60512. 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);
  60513. /**
  60514. * Updates the effect with the current post process compile time values and recompiles the shader.
  60515. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60516. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60517. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60518. * @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
  60519. * @param onCompiled Called when the shader has been compiled.
  60520. * @param onError Called if there is an error when compiling a shader.
  60521. */
  60522. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60523. }
  60524. }
  60525. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  60526. import { Nullable } from "babylonjs/types";
  60527. import { Camera } from "babylonjs/Cameras/camera";
  60528. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60529. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60530. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60531. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60532. import { Scene } from "babylonjs/scene";
  60533. /**
  60534. * Specifies the level of max blur that should be applied when using the depth of field effect
  60535. */
  60536. export enum DepthOfFieldEffectBlurLevel {
  60537. /**
  60538. * Subtle blur
  60539. */
  60540. Low = 0,
  60541. /**
  60542. * Medium blur
  60543. */
  60544. Medium = 1,
  60545. /**
  60546. * Large blur
  60547. */
  60548. High = 2
  60549. }
  60550. /**
  60551. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60552. */
  60553. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60554. private _circleOfConfusion;
  60555. /**
  60556. * @hidden Internal, blurs from high to low
  60557. */
  60558. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60559. private _depthOfFieldBlurY;
  60560. private _dofMerge;
  60561. /**
  60562. * @hidden Internal post processes in depth of field effect
  60563. */
  60564. _effects: Array<PostProcess>;
  60565. /**
  60566. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60567. */
  60568. focalLength: number;
  60569. /**
  60570. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60571. */
  60572. fStop: number;
  60573. /**
  60574. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60575. */
  60576. focusDistance: number;
  60577. /**
  60578. * 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.
  60579. */
  60580. lensSize: number;
  60581. /**
  60582. * Creates a new instance DepthOfFieldEffect
  60583. * @param scene The scene the effect belongs to.
  60584. * @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.
  60585. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60586. * @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)
  60587. */
  60588. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60589. /**
  60590. * Get the current class name of the current effet
  60591. * @returns "DepthOfFieldEffect"
  60592. */
  60593. getClassName(): string;
  60594. /**
  60595. * 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.
  60596. */
  60597. depthTexture: RenderTargetTexture;
  60598. /**
  60599. * Disposes each of the internal effects for a given camera.
  60600. * @param camera The camera to dispose the effect on.
  60601. */
  60602. disposeEffects(camera: Camera): void;
  60603. /**
  60604. * @hidden Internal
  60605. */
  60606. _updateEffects(): void;
  60607. /**
  60608. * Internal
  60609. * @returns if all the contained post processes are ready.
  60610. * @hidden
  60611. */
  60612. _isReady(): boolean;
  60613. }
  60614. }
  60615. declare module "babylonjs/Shaders/displayPass.fragment" {
  60616. /** @hidden */
  60617. export var displayPassPixelShader: {
  60618. name: string;
  60619. shader: string;
  60620. };
  60621. }
  60622. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  60623. import { Nullable } from "babylonjs/types";
  60624. import { Camera } from "babylonjs/Cameras/camera";
  60625. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60626. import { Engine } from "babylonjs/Engines/engine";
  60627. import "babylonjs/Shaders/displayPass.fragment";
  60628. /**
  60629. * DisplayPassPostProcess which produces an output the same as it's input
  60630. */
  60631. export class DisplayPassPostProcess extends PostProcess {
  60632. /**
  60633. * Creates the DisplayPassPostProcess
  60634. * @param name The name of the effect.
  60635. * @param options The required width/height ratio to downsize to before computing the render pass.
  60636. * @param camera The camera to apply the render pass to.
  60637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60638. * @param engine The engine which the post process will be applied. (default: current engine)
  60639. * @param reusable If the post process can be reused on the same frame. (default: false)
  60640. */
  60641. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60642. }
  60643. }
  60644. declare module "babylonjs/Shaders/filter.fragment" {
  60645. /** @hidden */
  60646. export var filterPixelShader: {
  60647. name: string;
  60648. shader: string;
  60649. };
  60650. }
  60651. declare module "babylonjs/PostProcesses/filterPostProcess" {
  60652. import { Nullable } from "babylonjs/types";
  60653. import { Matrix } from "babylonjs/Maths/math.vector";
  60654. import { Camera } from "babylonjs/Cameras/camera";
  60655. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60656. import { Engine } from "babylonjs/Engines/engine";
  60657. import "babylonjs/Shaders/filter.fragment";
  60658. /**
  60659. * Applies a kernel filter to the image
  60660. */
  60661. export class FilterPostProcess extends PostProcess {
  60662. /** The matrix to be applied to the image */
  60663. kernelMatrix: Matrix;
  60664. /**
  60665. *
  60666. * @param name The name of the effect.
  60667. * @param kernelMatrix The matrix to be applied to the image
  60668. * @param options The required width/height ratio to downsize to before computing the render pass.
  60669. * @param camera The camera to apply the render pass to.
  60670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60671. * @param engine The engine which the post process will be applied. (default: current engine)
  60672. * @param reusable If the post process can be reused on the same frame. (default: false)
  60673. */
  60674. constructor(name: string,
  60675. /** The matrix to be applied to the image */
  60676. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60677. }
  60678. }
  60679. declare module "babylonjs/Shaders/fxaa.fragment" {
  60680. /** @hidden */
  60681. export var fxaaPixelShader: {
  60682. name: string;
  60683. shader: string;
  60684. };
  60685. }
  60686. declare module "babylonjs/Shaders/fxaa.vertex" {
  60687. /** @hidden */
  60688. export var fxaaVertexShader: {
  60689. name: string;
  60690. shader: string;
  60691. };
  60692. }
  60693. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60694. import { Nullable } from "babylonjs/types";
  60695. import { Camera } from "babylonjs/Cameras/camera";
  60696. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60697. import { Engine } from "babylonjs/Engines/engine";
  60698. import "babylonjs/Shaders/fxaa.fragment";
  60699. import "babylonjs/Shaders/fxaa.vertex";
  60700. /**
  60701. * Fxaa post process
  60702. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60703. */
  60704. export class FxaaPostProcess extends PostProcess {
  60705. /** @hidden */
  60706. texelWidth: number;
  60707. /** @hidden */
  60708. texelHeight: number;
  60709. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60710. private _getDefines;
  60711. }
  60712. }
  60713. declare module "babylonjs/Shaders/grain.fragment" {
  60714. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60715. /** @hidden */
  60716. export var grainPixelShader: {
  60717. name: string;
  60718. shader: string;
  60719. };
  60720. }
  60721. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60722. import { Nullable } from "babylonjs/types";
  60723. import { Camera } from "babylonjs/Cameras/camera";
  60724. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60725. import { Engine } from "babylonjs/Engines/engine";
  60726. import "babylonjs/Shaders/grain.fragment";
  60727. /**
  60728. * The GrainPostProcess adds noise to the image at mid luminance levels
  60729. */
  60730. export class GrainPostProcess extends PostProcess {
  60731. /**
  60732. * The intensity of the grain added (default: 30)
  60733. */
  60734. intensity: number;
  60735. /**
  60736. * If the grain should be randomized on every frame
  60737. */
  60738. animated: boolean;
  60739. /**
  60740. * Creates a new instance of @see GrainPostProcess
  60741. * @param name The name of the effect.
  60742. * @param options The required width/height ratio to downsize to before computing the render pass.
  60743. * @param camera The camera to apply the render pass to.
  60744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60745. * @param engine The engine which the post process will be applied. (default: current engine)
  60746. * @param reusable If the post process can be reused on the same frame. (default: false)
  60747. * @param textureType Type of textures used when performing the post process. (default: 0)
  60748. * @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)
  60749. */
  60750. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60751. }
  60752. }
  60753. declare module "babylonjs/Shaders/highlights.fragment" {
  60754. /** @hidden */
  60755. export var highlightsPixelShader: {
  60756. name: string;
  60757. shader: string;
  60758. };
  60759. }
  60760. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60761. import { Nullable } from "babylonjs/types";
  60762. import { Camera } from "babylonjs/Cameras/camera";
  60763. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60764. import { Engine } from "babylonjs/Engines/engine";
  60765. import "babylonjs/Shaders/highlights.fragment";
  60766. /**
  60767. * Extracts highlights from the image
  60768. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60769. */
  60770. export class HighlightsPostProcess extends PostProcess {
  60771. /**
  60772. * Extracts highlights from the image
  60773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60774. * @param name The name of the effect.
  60775. * @param options The required width/height ratio to downsize to before computing the render pass.
  60776. * @param camera The camera to apply the render pass to.
  60777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60778. * @param engine The engine which the post process will be applied. (default: current engine)
  60779. * @param reusable If the post process can be reused on the same frame. (default: false)
  60780. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60781. */
  60782. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60783. }
  60784. }
  60785. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60786. /** @hidden */
  60787. export var mrtFragmentDeclaration: {
  60788. name: string;
  60789. shader: string;
  60790. };
  60791. }
  60792. declare module "babylonjs/Shaders/geometry.fragment" {
  60793. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60794. /** @hidden */
  60795. export var geometryPixelShader: {
  60796. name: string;
  60797. shader: string;
  60798. };
  60799. }
  60800. declare module "babylonjs/Shaders/geometry.vertex" {
  60801. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60802. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60803. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60804. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60805. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60806. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60807. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60808. /** @hidden */
  60809. export var geometryVertexShader: {
  60810. name: string;
  60811. shader: string;
  60812. };
  60813. }
  60814. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60815. import { Matrix } from "babylonjs/Maths/math.vector";
  60816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60817. import { Mesh } from "babylonjs/Meshes/mesh";
  60818. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60819. import { Effect } from "babylonjs/Materials/effect";
  60820. import { Scene } from "babylonjs/scene";
  60821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60822. import "babylonjs/Shaders/geometry.fragment";
  60823. import "babylonjs/Shaders/geometry.vertex";
  60824. /** @hidden */
  60825. interface ISavedTransformationMatrix {
  60826. world: Matrix;
  60827. viewProjection: Matrix;
  60828. }
  60829. /**
  60830. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60831. */
  60832. export class GeometryBufferRenderer {
  60833. /**
  60834. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60835. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60836. */
  60837. static readonly POSITION_TEXTURE_TYPE: number;
  60838. /**
  60839. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60840. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60841. */
  60842. static readonly VELOCITY_TEXTURE_TYPE: number;
  60843. /**
  60844. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60845. * in order to compute objects velocities when enableVelocity is set to "true"
  60846. * @hidden
  60847. */
  60848. _previousTransformationMatrices: {
  60849. [index: number]: ISavedTransformationMatrix;
  60850. };
  60851. /**
  60852. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60853. * in order to compute objects velocities when enableVelocity is set to "true"
  60854. * @hidden
  60855. */
  60856. _previousBonesTransformationMatrices: {
  60857. [index: number]: Float32Array;
  60858. };
  60859. /**
  60860. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60861. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60862. */
  60863. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60864. private _scene;
  60865. private _multiRenderTarget;
  60866. private _ratio;
  60867. private _enablePosition;
  60868. private _enableVelocity;
  60869. private _positionIndex;
  60870. private _velocityIndex;
  60871. protected _effect: Effect;
  60872. protected _cachedDefines: string;
  60873. /**
  60874. * Set the render list (meshes to be rendered) used in the G buffer.
  60875. */
  60876. renderList: Mesh[];
  60877. /**
  60878. * Gets wether or not G buffer are supported by the running hardware.
  60879. * This requires draw buffer supports
  60880. */
  60881. readonly isSupported: boolean;
  60882. /**
  60883. * Returns the index of the given texture type in the G-Buffer textures array
  60884. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60885. * @returns the index of the given texture type in the G-Buffer textures array
  60886. */
  60887. getTextureIndex(textureType: number): number;
  60888. /**
  60889. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60890. */
  60891. /**
  60892. * Sets whether or not objects positions are enabled for the G buffer.
  60893. */
  60894. enablePosition: boolean;
  60895. /**
  60896. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60897. */
  60898. /**
  60899. * Sets wether or not objects velocities are enabled for the G buffer.
  60900. */
  60901. enableVelocity: boolean;
  60902. /**
  60903. * Gets the scene associated with the buffer.
  60904. */
  60905. readonly scene: Scene;
  60906. /**
  60907. * Gets the ratio used by the buffer during its creation.
  60908. * How big is the buffer related to the main canvas.
  60909. */
  60910. readonly ratio: number;
  60911. /** @hidden */
  60912. static _SceneComponentInitialization: (scene: Scene) => void;
  60913. /**
  60914. * Creates a new G Buffer for the scene
  60915. * @param scene The scene the buffer belongs to
  60916. * @param ratio How big is the buffer related to the main canvas.
  60917. */
  60918. constructor(scene: Scene, ratio?: number);
  60919. /**
  60920. * Checks wether everything is ready to render a submesh to the G buffer.
  60921. * @param subMesh the submesh to check readiness for
  60922. * @param useInstances is the mesh drawn using instance or not
  60923. * @returns true if ready otherwise false
  60924. */
  60925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60926. /**
  60927. * Gets the current underlying G Buffer.
  60928. * @returns the buffer
  60929. */
  60930. getGBuffer(): MultiRenderTarget;
  60931. /**
  60932. * Gets the number of samples used to render the buffer (anti aliasing).
  60933. */
  60934. /**
  60935. * Sets the number of samples used to render the buffer (anti aliasing).
  60936. */
  60937. samples: number;
  60938. /**
  60939. * Disposes the renderer and frees up associated resources.
  60940. */
  60941. dispose(): void;
  60942. protected _createRenderTargets(): void;
  60943. private _copyBonesTransformationMatrices;
  60944. }
  60945. }
  60946. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60947. import { Nullable } from "babylonjs/types";
  60948. import { Scene } from "babylonjs/scene";
  60949. import { ISceneComponent } from "babylonjs/sceneComponent";
  60950. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60951. module "babylonjs/scene" {
  60952. interface Scene {
  60953. /** @hidden (Backing field) */
  60954. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60955. /**
  60956. * Gets or Sets the current geometry buffer associated to the scene.
  60957. */
  60958. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60959. /**
  60960. * Enables a GeometryBufferRender and associates it with the scene
  60961. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60962. * @returns the GeometryBufferRenderer
  60963. */
  60964. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60965. /**
  60966. * Disables the GeometryBufferRender associated with the scene
  60967. */
  60968. disableGeometryBufferRenderer(): void;
  60969. }
  60970. }
  60971. /**
  60972. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60973. * in several rendering techniques.
  60974. */
  60975. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60976. /**
  60977. * The component name helpful to identify the component in the list of scene components.
  60978. */
  60979. readonly name: string;
  60980. /**
  60981. * The scene the component belongs to.
  60982. */
  60983. scene: Scene;
  60984. /**
  60985. * Creates a new instance of the component for the given scene
  60986. * @param scene Defines the scene to register the component in
  60987. */
  60988. constructor(scene: Scene);
  60989. /**
  60990. * Registers the component in a given scene
  60991. */
  60992. register(): void;
  60993. /**
  60994. * Rebuilds the elements related to this component in case of
  60995. * context lost for instance.
  60996. */
  60997. rebuild(): void;
  60998. /**
  60999. * Disposes the component and the associated ressources
  61000. */
  61001. dispose(): void;
  61002. private _gatherRenderTargets;
  61003. }
  61004. }
  61005. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61006. /** @hidden */
  61007. export var motionBlurPixelShader: {
  61008. name: string;
  61009. shader: string;
  61010. };
  61011. }
  61012. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61013. import { Nullable } from "babylonjs/types";
  61014. import { Camera } from "babylonjs/Cameras/camera";
  61015. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61016. import { Scene } from "babylonjs/scene";
  61017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61018. import "babylonjs/Animations/animatable";
  61019. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61020. import "babylonjs/Shaders/motionBlur.fragment";
  61021. import { Engine } from "babylonjs/Engines/engine";
  61022. /**
  61023. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61024. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61025. * As an example, all you have to do is to create the post-process:
  61026. * var mb = new BABYLON.MotionBlurPostProcess(
  61027. * 'mb', // The name of the effect.
  61028. * scene, // The scene containing the objects to blur according to their velocity.
  61029. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61030. * camera // The camera to apply the render pass to.
  61031. * );
  61032. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61033. */
  61034. export class MotionBlurPostProcess extends PostProcess {
  61035. /**
  61036. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61037. */
  61038. motionStrength: number;
  61039. /**
  61040. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61041. */
  61042. /**
  61043. * Sets the number of iterations to be used for motion blur quality
  61044. */
  61045. motionBlurSamples: number;
  61046. private _motionBlurSamples;
  61047. private _geometryBufferRenderer;
  61048. /**
  61049. * Creates a new instance MotionBlurPostProcess
  61050. * @param name The name of the effect.
  61051. * @param scene The scene containing the objects to blur according to their velocity.
  61052. * @param options The required width/height ratio to downsize to before computing the render pass.
  61053. * @param camera The camera to apply the render pass to.
  61054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61055. * @param engine The engine which the post process will be applied. (default: current engine)
  61056. * @param reusable If the post process can be reused on the same frame. (default: false)
  61057. * @param textureType Type of textures used when performing the post process. (default: 0)
  61058. * @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)
  61059. */
  61060. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61061. /**
  61062. * Excludes the given skinned mesh from computing bones velocities.
  61063. * 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.
  61064. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61065. */
  61066. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61067. /**
  61068. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61069. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61070. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61071. */
  61072. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61073. /**
  61074. * Disposes the post process.
  61075. * @param camera The camera to dispose the post process on.
  61076. */
  61077. dispose(camera?: Camera): void;
  61078. }
  61079. }
  61080. declare module "babylonjs/Shaders/refraction.fragment" {
  61081. /** @hidden */
  61082. export var refractionPixelShader: {
  61083. name: string;
  61084. shader: string;
  61085. };
  61086. }
  61087. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61088. import { Color3 } from "babylonjs/Maths/math.color";
  61089. import { Camera } from "babylonjs/Cameras/camera";
  61090. import { Texture } from "babylonjs/Materials/Textures/texture";
  61091. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61092. import { Engine } from "babylonjs/Engines/engine";
  61093. import "babylonjs/Shaders/refraction.fragment";
  61094. /**
  61095. * Post process which applies a refractin texture
  61096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61097. */
  61098. export class RefractionPostProcess extends PostProcess {
  61099. /** the base color of the refraction (used to taint the rendering) */
  61100. color: Color3;
  61101. /** simulated refraction depth */
  61102. depth: number;
  61103. /** the coefficient of the base color (0 to remove base color tainting) */
  61104. colorLevel: number;
  61105. private _refTexture;
  61106. private _ownRefractionTexture;
  61107. /**
  61108. * Gets or sets the refraction texture
  61109. * Please note that you are responsible for disposing the texture if you set it manually
  61110. */
  61111. refractionTexture: Texture;
  61112. /**
  61113. * Initializes the RefractionPostProcess
  61114. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61115. * @param name The name of the effect.
  61116. * @param refractionTextureUrl Url of the refraction texture to use
  61117. * @param color the base color of the refraction (used to taint the rendering)
  61118. * @param depth simulated refraction depth
  61119. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61120. * @param camera The camera to apply the render pass to.
  61121. * @param options The required width/height ratio to downsize to before computing the render pass.
  61122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61123. * @param engine The engine which the post process will be applied. (default: current engine)
  61124. * @param reusable If the post process can be reused on the same frame. (default: false)
  61125. */
  61126. constructor(name: string, refractionTextureUrl: string,
  61127. /** the base color of the refraction (used to taint the rendering) */
  61128. color: Color3,
  61129. /** simulated refraction depth */
  61130. depth: number,
  61131. /** the coefficient of the base color (0 to remove base color tainting) */
  61132. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61133. /**
  61134. * Disposes of the post process
  61135. * @param camera Camera to dispose post process on
  61136. */
  61137. dispose(camera: Camera): void;
  61138. }
  61139. }
  61140. declare module "babylonjs/Shaders/sharpen.fragment" {
  61141. /** @hidden */
  61142. export var sharpenPixelShader: {
  61143. name: string;
  61144. shader: string;
  61145. };
  61146. }
  61147. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  61148. import { Nullable } from "babylonjs/types";
  61149. import { Camera } from "babylonjs/Cameras/camera";
  61150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61151. import "babylonjs/Shaders/sharpen.fragment";
  61152. import { Engine } from "babylonjs/Engines/engine";
  61153. /**
  61154. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61155. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61156. */
  61157. export class SharpenPostProcess extends PostProcess {
  61158. /**
  61159. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61160. */
  61161. colorAmount: number;
  61162. /**
  61163. * How much sharpness should be applied (default: 0.3)
  61164. */
  61165. edgeAmount: number;
  61166. /**
  61167. * Creates a new instance ConvolutionPostProcess
  61168. * @param name The name of the effect.
  61169. * @param options The required width/height ratio to downsize to before computing the render pass.
  61170. * @param camera The camera to apply the render pass to.
  61171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61172. * @param engine The engine which the post process will be applied. (default: current engine)
  61173. * @param reusable If the post process can be reused on the same frame. (default: false)
  61174. * @param textureType Type of textures used when performing the post process. (default: 0)
  61175. * @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)
  61176. */
  61177. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61178. }
  61179. }
  61180. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  61181. import { Nullable } from "babylonjs/types";
  61182. import { Camera } from "babylonjs/Cameras/camera";
  61183. import { Engine } from "babylonjs/Engines/engine";
  61184. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61185. import { IInspectable } from "babylonjs/Misc/iInspectable";
  61186. /**
  61187. * PostProcessRenderPipeline
  61188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61189. */
  61190. export class PostProcessRenderPipeline {
  61191. private engine;
  61192. private _renderEffects;
  61193. private _renderEffectsForIsolatedPass;
  61194. /**
  61195. * List of inspectable custom properties (used by the Inspector)
  61196. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61197. */
  61198. inspectableCustomProperties: IInspectable[];
  61199. /**
  61200. * @hidden
  61201. */
  61202. protected _cameras: Camera[];
  61203. /** @hidden */
  61204. _name: string;
  61205. /**
  61206. * Gets pipeline name
  61207. */
  61208. readonly name: string;
  61209. /**
  61210. * Initializes a PostProcessRenderPipeline
  61211. * @param engine engine to add the pipeline to
  61212. * @param name name of the pipeline
  61213. */
  61214. constructor(engine: Engine, name: string);
  61215. /**
  61216. * Gets the class name
  61217. * @returns "PostProcessRenderPipeline"
  61218. */
  61219. getClassName(): string;
  61220. /**
  61221. * If all the render effects in the pipeline are supported
  61222. */
  61223. readonly isSupported: boolean;
  61224. /**
  61225. * Adds an effect to the pipeline
  61226. * @param renderEffect the effect to add
  61227. */
  61228. addEffect(renderEffect: PostProcessRenderEffect): void;
  61229. /** @hidden */
  61230. _rebuild(): void;
  61231. /** @hidden */
  61232. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61233. /** @hidden */
  61234. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61235. /** @hidden */
  61236. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61237. /** @hidden */
  61238. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61239. /** @hidden */
  61240. _attachCameras(cameras: Camera, unique: boolean): void;
  61241. /** @hidden */
  61242. _attachCameras(cameras: Camera[], unique: boolean): void;
  61243. /** @hidden */
  61244. _detachCameras(cameras: Camera): void;
  61245. /** @hidden */
  61246. _detachCameras(cameras: Nullable<Camera[]>): void;
  61247. /** @hidden */
  61248. _update(): void;
  61249. /** @hidden */
  61250. _reset(): void;
  61251. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61252. /**
  61253. * Disposes of the pipeline
  61254. */
  61255. dispose(): void;
  61256. }
  61257. }
  61258. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  61259. import { Camera } from "babylonjs/Cameras/camera";
  61260. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61261. /**
  61262. * PostProcessRenderPipelineManager class
  61263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61264. */
  61265. export class PostProcessRenderPipelineManager {
  61266. private _renderPipelines;
  61267. /**
  61268. * Initializes a PostProcessRenderPipelineManager
  61269. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61270. */
  61271. constructor();
  61272. /**
  61273. * Gets the list of supported render pipelines
  61274. */
  61275. readonly supportedPipelines: PostProcessRenderPipeline[];
  61276. /**
  61277. * Adds a pipeline to the manager
  61278. * @param renderPipeline The pipeline to add
  61279. */
  61280. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61281. /**
  61282. * Attaches a camera to the pipeline
  61283. * @param renderPipelineName The name of the pipeline to attach to
  61284. * @param cameras the camera to attach
  61285. * @param unique if the camera can be attached multiple times to the pipeline
  61286. */
  61287. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61288. /**
  61289. * Detaches a camera from the pipeline
  61290. * @param renderPipelineName The name of the pipeline to detach from
  61291. * @param cameras the camera to detach
  61292. */
  61293. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61294. /**
  61295. * Enables an effect by name on a pipeline
  61296. * @param renderPipelineName the name of the pipeline to enable the effect in
  61297. * @param renderEffectName the name of the effect to enable
  61298. * @param cameras the cameras that the effect should be enabled on
  61299. */
  61300. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61301. /**
  61302. * Disables an effect by name on a pipeline
  61303. * @param renderPipelineName the name of the pipeline to disable the effect in
  61304. * @param renderEffectName the name of the effect to disable
  61305. * @param cameras the cameras that the effect should be disabled on
  61306. */
  61307. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61308. /**
  61309. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61310. */
  61311. update(): void;
  61312. /** @hidden */
  61313. _rebuild(): void;
  61314. /**
  61315. * Disposes of the manager and pipelines
  61316. */
  61317. dispose(): void;
  61318. }
  61319. }
  61320. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  61321. import { ISceneComponent } from "babylonjs/sceneComponent";
  61322. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61323. import { Scene } from "babylonjs/scene";
  61324. module "babylonjs/scene" {
  61325. interface Scene {
  61326. /** @hidden (Backing field) */
  61327. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61328. /**
  61329. * Gets the postprocess render pipeline manager
  61330. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61331. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61332. */
  61333. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61334. }
  61335. }
  61336. /**
  61337. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61338. */
  61339. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61340. /**
  61341. * The component name helpfull to identify the component in the list of scene components.
  61342. */
  61343. readonly name: string;
  61344. /**
  61345. * The scene the component belongs to.
  61346. */
  61347. scene: Scene;
  61348. /**
  61349. * Creates a new instance of the component for the given scene
  61350. * @param scene Defines the scene to register the component in
  61351. */
  61352. constructor(scene: Scene);
  61353. /**
  61354. * Registers the component in a given scene
  61355. */
  61356. register(): void;
  61357. /**
  61358. * Rebuilds the elements related to this component in case of
  61359. * context lost for instance.
  61360. */
  61361. rebuild(): void;
  61362. /**
  61363. * Disposes the component and the associated ressources
  61364. */
  61365. dispose(): void;
  61366. private _gatherRenderTargets;
  61367. }
  61368. }
  61369. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  61370. import { Nullable } from "babylonjs/types";
  61371. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61372. import { Camera } from "babylonjs/Cameras/camera";
  61373. import { IDisposable } from "babylonjs/scene";
  61374. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  61375. import { Scene } from "babylonjs/scene";
  61376. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  61377. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61378. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61379. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  61380. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61381. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61382. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  61383. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61384. import { Animation } from "babylonjs/Animations/animation";
  61385. /**
  61386. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61387. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61388. */
  61389. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61390. private _scene;
  61391. private _camerasToBeAttached;
  61392. /**
  61393. * ID of the sharpen post process,
  61394. */
  61395. private readonly SharpenPostProcessId;
  61396. /**
  61397. * @ignore
  61398. * ID of the image processing post process;
  61399. */
  61400. readonly ImageProcessingPostProcessId: string;
  61401. /**
  61402. * @ignore
  61403. * ID of the Fast Approximate Anti-Aliasing post process;
  61404. */
  61405. readonly FxaaPostProcessId: string;
  61406. /**
  61407. * ID of the chromatic aberration post process,
  61408. */
  61409. private readonly ChromaticAberrationPostProcessId;
  61410. /**
  61411. * ID of the grain post process
  61412. */
  61413. private readonly GrainPostProcessId;
  61414. /**
  61415. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61416. */
  61417. sharpen: SharpenPostProcess;
  61418. private _sharpenEffect;
  61419. private bloom;
  61420. /**
  61421. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61422. */
  61423. depthOfField: DepthOfFieldEffect;
  61424. /**
  61425. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61426. */
  61427. fxaa: FxaaPostProcess;
  61428. /**
  61429. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61430. */
  61431. imageProcessing: ImageProcessingPostProcess;
  61432. /**
  61433. * Chromatic aberration post process which will shift rgb colors in the image
  61434. */
  61435. chromaticAberration: ChromaticAberrationPostProcess;
  61436. private _chromaticAberrationEffect;
  61437. /**
  61438. * Grain post process which add noise to the image
  61439. */
  61440. grain: GrainPostProcess;
  61441. private _grainEffect;
  61442. /**
  61443. * Glow post process which adds a glow to emissive areas of the image
  61444. */
  61445. private _glowLayer;
  61446. /**
  61447. * Animations which can be used to tweak settings over a period of time
  61448. */
  61449. animations: Animation[];
  61450. private _imageProcessingConfigurationObserver;
  61451. private _sharpenEnabled;
  61452. private _bloomEnabled;
  61453. private _depthOfFieldEnabled;
  61454. private _depthOfFieldBlurLevel;
  61455. private _fxaaEnabled;
  61456. private _imageProcessingEnabled;
  61457. private _defaultPipelineTextureType;
  61458. private _bloomScale;
  61459. private _chromaticAberrationEnabled;
  61460. private _grainEnabled;
  61461. private _buildAllowed;
  61462. /**
  61463. * Gets active scene
  61464. */
  61465. readonly scene: Scene;
  61466. /**
  61467. * Enable or disable the sharpen process from the pipeline
  61468. */
  61469. sharpenEnabled: boolean;
  61470. private _resizeObserver;
  61471. private _hardwareScaleLevel;
  61472. private _bloomKernel;
  61473. /**
  61474. * Specifies the size of the bloom blur kernel, relative to the final output size
  61475. */
  61476. bloomKernel: number;
  61477. /**
  61478. * Specifies the weight of the bloom in the final rendering
  61479. */
  61480. private _bloomWeight;
  61481. /**
  61482. * Specifies the luma threshold for the area that will be blurred by the bloom
  61483. */
  61484. private _bloomThreshold;
  61485. private _hdr;
  61486. /**
  61487. * The strength of the bloom.
  61488. */
  61489. bloomWeight: number;
  61490. /**
  61491. * The strength of the bloom.
  61492. */
  61493. bloomThreshold: number;
  61494. /**
  61495. * The scale of the bloom, lower value will provide better performance.
  61496. */
  61497. bloomScale: number;
  61498. /**
  61499. * Enable or disable the bloom from the pipeline
  61500. */
  61501. bloomEnabled: boolean;
  61502. private _rebuildBloom;
  61503. /**
  61504. * If the depth of field is enabled.
  61505. */
  61506. depthOfFieldEnabled: boolean;
  61507. /**
  61508. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61509. */
  61510. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61511. /**
  61512. * If the anti aliasing is enabled.
  61513. */
  61514. fxaaEnabled: boolean;
  61515. private _samples;
  61516. /**
  61517. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61518. */
  61519. samples: number;
  61520. /**
  61521. * If image processing is enabled.
  61522. */
  61523. imageProcessingEnabled: boolean;
  61524. /**
  61525. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61526. */
  61527. glowLayerEnabled: boolean;
  61528. /**
  61529. * Gets the glow layer (or null if not defined)
  61530. */
  61531. readonly glowLayer: Nullable<GlowLayer>;
  61532. /**
  61533. * Enable or disable the chromaticAberration process from the pipeline
  61534. */
  61535. chromaticAberrationEnabled: boolean;
  61536. /**
  61537. * Enable or disable the grain process from the pipeline
  61538. */
  61539. grainEnabled: boolean;
  61540. /**
  61541. * @constructor
  61542. * @param name - The rendering pipeline name (default: "")
  61543. * @param hdr - If high dynamic range textures should be used (default: true)
  61544. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61545. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61546. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61547. */
  61548. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61549. /**
  61550. * Get the class name
  61551. * @returns "DefaultRenderingPipeline"
  61552. */
  61553. getClassName(): string;
  61554. /**
  61555. * Force the compilation of the entire pipeline.
  61556. */
  61557. prepare(): void;
  61558. private _hasCleared;
  61559. private _prevPostProcess;
  61560. private _prevPrevPostProcess;
  61561. private _setAutoClearAndTextureSharing;
  61562. private _depthOfFieldSceneObserver;
  61563. private _buildPipeline;
  61564. private _disposePostProcesses;
  61565. /**
  61566. * Adds a camera to the pipeline
  61567. * @param camera the camera to be added
  61568. */
  61569. addCamera(camera: Camera): void;
  61570. /**
  61571. * Removes a camera from the pipeline
  61572. * @param camera the camera to remove
  61573. */
  61574. removeCamera(camera: Camera): void;
  61575. /**
  61576. * Dispose of the pipeline and stop all post processes
  61577. */
  61578. dispose(): void;
  61579. /**
  61580. * Serialize the rendering pipeline (Used when exporting)
  61581. * @returns the serialized object
  61582. */
  61583. serialize(): any;
  61584. /**
  61585. * Parse the serialized pipeline
  61586. * @param source Source pipeline.
  61587. * @param scene The scene to load the pipeline to.
  61588. * @param rootUrl The URL of the serialized pipeline.
  61589. * @returns An instantiated pipeline from the serialized object.
  61590. */
  61591. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61592. }
  61593. }
  61594. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  61595. /** @hidden */
  61596. export var lensHighlightsPixelShader: {
  61597. name: string;
  61598. shader: string;
  61599. };
  61600. }
  61601. declare module "babylonjs/Shaders/depthOfField.fragment" {
  61602. /** @hidden */
  61603. export var depthOfFieldPixelShader: {
  61604. name: string;
  61605. shader: string;
  61606. };
  61607. }
  61608. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  61609. import { Camera } from "babylonjs/Cameras/camera";
  61610. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61611. import { Scene } from "babylonjs/scene";
  61612. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61613. import "babylonjs/Shaders/chromaticAberration.fragment";
  61614. import "babylonjs/Shaders/lensHighlights.fragment";
  61615. import "babylonjs/Shaders/depthOfField.fragment";
  61616. /**
  61617. * BABYLON.JS Chromatic Aberration GLSL Shader
  61618. * Author: Olivier Guyot
  61619. * Separates very slightly R, G and B colors on the edges of the screen
  61620. * Inspired by Francois Tarlier & Martins Upitis
  61621. */
  61622. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61623. /**
  61624. * @ignore
  61625. * The chromatic aberration PostProcess id in the pipeline
  61626. */
  61627. LensChromaticAberrationEffect: string;
  61628. /**
  61629. * @ignore
  61630. * The highlights enhancing PostProcess id in the pipeline
  61631. */
  61632. HighlightsEnhancingEffect: string;
  61633. /**
  61634. * @ignore
  61635. * The depth-of-field PostProcess id in the pipeline
  61636. */
  61637. LensDepthOfFieldEffect: string;
  61638. private _scene;
  61639. private _depthTexture;
  61640. private _grainTexture;
  61641. private _chromaticAberrationPostProcess;
  61642. private _highlightsPostProcess;
  61643. private _depthOfFieldPostProcess;
  61644. private _edgeBlur;
  61645. private _grainAmount;
  61646. private _chromaticAberration;
  61647. private _distortion;
  61648. private _highlightsGain;
  61649. private _highlightsThreshold;
  61650. private _dofDistance;
  61651. private _dofAperture;
  61652. private _dofDarken;
  61653. private _dofPentagon;
  61654. private _blurNoise;
  61655. /**
  61656. * @constructor
  61657. *
  61658. * Effect parameters are as follow:
  61659. * {
  61660. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61661. * edge_blur: number; // from 0 to x (1 for realism)
  61662. * distortion: number; // from 0 to x (1 for realism)
  61663. * grain_amount: number; // from 0 to 1
  61664. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61665. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61666. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61667. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61668. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61669. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61670. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61671. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61672. * }
  61673. * Note: if an effect parameter is unset, effect is disabled
  61674. *
  61675. * @param name The rendering pipeline name
  61676. * @param parameters - An object containing all parameters (see above)
  61677. * @param scene The scene linked to this pipeline
  61678. * @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)
  61679. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61680. */
  61681. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61682. /**
  61683. * Get the class name
  61684. * @returns "LensRenderingPipeline"
  61685. */
  61686. getClassName(): string;
  61687. /**
  61688. * Gets associated scene
  61689. */
  61690. readonly scene: Scene;
  61691. /**
  61692. * Gets or sets the edge blur
  61693. */
  61694. edgeBlur: number;
  61695. /**
  61696. * Gets or sets the grain amount
  61697. */
  61698. grainAmount: number;
  61699. /**
  61700. * Gets or sets the chromatic aberration amount
  61701. */
  61702. chromaticAberration: number;
  61703. /**
  61704. * Gets or sets the depth of field aperture
  61705. */
  61706. dofAperture: number;
  61707. /**
  61708. * Gets or sets the edge distortion
  61709. */
  61710. edgeDistortion: number;
  61711. /**
  61712. * Gets or sets the depth of field distortion
  61713. */
  61714. dofDistortion: number;
  61715. /**
  61716. * Gets or sets the darken out of focus amount
  61717. */
  61718. darkenOutOfFocus: number;
  61719. /**
  61720. * Gets or sets a boolean indicating if blur noise is enabled
  61721. */
  61722. blurNoise: boolean;
  61723. /**
  61724. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61725. */
  61726. pentagonBokeh: boolean;
  61727. /**
  61728. * Gets or sets the highlight grain amount
  61729. */
  61730. highlightsGain: number;
  61731. /**
  61732. * Gets or sets the highlight threshold
  61733. */
  61734. highlightsThreshold: number;
  61735. /**
  61736. * Sets the amount of blur at the edges
  61737. * @param amount blur amount
  61738. */
  61739. setEdgeBlur(amount: number): void;
  61740. /**
  61741. * Sets edge blur to 0
  61742. */
  61743. disableEdgeBlur(): void;
  61744. /**
  61745. * Sets the amout of grain
  61746. * @param amount Amount of grain
  61747. */
  61748. setGrainAmount(amount: number): void;
  61749. /**
  61750. * Set grain amount to 0
  61751. */
  61752. disableGrain(): void;
  61753. /**
  61754. * Sets the chromatic aberration amount
  61755. * @param amount amount of chromatic aberration
  61756. */
  61757. setChromaticAberration(amount: number): void;
  61758. /**
  61759. * Sets chromatic aberration amount to 0
  61760. */
  61761. disableChromaticAberration(): void;
  61762. /**
  61763. * Sets the EdgeDistortion amount
  61764. * @param amount amount of EdgeDistortion
  61765. */
  61766. setEdgeDistortion(amount: number): void;
  61767. /**
  61768. * Sets edge distortion to 0
  61769. */
  61770. disableEdgeDistortion(): void;
  61771. /**
  61772. * Sets the FocusDistance amount
  61773. * @param amount amount of FocusDistance
  61774. */
  61775. setFocusDistance(amount: number): void;
  61776. /**
  61777. * Disables depth of field
  61778. */
  61779. disableDepthOfField(): void;
  61780. /**
  61781. * Sets the Aperture amount
  61782. * @param amount amount of Aperture
  61783. */
  61784. setAperture(amount: number): void;
  61785. /**
  61786. * Sets the DarkenOutOfFocus amount
  61787. * @param amount amount of DarkenOutOfFocus
  61788. */
  61789. setDarkenOutOfFocus(amount: number): void;
  61790. private _pentagonBokehIsEnabled;
  61791. /**
  61792. * Creates a pentagon bokeh effect
  61793. */
  61794. enablePentagonBokeh(): void;
  61795. /**
  61796. * Disables the pentagon bokeh effect
  61797. */
  61798. disablePentagonBokeh(): void;
  61799. /**
  61800. * Enables noise blur
  61801. */
  61802. enableNoiseBlur(): void;
  61803. /**
  61804. * Disables noise blur
  61805. */
  61806. disableNoiseBlur(): void;
  61807. /**
  61808. * Sets the HighlightsGain amount
  61809. * @param amount amount of HighlightsGain
  61810. */
  61811. setHighlightsGain(amount: number): void;
  61812. /**
  61813. * Sets the HighlightsThreshold amount
  61814. * @param amount amount of HighlightsThreshold
  61815. */
  61816. setHighlightsThreshold(amount: number): void;
  61817. /**
  61818. * Disables highlights
  61819. */
  61820. disableHighlights(): void;
  61821. /**
  61822. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61823. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61824. */
  61825. dispose(disableDepthRender?: boolean): void;
  61826. private _createChromaticAberrationPostProcess;
  61827. private _createHighlightsPostProcess;
  61828. private _createDepthOfFieldPostProcess;
  61829. private _createGrainTexture;
  61830. }
  61831. }
  61832. declare module "babylonjs/Shaders/ssao2.fragment" {
  61833. /** @hidden */
  61834. export var ssao2PixelShader: {
  61835. name: string;
  61836. shader: string;
  61837. };
  61838. }
  61839. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61840. /** @hidden */
  61841. export var ssaoCombinePixelShader: {
  61842. name: string;
  61843. shader: string;
  61844. };
  61845. }
  61846. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61847. import { Camera } from "babylonjs/Cameras/camera";
  61848. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61849. import { Scene } from "babylonjs/scene";
  61850. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61851. import "babylonjs/Shaders/ssao2.fragment";
  61852. import "babylonjs/Shaders/ssaoCombine.fragment";
  61853. /**
  61854. * Render pipeline to produce ssao effect
  61855. */
  61856. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61857. /**
  61858. * @ignore
  61859. * The PassPostProcess id in the pipeline that contains the original scene color
  61860. */
  61861. SSAOOriginalSceneColorEffect: string;
  61862. /**
  61863. * @ignore
  61864. * The SSAO PostProcess id in the pipeline
  61865. */
  61866. SSAORenderEffect: string;
  61867. /**
  61868. * @ignore
  61869. * The horizontal blur PostProcess id in the pipeline
  61870. */
  61871. SSAOBlurHRenderEffect: string;
  61872. /**
  61873. * @ignore
  61874. * The vertical blur PostProcess id in the pipeline
  61875. */
  61876. SSAOBlurVRenderEffect: string;
  61877. /**
  61878. * @ignore
  61879. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61880. */
  61881. SSAOCombineRenderEffect: string;
  61882. /**
  61883. * The output strength of the SSAO post-process. Default value is 1.0.
  61884. */
  61885. totalStrength: number;
  61886. /**
  61887. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61888. */
  61889. maxZ: number;
  61890. /**
  61891. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61892. */
  61893. minZAspect: number;
  61894. private _samples;
  61895. /**
  61896. * Number of samples used for the SSAO calculations. Default value is 8
  61897. */
  61898. samples: number;
  61899. private _textureSamples;
  61900. /**
  61901. * Number of samples to use for antialiasing
  61902. */
  61903. textureSamples: number;
  61904. /**
  61905. * Ratio object used for SSAO ratio and blur ratio
  61906. */
  61907. private _ratio;
  61908. /**
  61909. * Dynamically generated sphere sampler.
  61910. */
  61911. private _sampleSphere;
  61912. /**
  61913. * Blur filter offsets
  61914. */
  61915. private _samplerOffsets;
  61916. private _expensiveBlur;
  61917. /**
  61918. * If bilateral blur should be used
  61919. */
  61920. expensiveBlur: boolean;
  61921. /**
  61922. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61923. */
  61924. radius: number;
  61925. /**
  61926. * The base color of the SSAO post-process
  61927. * The final result is "base + ssao" between [0, 1]
  61928. */
  61929. base: number;
  61930. /**
  61931. * Support test.
  61932. */
  61933. static readonly IsSupported: boolean;
  61934. private _scene;
  61935. private _depthTexture;
  61936. private _normalTexture;
  61937. private _randomTexture;
  61938. private _originalColorPostProcess;
  61939. private _ssaoPostProcess;
  61940. private _blurHPostProcess;
  61941. private _blurVPostProcess;
  61942. private _ssaoCombinePostProcess;
  61943. private _firstUpdate;
  61944. /**
  61945. * Gets active scene
  61946. */
  61947. readonly scene: Scene;
  61948. /**
  61949. * @constructor
  61950. * @param name The rendering pipeline name
  61951. * @param scene The scene linked to this pipeline
  61952. * @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 }
  61953. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61954. */
  61955. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61956. /**
  61957. * Get the class name
  61958. * @returns "SSAO2RenderingPipeline"
  61959. */
  61960. getClassName(): string;
  61961. /**
  61962. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61963. */
  61964. dispose(disableGeometryBufferRenderer?: boolean): void;
  61965. private _createBlurPostProcess;
  61966. /** @hidden */
  61967. _rebuild(): void;
  61968. private _bits;
  61969. private _radicalInverse_VdC;
  61970. private _hammersley;
  61971. private _hemisphereSample_uniform;
  61972. private _generateHemisphere;
  61973. private _createSSAOPostProcess;
  61974. private _createSSAOCombinePostProcess;
  61975. private _createRandomTexture;
  61976. /**
  61977. * Serialize the rendering pipeline (Used when exporting)
  61978. * @returns the serialized object
  61979. */
  61980. serialize(): any;
  61981. /**
  61982. * Parse the serialized pipeline
  61983. * @param source Source pipeline.
  61984. * @param scene The scene to load the pipeline to.
  61985. * @param rootUrl The URL of the serialized pipeline.
  61986. * @returns An instantiated pipeline from the serialized object.
  61987. */
  61988. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61989. }
  61990. }
  61991. declare module "babylonjs/Shaders/ssao.fragment" {
  61992. /** @hidden */
  61993. export var ssaoPixelShader: {
  61994. name: string;
  61995. shader: string;
  61996. };
  61997. }
  61998. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61999. import { Camera } from "babylonjs/Cameras/camera";
  62000. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62001. import { Scene } from "babylonjs/scene";
  62002. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62003. import "babylonjs/Shaders/ssao.fragment";
  62004. import "babylonjs/Shaders/ssaoCombine.fragment";
  62005. /**
  62006. * Render pipeline to produce ssao effect
  62007. */
  62008. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62009. /**
  62010. * @ignore
  62011. * The PassPostProcess id in the pipeline that contains the original scene color
  62012. */
  62013. SSAOOriginalSceneColorEffect: string;
  62014. /**
  62015. * @ignore
  62016. * The SSAO PostProcess id in the pipeline
  62017. */
  62018. SSAORenderEffect: string;
  62019. /**
  62020. * @ignore
  62021. * The horizontal blur PostProcess id in the pipeline
  62022. */
  62023. SSAOBlurHRenderEffect: string;
  62024. /**
  62025. * @ignore
  62026. * The vertical blur PostProcess id in the pipeline
  62027. */
  62028. SSAOBlurVRenderEffect: string;
  62029. /**
  62030. * @ignore
  62031. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62032. */
  62033. SSAOCombineRenderEffect: string;
  62034. /**
  62035. * The output strength of the SSAO post-process. Default value is 1.0.
  62036. */
  62037. totalStrength: number;
  62038. /**
  62039. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62040. */
  62041. radius: number;
  62042. /**
  62043. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62044. * Must not be equal to fallOff and superior to fallOff.
  62045. * Default value is 0.0075
  62046. */
  62047. area: number;
  62048. /**
  62049. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62050. * Must not be equal to area and inferior to area.
  62051. * Default value is 0.000001
  62052. */
  62053. fallOff: number;
  62054. /**
  62055. * The base color of the SSAO post-process
  62056. * The final result is "base + ssao" between [0, 1]
  62057. */
  62058. base: number;
  62059. private _scene;
  62060. private _depthTexture;
  62061. private _randomTexture;
  62062. private _originalColorPostProcess;
  62063. private _ssaoPostProcess;
  62064. private _blurHPostProcess;
  62065. private _blurVPostProcess;
  62066. private _ssaoCombinePostProcess;
  62067. private _firstUpdate;
  62068. /**
  62069. * Gets active scene
  62070. */
  62071. readonly scene: Scene;
  62072. /**
  62073. * @constructor
  62074. * @param name - The rendering pipeline name
  62075. * @param scene - The scene linked to this pipeline
  62076. * @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 }
  62077. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62078. */
  62079. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62080. /**
  62081. * Get the class name
  62082. * @returns "SSAORenderingPipeline"
  62083. */
  62084. getClassName(): string;
  62085. /**
  62086. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62087. */
  62088. dispose(disableDepthRender?: boolean): void;
  62089. private _createBlurPostProcess;
  62090. /** @hidden */
  62091. _rebuild(): void;
  62092. private _createSSAOPostProcess;
  62093. private _createSSAOCombinePostProcess;
  62094. private _createRandomTexture;
  62095. }
  62096. }
  62097. declare module "babylonjs/Shaders/standard.fragment" {
  62098. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62099. /** @hidden */
  62100. export var standardPixelShader: {
  62101. name: string;
  62102. shader: string;
  62103. };
  62104. }
  62105. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62106. import { Nullable } from "babylonjs/types";
  62107. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62108. import { Camera } from "babylonjs/Cameras/camera";
  62109. import { Texture } from "babylonjs/Materials/Textures/texture";
  62110. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62111. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62112. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62113. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62114. import { IDisposable } from "babylonjs/scene";
  62115. import { SpotLight } from "babylonjs/Lights/spotLight";
  62116. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62117. import { Scene } from "babylonjs/scene";
  62118. import { Animation } from "babylonjs/Animations/animation";
  62119. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62120. import "babylonjs/Shaders/standard.fragment";
  62121. /**
  62122. * Standard rendering pipeline
  62123. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62124. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62125. */
  62126. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62127. /**
  62128. * Public members
  62129. */
  62130. /**
  62131. * Post-process which contains the original scene color before the pipeline applies all the effects
  62132. */
  62133. originalPostProcess: Nullable<PostProcess>;
  62134. /**
  62135. * Post-process used to down scale an image x4
  62136. */
  62137. downSampleX4PostProcess: Nullable<PostProcess>;
  62138. /**
  62139. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62140. */
  62141. brightPassPostProcess: Nullable<PostProcess>;
  62142. /**
  62143. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62144. */
  62145. blurHPostProcesses: PostProcess[];
  62146. /**
  62147. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62148. */
  62149. blurVPostProcesses: PostProcess[];
  62150. /**
  62151. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62152. */
  62153. textureAdderPostProcess: Nullable<PostProcess>;
  62154. /**
  62155. * Post-process used to create volumetric lighting effect
  62156. */
  62157. volumetricLightPostProcess: Nullable<PostProcess>;
  62158. /**
  62159. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62160. */
  62161. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62162. /**
  62163. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62164. */
  62165. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62166. /**
  62167. * Post-process used to merge the volumetric light effect and the real scene color
  62168. */
  62169. volumetricLightMergePostProces: Nullable<PostProcess>;
  62170. /**
  62171. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62172. */
  62173. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62174. /**
  62175. * Base post-process used to calculate the average luminance of the final image for HDR
  62176. */
  62177. luminancePostProcess: Nullable<PostProcess>;
  62178. /**
  62179. * Post-processes used to create down sample post-processes in order to get
  62180. * the average luminance of the final image for HDR
  62181. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62182. */
  62183. luminanceDownSamplePostProcesses: PostProcess[];
  62184. /**
  62185. * Post-process used to create a HDR effect (light adaptation)
  62186. */
  62187. hdrPostProcess: Nullable<PostProcess>;
  62188. /**
  62189. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62190. */
  62191. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62192. /**
  62193. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62194. */
  62195. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62196. /**
  62197. * Post-process used to merge the final HDR post-process and the real scene color
  62198. */
  62199. hdrFinalPostProcess: Nullable<PostProcess>;
  62200. /**
  62201. * Post-process used to create a lens flare effect
  62202. */
  62203. lensFlarePostProcess: Nullable<PostProcess>;
  62204. /**
  62205. * Post-process that merges the result of the lens flare post-process and the real scene color
  62206. */
  62207. lensFlareComposePostProcess: Nullable<PostProcess>;
  62208. /**
  62209. * Post-process used to create a motion blur effect
  62210. */
  62211. motionBlurPostProcess: Nullable<PostProcess>;
  62212. /**
  62213. * Post-process used to create a depth of field effect
  62214. */
  62215. depthOfFieldPostProcess: Nullable<PostProcess>;
  62216. /**
  62217. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62218. */
  62219. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62220. /**
  62221. * Represents the brightness threshold in order to configure the illuminated surfaces
  62222. */
  62223. brightThreshold: number;
  62224. /**
  62225. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62226. */
  62227. blurWidth: number;
  62228. /**
  62229. * Sets if the blur for highlighted surfaces must be only horizontal
  62230. */
  62231. horizontalBlur: boolean;
  62232. /**
  62233. * Gets the overall exposure used by the pipeline
  62234. */
  62235. /**
  62236. * Sets the overall exposure used by the pipeline
  62237. */
  62238. exposure: number;
  62239. /**
  62240. * Texture used typically to simulate "dirty" on camera lens
  62241. */
  62242. lensTexture: Nullable<Texture>;
  62243. /**
  62244. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62245. */
  62246. volumetricLightCoefficient: number;
  62247. /**
  62248. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62249. */
  62250. volumetricLightPower: number;
  62251. /**
  62252. * Used the set the blur intensity to smooth the volumetric lights
  62253. */
  62254. volumetricLightBlurScale: number;
  62255. /**
  62256. * Light (spot or directional) used to generate the volumetric lights rays
  62257. * The source light must have a shadow generate so the pipeline can get its
  62258. * depth map
  62259. */
  62260. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62261. /**
  62262. * For eye adaptation, represents the minimum luminance the eye can see
  62263. */
  62264. hdrMinimumLuminance: number;
  62265. /**
  62266. * For eye adaptation, represents the decrease luminance speed
  62267. */
  62268. hdrDecreaseRate: number;
  62269. /**
  62270. * For eye adaptation, represents the increase luminance speed
  62271. */
  62272. hdrIncreaseRate: number;
  62273. /**
  62274. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62275. */
  62276. /**
  62277. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62278. */
  62279. hdrAutoExposure: boolean;
  62280. /**
  62281. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62282. */
  62283. lensColorTexture: Nullable<Texture>;
  62284. /**
  62285. * The overall strengh for the lens flare effect
  62286. */
  62287. lensFlareStrength: number;
  62288. /**
  62289. * Dispersion coefficient for lens flare ghosts
  62290. */
  62291. lensFlareGhostDispersal: number;
  62292. /**
  62293. * Main lens flare halo width
  62294. */
  62295. lensFlareHaloWidth: number;
  62296. /**
  62297. * Based on the lens distortion effect, defines how much the lens flare result
  62298. * is distorted
  62299. */
  62300. lensFlareDistortionStrength: number;
  62301. /**
  62302. * Configures the blur intensity used for for lens flare (halo)
  62303. */
  62304. lensFlareBlurWidth: number;
  62305. /**
  62306. * Lens star texture must be used to simulate rays on the flares and is available
  62307. * in the documentation
  62308. */
  62309. lensStarTexture: Nullable<Texture>;
  62310. /**
  62311. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62312. * flare effect by taking account of the dirt texture
  62313. */
  62314. lensFlareDirtTexture: Nullable<Texture>;
  62315. /**
  62316. * Represents the focal length for the depth of field effect
  62317. */
  62318. depthOfFieldDistance: number;
  62319. /**
  62320. * Represents the blur intensity for the blurred part of the depth of field effect
  62321. */
  62322. depthOfFieldBlurWidth: number;
  62323. /**
  62324. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62325. */
  62326. /**
  62327. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62328. */
  62329. motionStrength: number;
  62330. /**
  62331. * Gets wether or not the motion blur post-process is object based or screen based.
  62332. */
  62333. /**
  62334. * Sets wether or not the motion blur post-process should be object based or screen based
  62335. */
  62336. objectBasedMotionBlur: boolean;
  62337. /**
  62338. * List of animations for the pipeline (IAnimatable implementation)
  62339. */
  62340. animations: Animation[];
  62341. /**
  62342. * Private members
  62343. */
  62344. private _scene;
  62345. private _currentDepthOfFieldSource;
  62346. private _basePostProcess;
  62347. private _fixedExposure;
  62348. private _currentExposure;
  62349. private _hdrAutoExposure;
  62350. private _hdrCurrentLuminance;
  62351. private _motionStrength;
  62352. private _isObjectBasedMotionBlur;
  62353. private _floatTextureType;
  62354. private _camerasToBeAttached;
  62355. private _ratio;
  62356. private _bloomEnabled;
  62357. private _depthOfFieldEnabled;
  62358. private _vlsEnabled;
  62359. private _lensFlareEnabled;
  62360. private _hdrEnabled;
  62361. private _motionBlurEnabled;
  62362. private _fxaaEnabled;
  62363. private _motionBlurSamples;
  62364. private _volumetricLightStepsCount;
  62365. private _samples;
  62366. /**
  62367. * @ignore
  62368. * Specifies if the bloom pipeline is enabled
  62369. */
  62370. BloomEnabled: boolean;
  62371. /**
  62372. * @ignore
  62373. * Specifies if the depth of field pipeline is enabed
  62374. */
  62375. DepthOfFieldEnabled: boolean;
  62376. /**
  62377. * @ignore
  62378. * Specifies if the lens flare pipeline is enabed
  62379. */
  62380. LensFlareEnabled: boolean;
  62381. /**
  62382. * @ignore
  62383. * Specifies if the HDR pipeline is enabled
  62384. */
  62385. HDREnabled: boolean;
  62386. /**
  62387. * @ignore
  62388. * Specifies if the volumetric lights scattering effect is enabled
  62389. */
  62390. VLSEnabled: boolean;
  62391. /**
  62392. * @ignore
  62393. * Specifies if the motion blur effect is enabled
  62394. */
  62395. MotionBlurEnabled: boolean;
  62396. /**
  62397. * Specifies if anti-aliasing is enabled
  62398. */
  62399. fxaaEnabled: boolean;
  62400. /**
  62401. * Specifies the number of steps used to calculate the volumetric lights
  62402. * Typically in interval [50, 200]
  62403. */
  62404. volumetricLightStepsCount: number;
  62405. /**
  62406. * Specifies the number of samples used for the motion blur effect
  62407. * Typically in interval [16, 64]
  62408. */
  62409. motionBlurSamples: number;
  62410. /**
  62411. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62412. */
  62413. samples: number;
  62414. /**
  62415. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62416. * @constructor
  62417. * @param name The rendering pipeline name
  62418. * @param scene The scene linked to this pipeline
  62419. * @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)
  62420. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62421. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62422. */
  62423. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62424. private _buildPipeline;
  62425. private _createDownSampleX4PostProcess;
  62426. private _createBrightPassPostProcess;
  62427. private _createBlurPostProcesses;
  62428. private _createTextureAdderPostProcess;
  62429. private _createVolumetricLightPostProcess;
  62430. private _createLuminancePostProcesses;
  62431. private _createHdrPostProcess;
  62432. private _createLensFlarePostProcess;
  62433. private _createDepthOfFieldPostProcess;
  62434. private _createMotionBlurPostProcess;
  62435. private _getDepthTexture;
  62436. private _disposePostProcesses;
  62437. /**
  62438. * Dispose of the pipeline and stop all post processes
  62439. */
  62440. dispose(): void;
  62441. /**
  62442. * Serialize the rendering pipeline (Used when exporting)
  62443. * @returns the serialized object
  62444. */
  62445. serialize(): any;
  62446. /**
  62447. * Parse the serialized pipeline
  62448. * @param source Source pipeline.
  62449. * @param scene The scene to load the pipeline to.
  62450. * @param rootUrl The URL of the serialized pipeline.
  62451. * @returns An instantiated pipeline from the serialized object.
  62452. */
  62453. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62454. /**
  62455. * Luminance steps
  62456. */
  62457. static LuminanceSteps: number;
  62458. }
  62459. }
  62460. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  62461. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  62462. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  62463. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  62464. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  62465. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  62466. }
  62467. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  62468. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  62469. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62470. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62471. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62472. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62473. }
  62474. declare module "babylonjs/Shaders/tonemap.fragment" {
  62475. /** @hidden */
  62476. export var tonemapPixelShader: {
  62477. name: string;
  62478. shader: string;
  62479. };
  62480. }
  62481. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  62482. import { Camera } from "babylonjs/Cameras/camera";
  62483. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62484. import "babylonjs/Shaders/tonemap.fragment";
  62485. import { Engine } from "babylonjs/Engines/engine";
  62486. /** Defines operator used for tonemapping */
  62487. export enum TonemappingOperator {
  62488. /** Hable */
  62489. Hable = 0,
  62490. /** Reinhard */
  62491. Reinhard = 1,
  62492. /** HejiDawson */
  62493. HejiDawson = 2,
  62494. /** Photographic */
  62495. Photographic = 3
  62496. }
  62497. /**
  62498. * Defines a post process to apply tone mapping
  62499. */
  62500. export class TonemapPostProcess extends PostProcess {
  62501. private _operator;
  62502. /** Defines the required exposure adjustement */
  62503. exposureAdjustment: number;
  62504. /**
  62505. * Creates a new TonemapPostProcess
  62506. * @param name defines the name of the postprocess
  62507. * @param _operator defines the operator to use
  62508. * @param exposureAdjustment defines the required exposure adjustement
  62509. * @param camera defines the camera to use (can be null)
  62510. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62511. * @param engine defines the hosting engine (can be ignore if camera is set)
  62512. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62513. */
  62514. constructor(name: string, _operator: TonemappingOperator,
  62515. /** Defines the required exposure adjustement */
  62516. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62517. }
  62518. }
  62519. declare module "babylonjs/Shaders/depth.vertex" {
  62520. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62521. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62522. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62523. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62524. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62525. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62526. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62527. /** @hidden */
  62528. export var depthVertexShader: {
  62529. name: string;
  62530. shader: string;
  62531. };
  62532. }
  62533. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  62534. /** @hidden */
  62535. export var volumetricLightScatteringPixelShader: {
  62536. name: string;
  62537. shader: string;
  62538. };
  62539. }
  62540. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  62541. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62544. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62545. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62546. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62547. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62548. /** @hidden */
  62549. export var volumetricLightScatteringPassVertexShader: {
  62550. name: string;
  62551. shader: string;
  62552. };
  62553. }
  62554. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  62555. /** @hidden */
  62556. export var volumetricLightScatteringPassPixelShader: {
  62557. name: string;
  62558. shader: string;
  62559. };
  62560. }
  62561. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  62562. import { Vector3 } from "babylonjs/Maths/math.vector";
  62563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62564. import { Mesh } from "babylonjs/Meshes/mesh";
  62565. import { Camera } from "babylonjs/Cameras/camera";
  62566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62567. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62568. import { Scene } from "babylonjs/scene";
  62569. import "babylonjs/Meshes/Builders/planeBuilder";
  62570. import "babylonjs/Shaders/depth.vertex";
  62571. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  62572. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  62573. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  62574. import { Engine } from "babylonjs/Engines/engine";
  62575. /**
  62576. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62577. */
  62578. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62579. private _volumetricLightScatteringPass;
  62580. private _volumetricLightScatteringRTT;
  62581. private _viewPort;
  62582. private _screenCoordinates;
  62583. private _cachedDefines;
  62584. /**
  62585. * If not undefined, the mesh position is computed from the attached node position
  62586. */
  62587. attachedNode: {
  62588. position: Vector3;
  62589. };
  62590. /**
  62591. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62592. */
  62593. customMeshPosition: Vector3;
  62594. /**
  62595. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62596. */
  62597. useCustomMeshPosition: boolean;
  62598. /**
  62599. * If the post-process should inverse the light scattering direction
  62600. */
  62601. invert: boolean;
  62602. /**
  62603. * The internal mesh used by the post-process
  62604. */
  62605. mesh: Mesh;
  62606. /**
  62607. * @hidden
  62608. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62609. */
  62610. useDiffuseColor: boolean;
  62611. /**
  62612. * Array containing the excluded meshes not rendered in the internal pass
  62613. */
  62614. excludedMeshes: AbstractMesh[];
  62615. /**
  62616. * Controls the overall intensity of the post-process
  62617. */
  62618. exposure: number;
  62619. /**
  62620. * Dissipates each sample's contribution in range [0, 1]
  62621. */
  62622. decay: number;
  62623. /**
  62624. * Controls the overall intensity of each sample
  62625. */
  62626. weight: number;
  62627. /**
  62628. * Controls the density of each sample
  62629. */
  62630. density: number;
  62631. /**
  62632. * @constructor
  62633. * @param name The post-process name
  62634. * @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)
  62635. * @param camera The camera that the post-process will be attached to
  62636. * @param mesh The mesh used to create the light scattering
  62637. * @param samples The post-process quality, default 100
  62638. * @param samplingModeThe post-process filtering mode
  62639. * @param engine The babylon engine
  62640. * @param reusable If the post-process is reusable
  62641. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62642. */
  62643. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62644. /**
  62645. * Returns the string "VolumetricLightScatteringPostProcess"
  62646. * @returns "VolumetricLightScatteringPostProcess"
  62647. */
  62648. getClassName(): string;
  62649. private _isReady;
  62650. /**
  62651. * Sets the new light position for light scattering effect
  62652. * @param position The new custom light position
  62653. */
  62654. setCustomMeshPosition(position: Vector3): void;
  62655. /**
  62656. * Returns the light position for light scattering effect
  62657. * @return Vector3 The custom light position
  62658. */
  62659. getCustomMeshPosition(): Vector3;
  62660. /**
  62661. * Disposes the internal assets and detaches the post-process from the camera
  62662. */
  62663. dispose(camera: Camera): void;
  62664. /**
  62665. * Returns the render target texture used by the post-process
  62666. * @return the render target texture used by the post-process
  62667. */
  62668. getPass(): RenderTargetTexture;
  62669. private _meshExcluded;
  62670. private _createPass;
  62671. private _updateMeshScreenCoordinates;
  62672. /**
  62673. * Creates a default mesh for the Volumeric Light Scattering post-process
  62674. * @param name The mesh name
  62675. * @param scene The scene where to create the mesh
  62676. * @return the default mesh
  62677. */
  62678. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62679. }
  62680. }
  62681. declare module "babylonjs/PostProcesses/index" {
  62682. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  62683. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  62684. export * from "babylonjs/PostProcesses/bloomEffect";
  62685. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62686. export * from "babylonjs/PostProcesses/blurPostProcess";
  62687. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62688. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62689. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62690. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62691. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62692. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62693. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62694. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62695. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62696. export * from "babylonjs/PostProcesses/filterPostProcess";
  62697. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62698. export * from "babylonjs/PostProcesses/grainPostProcess";
  62699. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62700. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62701. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62702. export * from "babylonjs/PostProcesses/passPostProcess";
  62703. export * from "babylonjs/PostProcesses/postProcess";
  62704. export * from "babylonjs/PostProcesses/postProcessManager";
  62705. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62706. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62707. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62708. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62709. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62710. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62711. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62712. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62713. }
  62714. declare module "babylonjs/Probes/index" {
  62715. export * from "babylonjs/Probes/reflectionProbe";
  62716. }
  62717. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62718. import { Scene } from "babylonjs/scene";
  62719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62720. import { SmartArray } from "babylonjs/Misc/smartArray";
  62721. import { ISceneComponent } from "babylonjs/sceneComponent";
  62722. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62723. import "babylonjs/Meshes/Builders/boxBuilder";
  62724. import "babylonjs/Shaders/color.fragment";
  62725. import "babylonjs/Shaders/color.vertex";
  62726. import { Color3 } from "babylonjs/Maths/math.color";
  62727. module "babylonjs/scene" {
  62728. interface Scene {
  62729. /** @hidden (Backing field) */
  62730. _boundingBoxRenderer: BoundingBoxRenderer;
  62731. /** @hidden (Backing field) */
  62732. _forceShowBoundingBoxes: boolean;
  62733. /**
  62734. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62735. */
  62736. forceShowBoundingBoxes: boolean;
  62737. /**
  62738. * Gets the bounding box renderer associated with the scene
  62739. * @returns a BoundingBoxRenderer
  62740. */
  62741. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62742. }
  62743. }
  62744. module "babylonjs/Meshes/abstractMesh" {
  62745. interface AbstractMesh {
  62746. /** @hidden (Backing field) */
  62747. _showBoundingBox: boolean;
  62748. /**
  62749. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62750. */
  62751. showBoundingBox: boolean;
  62752. }
  62753. }
  62754. /**
  62755. * Component responsible of rendering the bounding box of the meshes in a scene.
  62756. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62757. */
  62758. export class BoundingBoxRenderer implements ISceneComponent {
  62759. /**
  62760. * The component name helpfull to identify the component in the list of scene components.
  62761. */
  62762. readonly name: string;
  62763. /**
  62764. * The scene the component belongs to.
  62765. */
  62766. scene: Scene;
  62767. /**
  62768. * Color of the bounding box lines placed in front of an object
  62769. */
  62770. frontColor: Color3;
  62771. /**
  62772. * Color of the bounding box lines placed behind an object
  62773. */
  62774. backColor: Color3;
  62775. /**
  62776. * Defines if the renderer should show the back lines or not
  62777. */
  62778. showBackLines: boolean;
  62779. /**
  62780. * @hidden
  62781. */
  62782. renderList: SmartArray<BoundingBox>;
  62783. private _colorShader;
  62784. private _vertexBuffers;
  62785. private _indexBuffer;
  62786. private _fillIndexBuffer;
  62787. private _fillIndexData;
  62788. /**
  62789. * Instantiates a new bounding box renderer in a scene.
  62790. * @param scene the scene the renderer renders in
  62791. */
  62792. constructor(scene: Scene);
  62793. /**
  62794. * Registers the component in a given scene
  62795. */
  62796. register(): void;
  62797. private _evaluateSubMesh;
  62798. private _activeMesh;
  62799. private _prepareRessources;
  62800. private _createIndexBuffer;
  62801. /**
  62802. * Rebuilds the elements related to this component in case of
  62803. * context lost for instance.
  62804. */
  62805. rebuild(): void;
  62806. /**
  62807. * @hidden
  62808. */
  62809. reset(): void;
  62810. /**
  62811. * Render the bounding boxes of a specific rendering group
  62812. * @param renderingGroupId defines the rendering group to render
  62813. */
  62814. render(renderingGroupId: number): void;
  62815. /**
  62816. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62817. * @param mesh Define the mesh to render the occlusion bounding box for
  62818. */
  62819. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62820. /**
  62821. * Dispose and release the resources attached to this renderer.
  62822. */
  62823. dispose(): void;
  62824. }
  62825. }
  62826. declare module "babylonjs/Shaders/depth.fragment" {
  62827. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62828. /** @hidden */
  62829. export var depthPixelShader: {
  62830. name: string;
  62831. shader: string;
  62832. };
  62833. }
  62834. declare module "babylonjs/Rendering/depthRenderer" {
  62835. import { Nullable } from "babylonjs/types";
  62836. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62837. import { Scene } from "babylonjs/scene";
  62838. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62839. import { Camera } from "babylonjs/Cameras/camera";
  62840. import "babylonjs/Shaders/depth.fragment";
  62841. import "babylonjs/Shaders/depth.vertex";
  62842. /**
  62843. * This represents a depth renderer in Babylon.
  62844. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62845. */
  62846. export class DepthRenderer {
  62847. private _scene;
  62848. private _depthMap;
  62849. private _effect;
  62850. private readonly _storeNonLinearDepth;
  62851. private readonly _clearColor;
  62852. /** Get if the depth renderer is using packed depth or not */
  62853. readonly isPacked: boolean;
  62854. private _cachedDefines;
  62855. private _camera;
  62856. /**
  62857. * Specifiess that the depth renderer will only be used within
  62858. * the camera it is created for.
  62859. * This can help forcing its rendering during the camera processing.
  62860. */
  62861. useOnlyInActiveCamera: boolean;
  62862. /** @hidden */
  62863. static _SceneComponentInitialization: (scene: Scene) => void;
  62864. /**
  62865. * Instantiates a depth renderer
  62866. * @param scene The scene the renderer belongs to
  62867. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62868. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62869. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62870. */
  62871. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62872. /**
  62873. * Creates the depth rendering effect and checks if the effect is ready.
  62874. * @param subMesh The submesh to be used to render the depth map of
  62875. * @param useInstances If multiple world instances should be used
  62876. * @returns if the depth renderer is ready to render the depth map
  62877. */
  62878. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62879. /**
  62880. * Gets the texture which the depth map will be written to.
  62881. * @returns The depth map texture
  62882. */
  62883. getDepthMap(): RenderTargetTexture;
  62884. /**
  62885. * Disposes of the depth renderer.
  62886. */
  62887. dispose(): void;
  62888. }
  62889. }
  62890. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  62891. import { Nullable } from "babylonjs/types";
  62892. import { Scene } from "babylonjs/scene";
  62893. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62894. import { Camera } from "babylonjs/Cameras/camera";
  62895. import { ISceneComponent } from "babylonjs/sceneComponent";
  62896. module "babylonjs/scene" {
  62897. interface Scene {
  62898. /** @hidden (Backing field) */
  62899. _depthRenderer: {
  62900. [id: string]: DepthRenderer;
  62901. };
  62902. /**
  62903. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62904. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62905. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62906. * @returns the created depth renderer
  62907. */
  62908. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62909. /**
  62910. * Disables a depth renderer for a given camera
  62911. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62912. */
  62913. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62914. }
  62915. }
  62916. /**
  62917. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62918. * in several rendering techniques.
  62919. */
  62920. export class DepthRendererSceneComponent implements ISceneComponent {
  62921. /**
  62922. * The component name helpfull to identify the component in the list of scene components.
  62923. */
  62924. readonly name: string;
  62925. /**
  62926. * The scene the component belongs to.
  62927. */
  62928. scene: Scene;
  62929. /**
  62930. * Creates a new instance of the component for the given scene
  62931. * @param scene Defines the scene to register the component in
  62932. */
  62933. constructor(scene: Scene);
  62934. /**
  62935. * Registers the component in a given scene
  62936. */
  62937. register(): void;
  62938. /**
  62939. * Rebuilds the elements related to this component in case of
  62940. * context lost for instance.
  62941. */
  62942. rebuild(): void;
  62943. /**
  62944. * Disposes the component and the associated ressources
  62945. */
  62946. dispose(): void;
  62947. private _gatherRenderTargets;
  62948. private _gatherActiveCameraRenderTargets;
  62949. }
  62950. }
  62951. declare module "babylonjs/Shaders/outline.fragment" {
  62952. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62953. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  62954. /** @hidden */
  62955. export var outlinePixelShader: {
  62956. name: string;
  62957. shader: string;
  62958. };
  62959. }
  62960. declare module "babylonjs/Shaders/outline.vertex" {
  62961. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62962. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62963. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62964. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62965. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62966. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62967. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62968. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62969. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62970. /** @hidden */
  62971. export var outlineVertexShader: {
  62972. name: string;
  62973. shader: string;
  62974. };
  62975. }
  62976. declare module "babylonjs/Rendering/outlineRenderer" {
  62977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62978. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62979. import { Scene } from "babylonjs/scene";
  62980. import { ISceneComponent } from "babylonjs/sceneComponent";
  62981. import "babylonjs/Shaders/outline.fragment";
  62982. import "babylonjs/Shaders/outline.vertex";
  62983. module "babylonjs/scene" {
  62984. interface Scene {
  62985. /** @hidden */
  62986. _outlineRenderer: OutlineRenderer;
  62987. /**
  62988. * Gets the outline renderer associated with the scene
  62989. * @returns a OutlineRenderer
  62990. */
  62991. getOutlineRenderer(): OutlineRenderer;
  62992. }
  62993. }
  62994. module "babylonjs/Meshes/abstractMesh" {
  62995. interface AbstractMesh {
  62996. /** @hidden (Backing field) */
  62997. _renderOutline: boolean;
  62998. /**
  62999. * Gets or sets a boolean indicating if the outline must be rendered as well
  63000. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63001. */
  63002. renderOutline: boolean;
  63003. /** @hidden (Backing field) */
  63004. _renderOverlay: boolean;
  63005. /**
  63006. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63007. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63008. */
  63009. renderOverlay: boolean;
  63010. }
  63011. }
  63012. /**
  63013. * This class is responsible to draw bothe outline/overlay of meshes.
  63014. * It should not be used directly but through the available method on mesh.
  63015. */
  63016. export class OutlineRenderer implements ISceneComponent {
  63017. /**
  63018. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63019. */
  63020. private static _StencilReference;
  63021. /**
  63022. * The name of the component. Each component must have a unique name.
  63023. */
  63024. name: string;
  63025. /**
  63026. * The scene the component belongs to.
  63027. */
  63028. scene: Scene;
  63029. /**
  63030. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63031. */
  63032. zOffset: number;
  63033. private _engine;
  63034. private _effect;
  63035. private _cachedDefines;
  63036. private _savedDepthWrite;
  63037. /**
  63038. * Instantiates a new outline renderer. (There could be only one per scene).
  63039. * @param scene Defines the scene it belongs to
  63040. */
  63041. constructor(scene: Scene);
  63042. /**
  63043. * Register the component to one instance of a scene.
  63044. */
  63045. register(): void;
  63046. /**
  63047. * Rebuilds the elements related to this component in case of
  63048. * context lost for instance.
  63049. */
  63050. rebuild(): void;
  63051. /**
  63052. * Disposes the component and the associated ressources.
  63053. */
  63054. dispose(): void;
  63055. /**
  63056. * Renders the outline in the canvas.
  63057. * @param subMesh Defines the sumesh to render
  63058. * @param batch Defines the batch of meshes in case of instances
  63059. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63060. */
  63061. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63062. /**
  63063. * Returns whether or not the outline renderer is ready for a given submesh.
  63064. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63065. * @param subMesh Defines the submesh to check readyness for
  63066. * @param useInstances Defines wheter wee are trying to render instances or not
  63067. * @returns true if ready otherwise false
  63068. */
  63069. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63070. private _beforeRenderingMesh;
  63071. private _afterRenderingMesh;
  63072. }
  63073. }
  63074. declare module "babylonjs/Rendering/index" {
  63075. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63076. export * from "babylonjs/Rendering/depthRenderer";
  63077. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63078. export * from "babylonjs/Rendering/edgesRenderer";
  63079. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63080. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63081. export * from "babylonjs/Rendering/outlineRenderer";
  63082. export * from "babylonjs/Rendering/renderingGroup";
  63083. export * from "babylonjs/Rendering/renderingManager";
  63084. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63085. }
  63086. declare module "babylonjs/Sprites/spritePackedManager" {
  63087. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63088. import { Scene } from "babylonjs/scene";
  63089. /**
  63090. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63091. * @see http://doc.babylonjs.com/babylon101/sprites
  63092. */
  63093. export class SpritePackedManager extends SpriteManager {
  63094. /** defines the packed manager's name */
  63095. name: string;
  63096. /**
  63097. * Creates a new sprite manager from a packed sprite sheet
  63098. * @param name defines the manager's name
  63099. * @param imgUrl defines the sprite sheet url
  63100. * @param capacity defines the maximum allowed number of sprites
  63101. * @param scene defines the hosting scene
  63102. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63103. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63104. * @param samplingMode defines the smapling mode to use with spritesheet
  63105. * @param fromPacked set to true; do not alter
  63106. */
  63107. constructor(
  63108. /** defines the packed manager's name */
  63109. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63110. }
  63111. }
  63112. declare module "babylonjs/Sprites/index" {
  63113. export * from "babylonjs/Sprites/sprite";
  63114. export * from "babylonjs/Sprites/spriteManager";
  63115. export * from "babylonjs/Sprites/spritePackedManager";
  63116. export * from "babylonjs/Sprites/spriteSceneComponent";
  63117. }
  63118. declare module "babylonjs/Misc/assetsManager" {
  63119. import { Scene } from "babylonjs/scene";
  63120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63121. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63122. import { Skeleton } from "babylonjs/Bones/skeleton";
  63123. import { Observable } from "babylonjs/Misc/observable";
  63124. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63125. import { Texture } from "babylonjs/Materials/Textures/texture";
  63126. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63127. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63128. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63129. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  63130. /**
  63131. * Defines the list of states available for a task inside a AssetsManager
  63132. */
  63133. export enum AssetTaskState {
  63134. /**
  63135. * Initialization
  63136. */
  63137. INIT = 0,
  63138. /**
  63139. * Running
  63140. */
  63141. RUNNING = 1,
  63142. /**
  63143. * Done
  63144. */
  63145. DONE = 2,
  63146. /**
  63147. * Error
  63148. */
  63149. ERROR = 3
  63150. }
  63151. /**
  63152. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63153. */
  63154. export abstract class AbstractAssetTask {
  63155. /**
  63156. * Task name
  63157. */ name: string;
  63158. /**
  63159. * Callback called when the task is successful
  63160. */
  63161. onSuccess: (task: any) => void;
  63162. /**
  63163. * Callback called when the task is not successful
  63164. */
  63165. onError: (task: any, message?: string, exception?: any) => void;
  63166. /**
  63167. * Creates a new AssetsManager
  63168. * @param name defines the name of the task
  63169. */
  63170. constructor(
  63171. /**
  63172. * Task name
  63173. */ name: string);
  63174. private _isCompleted;
  63175. private _taskState;
  63176. private _errorObject;
  63177. /**
  63178. * Get if the task is completed
  63179. */
  63180. readonly isCompleted: boolean;
  63181. /**
  63182. * Gets the current state of the task
  63183. */
  63184. readonly taskState: AssetTaskState;
  63185. /**
  63186. * Gets the current error object (if task is in error)
  63187. */
  63188. readonly errorObject: {
  63189. message?: string;
  63190. exception?: any;
  63191. };
  63192. /**
  63193. * Internal only
  63194. * @hidden
  63195. */
  63196. _setErrorObject(message?: string, exception?: any): void;
  63197. /**
  63198. * Execute the current task
  63199. * @param scene defines the scene where you want your assets to be loaded
  63200. * @param onSuccess is a callback called when the task is successfully executed
  63201. * @param onError is a callback called if an error occurs
  63202. */
  63203. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63204. /**
  63205. * Execute the current task
  63206. * @param scene defines the scene where you want your assets to be loaded
  63207. * @param onSuccess is a callback called when the task is successfully executed
  63208. * @param onError is a callback called if an error occurs
  63209. */
  63210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63211. /**
  63212. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  63213. * This can be used with failed tasks that have the reason for failure fixed.
  63214. */
  63215. reset(): void;
  63216. private onErrorCallback;
  63217. private onDoneCallback;
  63218. }
  63219. /**
  63220. * Define the interface used by progress events raised during assets loading
  63221. */
  63222. export interface IAssetsProgressEvent {
  63223. /**
  63224. * Defines the number of remaining tasks to process
  63225. */
  63226. remainingCount: number;
  63227. /**
  63228. * Defines the total number of tasks
  63229. */
  63230. totalCount: number;
  63231. /**
  63232. * Defines the task that was just processed
  63233. */
  63234. task: AbstractAssetTask;
  63235. }
  63236. /**
  63237. * Class used to share progress information about assets loading
  63238. */
  63239. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63240. /**
  63241. * Defines the number of remaining tasks to process
  63242. */
  63243. remainingCount: number;
  63244. /**
  63245. * Defines the total number of tasks
  63246. */
  63247. totalCount: number;
  63248. /**
  63249. * Defines the task that was just processed
  63250. */
  63251. task: AbstractAssetTask;
  63252. /**
  63253. * Creates a AssetsProgressEvent
  63254. * @param remainingCount defines the number of remaining tasks to process
  63255. * @param totalCount defines the total number of tasks
  63256. * @param task defines the task that was just processed
  63257. */
  63258. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63259. }
  63260. /**
  63261. * Define a task used by AssetsManager to load meshes
  63262. */
  63263. export class MeshAssetTask extends AbstractAssetTask {
  63264. /**
  63265. * Defines the name of the task
  63266. */
  63267. name: string;
  63268. /**
  63269. * Defines the list of mesh's names you want to load
  63270. */
  63271. meshesNames: any;
  63272. /**
  63273. * Defines the root url to use as a base to load your meshes and associated resources
  63274. */
  63275. rootUrl: string;
  63276. /**
  63277. * Defines the filename of the scene to load from
  63278. */
  63279. sceneFilename: string;
  63280. /**
  63281. * Gets the list of loaded meshes
  63282. */
  63283. loadedMeshes: Array<AbstractMesh>;
  63284. /**
  63285. * Gets the list of loaded particle systems
  63286. */
  63287. loadedParticleSystems: Array<IParticleSystem>;
  63288. /**
  63289. * Gets the list of loaded skeletons
  63290. */
  63291. loadedSkeletons: Array<Skeleton>;
  63292. /**
  63293. * Gets the list of loaded animation groups
  63294. */
  63295. loadedAnimationGroups: Array<AnimationGroup>;
  63296. /**
  63297. * Callback called when the task is successful
  63298. */
  63299. onSuccess: (task: MeshAssetTask) => void;
  63300. /**
  63301. * Callback called when the task is successful
  63302. */
  63303. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63304. /**
  63305. * Creates a new MeshAssetTask
  63306. * @param name defines the name of the task
  63307. * @param meshesNames defines the list of mesh's names you want to load
  63308. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63309. * @param sceneFilename defines the filename of the scene to load from
  63310. */
  63311. constructor(
  63312. /**
  63313. * Defines the name of the task
  63314. */
  63315. name: string,
  63316. /**
  63317. * Defines the list of mesh's names you want to load
  63318. */
  63319. meshesNames: any,
  63320. /**
  63321. * Defines the root url to use as a base to load your meshes and associated resources
  63322. */
  63323. rootUrl: string,
  63324. /**
  63325. * Defines the filename of the scene to load from
  63326. */
  63327. sceneFilename: string);
  63328. /**
  63329. * Execute the current task
  63330. * @param scene defines the scene where you want your assets to be loaded
  63331. * @param onSuccess is a callback called when the task is successfully executed
  63332. * @param onError is a callback called if an error occurs
  63333. */
  63334. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63335. }
  63336. /**
  63337. * Define a task used by AssetsManager to load text content
  63338. */
  63339. export class TextFileAssetTask extends AbstractAssetTask {
  63340. /**
  63341. * Defines the name of the task
  63342. */
  63343. name: string;
  63344. /**
  63345. * Defines the location of the file to load
  63346. */
  63347. url: string;
  63348. /**
  63349. * Gets the loaded text string
  63350. */
  63351. text: string;
  63352. /**
  63353. * Callback called when the task is successful
  63354. */
  63355. onSuccess: (task: TextFileAssetTask) => void;
  63356. /**
  63357. * Callback called when the task is successful
  63358. */
  63359. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63360. /**
  63361. * Creates a new TextFileAssetTask object
  63362. * @param name defines the name of the task
  63363. * @param url defines the location of the file to load
  63364. */
  63365. constructor(
  63366. /**
  63367. * Defines the name of the task
  63368. */
  63369. name: string,
  63370. /**
  63371. * Defines the location of the file to load
  63372. */
  63373. url: string);
  63374. /**
  63375. * Execute the current task
  63376. * @param scene defines the scene where you want your assets to be loaded
  63377. * @param onSuccess is a callback called when the task is successfully executed
  63378. * @param onError is a callback called if an error occurs
  63379. */
  63380. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63381. }
  63382. /**
  63383. * Define a task used by AssetsManager to load binary data
  63384. */
  63385. export class BinaryFileAssetTask extends AbstractAssetTask {
  63386. /**
  63387. * Defines the name of the task
  63388. */
  63389. name: string;
  63390. /**
  63391. * Defines the location of the file to load
  63392. */
  63393. url: string;
  63394. /**
  63395. * Gets the lodaded data (as an array buffer)
  63396. */
  63397. data: ArrayBuffer;
  63398. /**
  63399. * Callback called when the task is successful
  63400. */
  63401. onSuccess: (task: BinaryFileAssetTask) => void;
  63402. /**
  63403. * Callback called when the task is successful
  63404. */
  63405. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63406. /**
  63407. * Creates a new BinaryFileAssetTask object
  63408. * @param name defines the name of the new task
  63409. * @param url defines the location of the file to load
  63410. */
  63411. constructor(
  63412. /**
  63413. * Defines the name of the task
  63414. */
  63415. name: string,
  63416. /**
  63417. * Defines the location of the file to load
  63418. */
  63419. url: string);
  63420. /**
  63421. * Execute the current task
  63422. * @param scene defines the scene where you want your assets to be loaded
  63423. * @param onSuccess is a callback called when the task is successfully executed
  63424. * @param onError is a callback called if an error occurs
  63425. */
  63426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63427. }
  63428. /**
  63429. * Define a task used by AssetsManager to load images
  63430. */
  63431. export class ImageAssetTask extends AbstractAssetTask {
  63432. /**
  63433. * Defines the name of the task
  63434. */
  63435. name: string;
  63436. /**
  63437. * Defines the location of the image to load
  63438. */
  63439. url: string;
  63440. /**
  63441. * Gets the loaded images
  63442. */
  63443. image: HTMLImageElement;
  63444. /**
  63445. * Callback called when the task is successful
  63446. */
  63447. onSuccess: (task: ImageAssetTask) => void;
  63448. /**
  63449. * Callback called when the task is successful
  63450. */
  63451. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63452. /**
  63453. * Creates a new ImageAssetTask
  63454. * @param name defines the name of the task
  63455. * @param url defines the location of the image to load
  63456. */
  63457. constructor(
  63458. /**
  63459. * Defines the name of the task
  63460. */
  63461. name: string,
  63462. /**
  63463. * Defines the location of the image to load
  63464. */
  63465. url: string);
  63466. /**
  63467. * Execute the current task
  63468. * @param scene defines the scene where you want your assets to be loaded
  63469. * @param onSuccess is a callback called when the task is successfully executed
  63470. * @param onError is a callback called if an error occurs
  63471. */
  63472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63473. }
  63474. /**
  63475. * Defines the interface used by texture loading tasks
  63476. */
  63477. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63478. /**
  63479. * Gets the loaded texture
  63480. */
  63481. texture: TEX;
  63482. }
  63483. /**
  63484. * Define a task used by AssetsManager to load 2D textures
  63485. */
  63486. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63487. /**
  63488. * Defines the name of the task
  63489. */
  63490. name: string;
  63491. /**
  63492. * Defines the location of the file to load
  63493. */
  63494. url: string;
  63495. /**
  63496. * Defines if mipmap should not be generated (default is false)
  63497. */
  63498. noMipmap?: boolean | undefined;
  63499. /**
  63500. * Defines if texture must be inverted on Y axis (default is false)
  63501. */
  63502. invertY?: boolean | undefined;
  63503. /**
  63504. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63505. */
  63506. samplingMode: number;
  63507. /**
  63508. * Gets the loaded texture
  63509. */
  63510. texture: Texture;
  63511. /**
  63512. * Callback called when the task is successful
  63513. */
  63514. onSuccess: (task: TextureAssetTask) => void;
  63515. /**
  63516. * Callback called when the task is successful
  63517. */
  63518. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63519. /**
  63520. * Creates a new TextureAssetTask object
  63521. * @param name defines the name of the task
  63522. * @param url defines the location of the file to load
  63523. * @param noMipmap defines if mipmap should not be generated (default is false)
  63524. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63525. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63526. */
  63527. constructor(
  63528. /**
  63529. * Defines the name of the task
  63530. */
  63531. name: string,
  63532. /**
  63533. * Defines the location of the file to load
  63534. */
  63535. url: string,
  63536. /**
  63537. * Defines if mipmap should not be generated (default is false)
  63538. */
  63539. noMipmap?: boolean | undefined,
  63540. /**
  63541. * Defines if texture must be inverted on Y axis (default is false)
  63542. */
  63543. invertY?: boolean | undefined,
  63544. /**
  63545. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63546. */
  63547. samplingMode?: number);
  63548. /**
  63549. * Execute the current task
  63550. * @param scene defines the scene where you want your assets to be loaded
  63551. * @param onSuccess is a callback called when the task is successfully executed
  63552. * @param onError is a callback called if an error occurs
  63553. */
  63554. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63555. }
  63556. /**
  63557. * Define a task used by AssetsManager to load cube textures
  63558. */
  63559. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63560. /**
  63561. * Defines the name of the task
  63562. */
  63563. name: string;
  63564. /**
  63565. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63566. */
  63567. url: string;
  63568. /**
  63569. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63570. */
  63571. extensions?: string[] | undefined;
  63572. /**
  63573. * Defines if mipmaps should not be generated (default is false)
  63574. */
  63575. noMipmap?: boolean | undefined;
  63576. /**
  63577. * Defines the explicit list of files (undefined by default)
  63578. */
  63579. files?: string[] | undefined;
  63580. /**
  63581. * Gets the loaded texture
  63582. */
  63583. texture: CubeTexture;
  63584. /**
  63585. * Callback called when the task is successful
  63586. */
  63587. onSuccess: (task: CubeTextureAssetTask) => void;
  63588. /**
  63589. * Callback called when the task is successful
  63590. */
  63591. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63592. /**
  63593. * Creates a new CubeTextureAssetTask
  63594. * @param name defines the name of the task
  63595. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63596. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63597. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63598. * @param files defines the explicit list of files (undefined by default)
  63599. */
  63600. constructor(
  63601. /**
  63602. * Defines the name of the task
  63603. */
  63604. name: string,
  63605. /**
  63606. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63607. */
  63608. url: string,
  63609. /**
  63610. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63611. */
  63612. extensions?: string[] | undefined,
  63613. /**
  63614. * Defines if mipmaps should not be generated (default is false)
  63615. */
  63616. noMipmap?: boolean | undefined,
  63617. /**
  63618. * Defines the explicit list of files (undefined by default)
  63619. */
  63620. files?: string[] | undefined);
  63621. /**
  63622. * Execute the current task
  63623. * @param scene defines the scene where you want your assets to be loaded
  63624. * @param onSuccess is a callback called when the task is successfully executed
  63625. * @param onError is a callback called if an error occurs
  63626. */
  63627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63628. }
  63629. /**
  63630. * Define a task used by AssetsManager to load HDR cube textures
  63631. */
  63632. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63633. /**
  63634. * Defines the name of the task
  63635. */
  63636. name: string;
  63637. /**
  63638. * Defines the location of the file to load
  63639. */
  63640. url: string;
  63641. /**
  63642. * Defines the desired size (the more it increases the longer the generation will be)
  63643. */
  63644. size: number;
  63645. /**
  63646. * Defines if mipmaps should not be generated (default is false)
  63647. */
  63648. noMipmap: boolean;
  63649. /**
  63650. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63651. */
  63652. generateHarmonics: boolean;
  63653. /**
  63654. * 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)
  63655. */
  63656. gammaSpace: boolean;
  63657. /**
  63658. * Internal Use Only
  63659. */
  63660. reserved: boolean;
  63661. /**
  63662. * Gets the loaded texture
  63663. */
  63664. texture: HDRCubeTexture;
  63665. /**
  63666. * Callback called when the task is successful
  63667. */
  63668. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63669. /**
  63670. * Callback called when the task is successful
  63671. */
  63672. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63673. /**
  63674. * Creates a new HDRCubeTextureAssetTask object
  63675. * @param name defines the name of the task
  63676. * @param url defines the location of the file to load
  63677. * @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.
  63678. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63679. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63680. * @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)
  63681. * @param reserved Internal use only
  63682. */
  63683. constructor(
  63684. /**
  63685. * Defines the name of the task
  63686. */
  63687. name: string,
  63688. /**
  63689. * Defines the location of the file to load
  63690. */
  63691. url: string,
  63692. /**
  63693. * Defines the desired size (the more it increases the longer the generation will be)
  63694. */
  63695. size: number,
  63696. /**
  63697. * Defines if mipmaps should not be generated (default is false)
  63698. */
  63699. noMipmap?: boolean,
  63700. /**
  63701. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63702. */
  63703. generateHarmonics?: boolean,
  63704. /**
  63705. * 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)
  63706. */
  63707. gammaSpace?: boolean,
  63708. /**
  63709. * Internal Use Only
  63710. */
  63711. reserved?: boolean);
  63712. /**
  63713. * Execute the current task
  63714. * @param scene defines the scene where you want your assets to be loaded
  63715. * @param onSuccess is a callback called when the task is successfully executed
  63716. * @param onError is a callback called if an error occurs
  63717. */
  63718. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63719. }
  63720. /**
  63721. * Define a task used by AssetsManager to load Equirectangular cube textures
  63722. */
  63723. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63724. /**
  63725. * Defines the name of the task
  63726. */
  63727. name: string;
  63728. /**
  63729. * Defines the location of the file to load
  63730. */
  63731. url: string;
  63732. /**
  63733. * Defines the desired size (the more it increases the longer the generation will be)
  63734. */
  63735. size: number;
  63736. /**
  63737. * Defines if mipmaps should not be generated (default is false)
  63738. */
  63739. noMipmap: boolean;
  63740. /**
  63741. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63742. * but the standard material would require them in Gamma space) (default is true)
  63743. */
  63744. gammaSpace: boolean;
  63745. /**
  63746. * Gets the loaded texture
  63747. */
  63748. texture: EquiRectangularCubeTexture;
  63749. /**
  63750. * Callback called when the task is successful
  63751. */
  63752. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63753. /**
  63754. * Callback called when the task is successful
  63755. */
  63756. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63757. /**
  63758. * Creates a new EquiRectangularCubeTextureAssetTask object
  63759. * @param name defines the name of the task
  63760. * @param url defines the location of the file to load
  63761. * @param size defines the desired size (the more it increases the longer the generation will be)
  63762. * If the size is omitted this implies you are using a preprocessed cubemap.
  63763. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63764. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63765. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63766. * (default is true)
  63767. */
  63768. constructor(
  63769. /**
  63770. * Defines the name of the task
  63771. */
  63772. name: string,
  63773. /**
  63774. * Defines the location of the file to load
  63775. */
  63776. url: string,
  63777. /**
  63778. * Defines the desired size (the more it increases the longer the generation will be)
  63779. */
  63780. size: number,
  63781. /**
  63782. * Defines if mipmaps should not be generated (default is false)
  63783. */
  63784. noMipmap?: boolean,
  63785. /**
  63786. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63787. * but the standard material would require them in Gamma space) (default is true)
  63788. */
  63789. gammaSpace?: boolean);
  63790. /**
  63791. * Execute the current task
  63792. * @param scene defines the scene where you want your assets to be loaded
  63793. * @param onSuccess is a callback called when the task is successfully executed
  63794. * @param onError is a callback called if an error occurs
  63795. */
  63796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63797. }
  63798. /**
  63799. * This class can be used to easily import assets into a scene
  63800. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63801. */
  63802. export class AssetsManager {
  63803. private _scene;
  63804. private _isLoading;
  63805. protected _tasks: AbstractAssetTask[];
  63806. protected _waitingTasksCount: number;
  63807. protected _totalTasksCount: number;
  63808. /**
  63809. * Callback called when all tasks are processed
  63810. */
  63811. onFinish: (tasks: AbstractAssetTask[]) => void;
  63812. /**
  63813. * Callback called when a task is successful
  63814. */
  63815. onTaskSuccess: (task: AbstractAssetTask) => void;
  63816. /**
  63817. * Callback called when a task had an error
  63818. */
  63819. onTaskError: (task: AbstractAssetTask) => void;
  63820. /**
  63821. * Callback called when a task is done (whatever the result is)
  63822. */
  63823. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63824. /**
  63825. * Observable called when all tasks are processed
  63826. */
  63827. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63828. /**
  63829. * Observable called when a task had an error
  63830. */
  63831. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63832. /**
  63833. * Observable called when all tasks were executed
  63834. */
  63835. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63836. /**
  63837. * Observable called when a task is done (whatever the result is)
  63838. */
  63839. onProgressObservable: Observable<IAssetsProgressEvent>;
  63840. /**
  63841. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63843. */
  63844. useDefaultLoadingScreen: boolean;
  63845. /**
  63846. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63847. * when all assets have been downloaded.
  63848. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63849. */
  63850. autoHideLoadingUI: boolean;
  63851. /**
  63852. * Creates a new AssetsManager
  63853. * @param scene defines the scene to work on
  63854. */
  63855. constructor(scene: Scene);
  63856. /**
  63857. * Add a MeshAssetTask to the list of active tasks
  63858. * @param taskName defines the name of the new task
  63859. * @param meshesNames defines the name of meshes to load
  63860. * @param rootUrl defines the root url to use to locate files
  63861. * @param sceneFilename defines the filename of the scene file
  63862. * @returns a new MeshAssetTask object
  63863. */
  63864. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63865. /**
  63866. * Add a TextFileAssetTask to the list of active tasks
  63867. * @param taskName defines the name of the new task
  63868. * @param url defines the url of the file to load
  63869. * @returns a new TextFileAssetTask object
  63870. */
  63871. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63872. /**
  63873. * Add a BinaryFileAssetTask to the list of active tasks
  63874. * @param taskName defines the name of the new task
  63875. * @param url defines the url of the file to load
  63876. * @returns a new BinaryFileAssetTask object
  63877. */
  63878. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63879. /**
  63880. * Add a ImageAssetTask to the list of active tasks
  63881. * @param taskName defines the name of the new task
  63882. * @param url defines the url of the file to load
  63883. * @returns a new ImageAssetTask object
  63884. */
  63885. addImageTask(taskName: string, url: string): ImageAssetTask;
  63886. /**
  63887. * Add a TextureAssetTask to the list of active tasks
  63888. * @param taskName defines the name of the new task
  63889. * @param url defines the url of the file to load
  63890. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63891. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63892. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63893. * @returns a new TextureAssetTask object
  63894. */
  63895. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63896. /**
  63897. * Add a CubeTextureAssetTask to the list of active tasks
  63898. * @param taskName defines the name of the new task
  63899. * @param url defines the url of the file to load
  63900. * @param extensions defines the extension to use to load the cube map (can be null)
  63901. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63902. * @param files defines the list of files to load (can be null)
  63903. * @returns a new CubeTextureAssetTask object
  63904. */
  63905. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63906. /**
  63907. *
  63908. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63909. * @param taskName defines the name of the new task
  63910. * @param url defines the url of the file to load
  63911. * @param size defines the size you want for the cubemap (can be null)
  63912. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63913. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63914. * @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)
  63915. * @param reserved Internal use only
  63916. * @returns a new HDRCubeTextureAssetTask object
  63917. */
  63918. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63919. /**
  63920. *
  63921. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63922. * @param taskName defines the name of the new task
  63923. * @param url defines the url of the file to load
  63924. * @param size defines the size you want for the cubemap (can be null)
  63925. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63926. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63927. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63928. * @returns a new EquiRectangularCubeTextureAssetTask object
  63929. */
  63930. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63931. /**
  63932. * Remove a task from the assets manager.
  63933. * @param task the task to remove
  63934. */
  63935. removeTask(task: AbstractAssetTask): void;
  63936. private _decreaseWaitingTasksCount;
  63937. private _runTask;
  63938. /**
  63939. * Reset the AssetsManager and remove all tasks
  63940. * @return the current instance of the AssetsManager
  63941. */
  63942. reset(): AssetsManager;
  63943. /**
  63944. * Start the loading process
  63945. * @return the current instance of the AssetsManager
  63946. */
  63947. load(): AssetsManager;
  63948. /**
  63949. * Start the loading process as an async operation
  63950. * @return a promise returning the list of failed tasks
  63951. */
  63952. loadAsync(): Promise<void>;
  63953. }
  63954. }
  63955. declare module "babylonjs/Misc/deferred" {
  63956. /**
  63957. * Wrapper class for promise with external resolve and reject.
  63958. */
  63959. export class Deferred<T> {
  63960. /**
  63961. * The promise associated with this deferred object.
  63962. */
  63963. readonly promise: Promise<T>;
  63964. private _resolve;
  63965. private _reject;
  63966. /**
  63967. * The resolve method of the promise associated with this deferred object.
  63968. */
  63969. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63970. /**
  63971. * The reject method of the promise associated with this deferred object.
  63972. */
  63973. readonly reject: (reason?: any) => void;
  63974. /**
  63975. * Constructor for this deferred object.
  63976. */
  63977. constructor();
  63978. }
  63979. }
  63980. declare module "babylonjs/Misc/meshExploder" {
  63981. import { Mesh } from "babylonjs/Meshes/mesh";
  63982. /**
  63983. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63984. */
  63985. export class MeshExploder {
  63986. private _centerMesh;
  63987. private _meshes;
  63988. private _meshesOrigins;
  63989. private _toCenterVectors;
  63990. private _scaledDirection;
  63991. private _newPosition;
  63992. private _centerPosition;
  63993. /**
  63994. * Explodes meshes from a center mesh.
  63995. * @param meshes The meshes to explode.
  63996. * @param centerMesh The mesh to be center of explosion.
  63997. */
  63998. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63999. private _setCenterMesh;
  64000. /**
  64001. * Get class name
  64002. * @returns "MeshExploder"
  64003. */
  64004. getClassName(): string;
  64005. /**
  64006. * "Exploded meshes"
  64007. * @returns Array of meshes with the centerMesh at index 0.
  64008. */
  64009. getMeshes(): Array<Mesh>;
  64010. /**
  64011. * Explodes meshes giving a specific direction
  64012. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64013. */
  64014. explode(direction?: number): void;
  64015. }
  64016. }
  64017. declare module "babylonjs/Misc/filesInput" {
  64018. import { Engine } from "babylonjs/Engines/engine";
  64019. import { Scene } from "babylonjs/scene";
  64020. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64021. /**
  64022. * Class used to help managing file picking and drag'n'drop
  64023. */
  64024. export class FilesInput {
  64025. /**
  64026. * List of files ready to be loaded
  64027. */
  64028. static readonly FilesToLoad: {
  64029. [key: string]: File;
  64030. };
  64031. /**
  64032. * Callback called when a file is processed
  64033. */
  64034. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64035. private _engine;
  64036. private _currentScene;
  64037. private _sceneLoadedCallback;
  64038. private _progressCallback;
  64039. private _additionalRenderLoopLogicCallback;
  64040. private _textureLoadingCallback;
  64041. private _startingProcessingFilesCallback;
  64042. private _onReloadCallback;
  64043. private _errorCallback;
  64044. private _elementToMonitor;
  64045. private _sceneFileToLoad;
  64046. private _filesToLoad;
  64047. /**
  64048. * Creates a new FilesInput
  64049. * @param engine defines the rendering engine
  64050. * @param scene defines the hosting scene
  64051. * @param sceneLoadedCallback callback called when scene is loaded
  64052. * @param progressCallback callback called to track progress
  64053. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64054. * @param textureLoadingCallback callback called when a texture is loading
  64055. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64056. * @param onReloadCallback callback called when a reload is requested
  64057. * @param errorCallback callback call if an error occurs
  64058. */
  64059. 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);
  64060. private _dragEnterHandler;
  64061. private _dragOverHandler;
  64062. private _dropHandler;
  64063. /**
  64064. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64065. * @param elementToMonitor defines the DOM element to track
  64066. */
  64067. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64068. /**
  64069. * Release all associated resources
  64070. */
  64071. dispose(): void;
  64072. private renderFunction;
  64073. private drag;
  64074. private drop;
  64075. private _traverseFolder;
  64076. private _processFiles;
  64077. /**
  64078. * Load files from a drop event
  64079. * @param event defines the drop event to use as source
  64080. */
  64081. loadFiles(event: any): void;
  64082. private _processReload;
  64083. /**
  64084. * Reload the current scene from the loaded files
  64085. */
  64086. reload(): void;
  64087. }
  64088. }
  64089. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64090. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64091. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64092. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64093. }
  64094. declare module "babylonjs/Misc/sceneOptimizer" {
  64095. import { Scene, IDisposable } from "babylonjs/scene";
  64096. import { Observable } from "babylonjs/Misc/observable";
  64097. /**
  64098. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64100. */
  64101. export class SceneOptimization {
  64102. /**
  64103. * Defines the priority of this optimization (0 by default which means first in the list)
  64104. */
  64105. priority: number;
  64106. /**
  64107. * Gets a string describing the action executed by the current optimization
  64108. * @returns description string
  64109. */
  64110. getDescription(): string;
  64111. /**
  64112. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64113. * @param scene defines the current scene where to apply this optimization
  64114. * @param optimizer defines the current optimizer
  64115. * @returns true if everything that can be done was applied
  64116. */
  64117. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64118. /**
  64119. * Creates the SceneOptimization object
  64120. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64121. * @param desc defines the description associated with the optimization
  64122. */
  64123. constructor(
  64124. /**
  64125. * Defines the priority of this optimization (0 by default which means first in the list)
  64126. */
  64127. priority?: number);
  64128. }
  64129. /**
  64130. * Defines an optimization used to reduce the size of render target textures
  64131. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64132. */
  64133. export class TextureOptimization extends SceneOptimization {
  64134. /**
  64135. * Defines the priority of this optimization (0 by default which means first in the list)
  64136. */
  64137. priority: number;
  64138. /**
  64139. * 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
  64140. */
  64141. maximumSize: number;
  64142. /**
  64143. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64144. */
  64145. step: number;
  64146. /**
  64147. * Gets a string describing the action executed by the current optimization
  64148. * @returns description string
  64149. */
  64150. getDescription(): string;
  64151. /**
  64152. * Creates the TextureOptimization object
  64153. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64154. * @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
  64155. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64156. */
  64157. constructor(
  64158. /**
  64159. * Defines the priority of this optimization (0 by default which means first in the list)
  64160. */
  64161. priority?: number,
  64162. /**
  64163. * 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
  64164. */
  64165. maximumSize?: number,
  64166. /**
  64167. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64168. */
  64169. step?: number);
  64170. /**
  64171. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64172. * @param scene defines the current scene where to apply this optimization
  64173. * @param optimizer defines the current optimizer
  64174. * @returns true if everything that can be done was applied
  64175. */
  64176. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64177. }
  64178. /**
  64179. * Defines an optimization used to increase or decrease the rendering resolution
  64180. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64181. */
  64182. export class HardwareScalingOptimization extends SceneOptimization {
  64183. /**
  64184. * Defines the priority of this optimization (0 by default which means first in the list)
  64185. */
  64186. priority: number;
  64187. /**
  64188. * Defines the maximum scale to use (2 by default)
  64189. */
  64190. maximumScale: number;
  64191. /**
  64192. * Defines the step to use between two passes (0.5 by default)
  64193. */
  64194. step: number;
  64195. private _currentScale;
  64196. private _directionOffset;
  64197. /**
  64198. * Gets a string describing the action executed by the current optimization
  64199. * @return description string
  64200. */
  64201. getDescription(): string;
  64202. /**
  64203. * Creates the HardwareScalingOptimization object
  64204. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64205. * @param maximumScale defines the maximum scale to use (2 by default)
  64206. * @param step defines the step to use between two passes (0.5 by default)
  64207. */
  64208. constructor(
  64209. /**
  64210. * Defines the priority of this optimization (0 by default which means first in the list)
  64211. */
  64212. priority?: number,
  64213. /**
  64214. * Defines the maximum scale to use (2 by default)
  64215. */
  64216. maximumScale?: number,
  64217. /**
  64218. * Defines the step to use between two passes (0.5 by default)
  64219. */
  64220. step?: number);
  64221. /**
  64222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64223. * @param scene defines the current scene where to apply this optimization
  64224. * @param optimizer defines the current optimizer
  64225. * @returns true if everything that can be done was applied
  64226. */
  64227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64228. }
  64229. /**
  64230. * Defines an optimization used to remove shadows
  64231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64232. */
  64233. export class ShadowsOptimization extends SceneOptimization {
  64234. /**
  64235. * Gets a string describing the action executed by the current optimization
  64236. * @return description string
  64237. */
  64238. getDescription(): string;
  64239. /**
  64240. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64241. * @param scene defines the current scene where to apply this optimization
  64242. * @param optimizer defines the current optimizer
  64243. * @returns true if everything that can be done was applied
  64244. */
  64245. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64246. }
  64247. /**
  64248. * Defines an optimization used to turn post-processes off
  64249. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64250. */
  64251. export class PostProcessesOptimization extends SceneOptimization {
  64252. /**
  64253. * Gets a string describing the action executed by the current optimization
  64254. * @return description string
  64255. */
  64256. getDescription(): string;
  64257. /**
  64258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64259. * @param scene defines the current scene where to apply this optimization
  64260. * @param optimizer defines the current optimizer
  64261. * @returns true if everything that can be done was applied
  64262. */
  64263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64264. }
  64265. /**
  64266. * Defines an optimization used to turn lens flares off
  64267. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64268. */
  64269. export class LensFlaresOptimization extends SceneOptimization {
  64270. /**
  64271. * Gets a string describing the action executed by the current optimization
  64272. * @return description string
  64273. */
  64274. getDescription(): string;
  64275. /**
  64276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64277. * @param scene defines the current scene where to apply this optimization
  64278. * @param optimizer defines the current optimizer
  64279. * @returns true if everything that can be done was applied
  64280. */
  64281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64282. }
  64283. /**
  64284. * Defines an optimization based on user defined callback.
  64285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64286. */
  64287. export class CustomOptimization extends SceneOptimization {
  64288. /**
  64289. * Callback called to apply the custom optimization.
  64290. */
  64291. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64292. /**
  64293. * Callback called to get custom description
  64294. */
  64295. onGetDescription: () => string;
  64296. /**
  64297. * Gets a string describing the action executed by the current optimization
  64298. * @returns description string
  64299. */
  64300. getDescription(): string;
  64301. /**
  64302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64303. * @param scene defines the current scene where to apply this optimization
  64304. * @param optimizer defines the current optimizer
  64305. * @returns true if everything that can be done was applied
  64306. */
  64307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64308. }
  64309. /**
  64310. * Defines an optimization used to turn particles off
  64311. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64312. */
  64313. export class ParticlesOptimization extends SceneOptimization {
  64314. /**
  64315. * Gets a string describing the action executed by the current optimization
  64316. * @return description string
  64317. */
  64318. getDescription(): string;
  64319. /**
  64320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64321. * @param scene defines the current scene where to apply this optimization
  64322. * @param optimizer defines the current optimizer
  64323. * @returns true if everything that can be done was applied
  64324. */
  64325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64326. }
  64327. /**
  64328. * Defines an optimization used to turn render targets off
  64329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64330. */
  64331. export class RenderTargetsOptimization extends SceneOptimization {
  64332. /**
  64333. * Gets a string describing the action executed by the current optimization
  64334. * @return description string
  64335. */
  64336. getDescription(): string;
  64337. /**
  64338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64339. * @param scene defines the current scene where to apply this optimization
  64340. * @param optimizer defines the current optimizer
  64341. * @returns true if everything that can be done was applied
  64342. */
  64343. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64344. }
  64345. /**
  64346. * Defines an optimization used to merge meshes with compatible materials
  64347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64348. */
  64349. export class MergeMeshesOptimization extends SceneOptimization {
  64350. private static _UpdateSelectionTree;
  64351. /**
  64352. * Gets or sets a boolean which defines if optimization octree has to be updated
  64353. */
  64354. /**
  64355. * Gets or sets a boolean which defines if optimization octree has to be updated
  64356. */
  64357. static UpdateSelectionTree: boolean;
  64358. /**
  64359. * Gets a string describing the action executed by the current optimization
  64360. * @return description string
  64361. */
  64362. getDescription(): string;
  64363. private _canBeMerged;
  64364. /**
  64365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64366. * @param scene defines the current scene where to apply this optimization
  64367. * @param optimizer defines the current optimizer
  64368. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64369. * @returns true if everything that can be done was applied
  64370. */
  64371. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64372. }
  64373. /**
  64374. * Defines a list of options used by SceneOptimizer
  64375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64376. */
  64377. export class SceneOptimizerOptions {
  64378. /**
  64379. * Defines the target frame rate to reach (60 by default)
  64380. */
  64381. targetFrameRate: number;
  64382. /**
  64383. * Defines the interval between two checkes (2000ms by default)
  64384. */
  64385. trackerDuration: number;
  64386. /**
  64387. * Gets the list of optimizations to apply
  64388. */
  64389. optimizations: SceneOptimization[];
  64390. /**
  64391. * Creates a new list of options used by SceneOptimizer
  64392. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64393. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64394. */
  64395. constructor(
  64396. /**
  64397. * Defines the target frame rate to reach (60 by default)
  64398. */
  64399. targetFrameRate?: number,
  64400. /**
  64401. * Defines the interval between two checkes (2000ms by default)
  64402. */
  64403. trackerDuration?: number);
  64404. /**
  64405. * Add a new optimization
  64406. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64407. * @returns the current SceneOptimizerOptions
  64408. */
  64409. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64410. /**
  64411. * Add a new custom optimization
  64412. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64413. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64414. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64415. * @returns the current SceneOptimizerOptions
  64416. */
  64417. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64418. /**
  64419. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64420. * @param targetFrameRate defines the target frame rate (60 by default)
  64421. * @returns a SceneOptimizerOptions object
  64422. */
  64423. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64424. /**
  64425. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64426. * @param targetFrameRate defines the target frame rate (60 by default)
  64427. * @returns a SceneOptimizerOptions object
  64428. */
  64429. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64430. /**
  64431. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64432. * @param targetFrameRate defines the target frame rate (60 by default)
  64433. * @returns a SceneOptimizerOptions object
  64434. */
  64435. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64436. }
  64437. /**
  64438. * Class used to run optimizations in order to reach a target frame rate
  64439. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64440. */
  64441. export class SceneOptimizer implements IDisposable {
  64442. private _isRunning;
  64443. private _options;
  64444. private _scene;
  64445. private _currentPriorityLevel;
  64446. private _targetFrameRate;
  64447. private _trackerDuration;
  64448. private _currentFrameRate;
  64449. private _sceneDisposeObserver;
  64450. private _improvementMode;
  64451. /**
  64452. * Defines an observable called when the optimizer reaches the target frame rate
  64453. */
  64454. onSuccessObservable: Observable<SceneOptimizer>;
  64455. /**
  64456. * Defines an observable called when the optimizer enables an optimization
  64457. */
  64458. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64459. /**
  64460. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64461. */
  64462. onFailureObservable: Observable<SceneOptimizer>;
  64463. /**
  64464. * Gets a boolean indicating if the optimizer is in improvement mode
  64465. */
  64466. readonly isInImprovementMode: boolean;
  64467. /**
  64468. * Gets the current priority level (0 at start)
  64469. */
  64470. readonly currentPriorityLevel: number;
  64471. /**
  64472. * Gets the current frame rate checked by the SceneOptimizer
  64473. */
  64474. readonly currentFrameRate: number;
  64475. /**
  64476. * Gets or sets the current target frame rate (60 by default)
  64477. */
  64478. /**
  64479. * Gets or sets the current target frame rate (60 by default)
  64480. */
  64481. targetFrameRate: number;
  64482. /**
  64483. * Gets or sets the current interval between two checks (every 2000ms by default)
  64484. */
  64485. /**
  64486. * Gets or sets the current interval between two checks (every 2000ms by default)
  64487. */
  64488. trackerDuration: number;
  64489. /**
  64490. * Gets the list of active optimizations
  64491. */
  64492. readonly optimizations: SceneOptimization[];
  64493. /**
  64494. * Creates a new SceneOptimizer
  64495. * @param scene defines the scene to work on
  64496. * @param options defines the options to use with the SceneOptimizer
  64497. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64498. * @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)
  64499. */
  64500. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64501. /**
  64502. * Stops the current optimizer
  64503. */
  64504. stop(): void;
  64505. /**
  64506. * Reset the optimizer to initial step (current priority level = 0)
  64507. */
  64508. reset(): void;
  64509. /**
  64510. * Start the optimizer. By default it will try to reach a specific framerate
  64511. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64512. */
  64513. start(): void;
  64514. private _checkCurrentState;
  64515. /**
  64516. * Release all resources
  64517. */
  64518. dispose(): void;
  64519. /**
  64520. * Helper function to create a SceneOptimizer with one single line of code
  64521. * @param scene defines the scene to work on
  64522. * @param options defines the options to use with the SceneOptimizer
  64523. * @param onSuccess defines a callback to call on success
  64524. * @param onFailure defines a callback to call on failure
  64525. * @returns the new SceneOptimizer object
  64526. */
  64527. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64528. }
  64529. }
  64530. declare module "babylonjs/Misc/sceneSerializer" {
  64531. import { Scene } from "babylonjs/scene";
  64532. /**
  64533. * Class used to serialize a scene into a string
  64534. */
  64535. export class SceneSerializer {
  64536. /**
  64537. * Clear cache used by a previous serialization
  64538. */
  64539. static ClearCache(): void;
  64540. /**
  64541. * Serialize a scene into a JSON compatible object
  64542. * @param scene defines the scene to serialize
  64543. * @returns a JSON compatible object
  64544. */
  64545. static Serialize(scene: Scene): any;
  64546. /**
  64547. * Serialize a mesh into a JSON compatible object
  64548. * @param toSerialize defines the mesh to serialize
  64549. * @param withParents defines if parents must be serialized as well
  64550. * @param withChildren defines if children must be serialized as well
  64551. * @returns a JSON compatible object
  64552. */
  64553. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64554. }
  64555. }
  64556. declare module "babylonjs/Misc/textureTools" {
  64557. import { Texture } from "babylonjs/Materials/Textures/texture";
  64558. /**
  64559. * Class used to host texture specific utilities
  64560. */
  64561. export class TextureTools {
  64562. /**
  64563. * Uses the GPU to create a copy texture rescaled at a given size
  64564. * @param texture Texture to copy from
  64565. * @param width defines the desired width
  64566. * @param height defines the desired height
  64567. * @param useBilinearMode defines if bilinear mode has to be used
  64568. * @return the generated texture
  64569. */
  64570. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64571. }
  64572. }
  64573. declare module "babylonjs/Misc/videoRecorder" {
  64574. import { Nullable } from "babylonjs/types";
  64575. import { Engine } from "babylonjs/Engines/engine";
  64576. /**
  64577. * This represents the different options available for the video capture.
  64578. */
  64579. export interface VideoRecorderOptions {
  64580. /** Defines the mime type of the video. */
  64581. mimeType: string;
  64582. /** Defines the FPS the video should be recorded at. */
  64583. fps: number;
  64584. /** Defines the chunk size for the recording data. */
  64585. recordChunckSize: number;
  64586. /** The audio tracks to attach to the recording. */
  64587. audioTracks?: MediaStreamTrack[];
  64588. }
  64589. /**
  64590. * This can help with recording videos from BabylonJS.
  64591. * This is based on the available WebRTC functionalities of the browser.
  64592. *
  64593. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64594. */
  64595. export class VideoRecorder {
  64596. private static readonly _defaultOptions;
  64597. /**
  64598. * Returns whether or not the VideoRecorder is available in your browser.
  64599. * @param engine Defines the Babylon Engine.
  64600. * @returns true if supported otherwise false.
  64601. */
  64602. static IsSupported(engine: Engine): boolean;
  64603. private readonly _options;
  64604. private _canvas;
  64605. private _mediaRecorder;
  64606. private _recordedChunks;
  64607. private _fileName;
  64608. private _resolve;
  64609. private _reject;
  64610. /**
  64611. * True when a recording is already in progress.
  64612. */
  64613. readonly isRecording: boolean;
  64614. /**
  64615. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64616. * @param engine Defines the BabylonJS Engine you wish to record.
  64617. * @param options Defines options that can be used to customize the capture.
  64618. */
  64619. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64620. /**
  64621. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64622. */
  64623. stopRecording(): void;
  64624. /**
  64625. * Starts recording the canvas for a max duration specified in parameters.
  64626. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64627. * If null no automatic download will start and you can rely on the promise to get the data back.
  64628. * @param maxDuration Defines the maximum recording time in seconds.
  64629. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64630. * @return A promise callback at the end of the recording with the video data in Blob.
  64631. */
  64632. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64633. /**
  64634. * Releases internal resources used during the recording.
  64635. */
  64636. dispose(): void;
  64637. private _handleDataAvailable;
  64638. private _handleError;
  64639. private _handleStop;
  64640. }
  64641. }
  64642. declare module "babylonjs/Misc/screenshotTools" {
  64643. import { Camera } from "babylonjs/Cameras/camera";
  64644. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  64645. import { Engine } from "babylonjs/Engines/engine";
  64646. /**
  64647. * Class containing a set of static utilities functions for screenshots
  64648. */
  64649. export class ScreenshotTools {
  64650. /**
  64651. * Captures a screenshot of the current rendering
  64652. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64653. * @param engine defines the rendering engine
  64654. * @param camera defines the source camera
  64655. * @param size This parameter can be set to a single number or to an object with the
  64656. * following (optional) properties: precision, width, height. If a single number is passed,
  64657. * it will be used for both width and height. If an object is passed, the screenshot size
  64658. * will be derived from the parameters. The precision property is a multiplier allowing
  64659. * rendering at a higher or lower resolution
  64660. * @param successCallback defines the callback receives a single parameter which contains the
  64661. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64662. * src parameter of an <img> to display it
  64663. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64664. * Check your browser for supported MIME types
  64665. */
  64666. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64667. /**
  64668. * Captures a screenshot of the current rendering
  64669. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64670. * @param engine defines the rendering engine
  64671. * @param camera defines the source camera
  64672. * @param size This parameter can be set to a single number or to an object with the
  64673. * following (optional) properties: precision, width, height. If a single number is passed,
  64674. * it will be used for both width and height. If an object is passed, the screenshot size
  64675. * will be derived from the parameters. The precision property is a multiplier allowing
  64676. * rendering at a higher or lower resolution
  64677. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64678. * Check your browser for supported MIME types
  64679. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64680. * to the src parameter of an <img> to display it
  64681. */
  64682. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64683. /**
  64684. * Generates an image screenshot from the specified camera.
  64685. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64686. * @param engine The engine to use for rendering
  64687. * @param camera The camera to use for rendering
  64688. * @param size This parameter can be set to a single number or to an object with the
  64689. * following (optional) properties: precision, width, height. If a single number is passed,
  64690. * it will be used for both width and height. If an object is passed, the screenshot size
  64691. * will be derived from the parameters. The precision property is a multiplier allowing
  64692. * rendering at a higher or lower resolution
  64693. * @param successCallback The callback receives a single parameter which contains the
  64694. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64695. * src parameter of an <img> to display it
  64696. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64697. * Check your browser for supported MIME types
  64698. * @param samples Texture samples (default: 1)
  64699. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64700. * @param fileName A name for for the downloaded file.
  64701. */
  64702. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64703. /**
  64704. * Generates an image screenshot from the specified camera.
  64705. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64706. * @param engine The engine to use for rendering
  64707. * @param camera The camera to use for rendering
  64708. * @param size This parameter can be set to a single number or to an object with the
  64709. * following (optional) properties: precision, width, height. If a single number is passed,
  64710. * it will be used for both width and height. If an object is passed, the screenshot size
  64711. * will be derived from the parameters. The precision property is a multiplier allowing
  64712. * rendering at a higher or lower resolution
  64713. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64714. * Check your browser for supported MIME types
  64715. * @param samples Texture samples (default: 1)
  64716. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64717. * @param fileName A name for for the downloaded file.
  64718. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64719. * to the src parameter of an <img> to display it
  64720. */
  64721. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64722. /**
  64723. * Gets height and width for screenshot size
  64724. * @private
  64725. */
  64726. private static _getScreenshotSize;
  64727. }
  64728. }
  64729. declare module "babylonjs/Misc/index" {
  64730. export * from "babylonjs/Misc/andOrNotEvaluator";
  64731. export * from "babylonjs/Misc/assetsManager";
  64732. export * from "babylonjs/Misc/dds";
  64733. export * from "babylonjs/Misc/decorators";
  64734. export * from "babylonjs/Misc/deferred";
  64735. export * from "babylonjs/Misc/environmentTextureTools";
  64736. export * from "babylonjs/Misc/meshExploder";
  64737. export * from "babylonjs/Misc/filesInput";
  64738. export * from "babylonjs/Misc/HighDynamicRange/index";
  64739. export * from "babylonjs/Misc/khronosTextureContainer";
  64740. export * from "babylonjs/Misc/observable";
  64741. export * from "babylonjs/Misc/performanceMonitor";
  64742. export * from "babylonjs/Misc/promise";
  64743. export * from "babylonjs/Misc/sceneOptimizer";
  64744. export * from "babylonjs/Misc/sceneSerializer";
  64745. export * from "babylonjs/Misc/smartArray";
  64746. export * from "babylonjs/Misc/stringDictionary";
  64747. export * from "babylonjs/Misc/tags";
  64748. export * from "babylonjs/Misc/textureTools";
  64749. export * from "babylonjs/Misc/tga";
  64750. export * from "babylonjs/Misc/tools";
  64751. export * from "babylonjs/Misc/videoRecorder";
  64752. export * from "babylonjs/Misc/virtualJoystick";
  64753. export * from "babylonjs/Misc/workerPool";
  64754. export * from "babylonjs/Misc/logger";
  64755. export * from "babylonjs/Misc/typeStore";
  64756. export * from "babylonjs/Misc/filesInputStore";
  64757. export * from "babylonjs/Misc/deepCopier";
  64758. export * from "babylonjs/Misc/pivotTools";
  64759. export * from "babylonjs/Misc/precisionDate";
  64760. export * from "babylonjs/Misc/screenshotTools";
  64761. export * from "babylonjs/Misc/typeStore";
  64762. export * from "babylonjs/Misc/webRequest";
  64763. export * from "babylonjs/Misc/iInspectable";
  64764. export * from "babylonjs/Misc/brdfTextureTools";
  64765. export * from "babylonjs/Misc/gradients";
  64766. export * from "babylonjs/Misc/perfCounter";
  64767. export * from "babylonjs/Misc/fileRequest";
  64768. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64769. export * from "babylonjs/Misc/retryStrategy";
  64770. export * from "babylonjs/Misc/loadFileError";
  64771. }
  64772. declare module "babylonjs/index" {
  64773. export * from "babylonjs/abstractScene";
  64774. export * from "babylonjs/Actions/index";
  64775. export * from "babylonjs/Animations/index";
  64776. export * from "babylonjs/assetContainer";
  64777. export * from "babylonjs/Audio/index";
  64778. export * from "babylonjs/Behaviors/index";
  64779. export * from "babylonjs/Bones/index";
  64780. export * from "babylonjs/Cameras/index";
  64781. export * from "babylonjs/Collisions/index";
  64782. export * from "babylonjs/Culling/index";
  64783. export * from "babylonjs/Debug/index";
  64784. export * from "babylonjs/Engines/index";
  64785. export * from "babylonjs/Events/index";
  64786. export * from "babylonjs/Gamepads/index";
  64787. export * from "babylonjs/Gizmos/index";
  64788. export * from "babylonjs/Helpers/index";
  64789. export * from "babylonjs/Instrumentation/index";
  64790. export * from "babylonjs/Layers/index";
  64791. export * from "babylonjs/LensFlares/index";
  64792. export * from "babylonjs/Lights/index";
  64793. export * from "babylonjs/Loading/index";
  64794. export * from "babylonjs/Materials/index";
  64795. export * from "babylonjs/Maths/index";
  64796. export * from "babylonjs/Meshes/index";
  64797. export * from "babylonjs/Morph/index";
  64798. export * from "babylonjs/Navigation/index";
  64799. export * from "babylonjs/node";
  64800. export * from "babylonjs/Offline/index";
  64801. export * from "babylonjs/Particles/index";
  64802. export * from "babylonjs/Physics/index";
  64803. export * from "babylonjs/PostProcesses/index";
  64804. export * from "babylonjs/Probes/index";
  64805. export * from "babylonjs/Rendering/index";
  64806. export * from "babylonjs/scene";
  64807. export * from "babylonjs/sceneComponent";
  64808. export * from "babylonjs/Sprites/index";
  64809. export * from "babylonjs/States/index";
  64810. export * from "babylonjs/Misc/index";
  64811. export * from "babylonjs/types";
  64812. }
  64813. declare module "babylonjs/Animations/pathCursor" {
  64814. import { Vector3 } from "babylonjs/Maths/math.vector";
  64815. import { Path2 } from "babylonjs/Maths/math.path";
  64816. /**
  64817. * A cursor which tracks a point on a path
  64818. */
  64819. export class PathCursor {
  64820. private path;
  64821. /**
  64822. * Stores path cursor callbacks for when an onchange event is triggered
  64823. */
  64824. private _onchange;
  64825. /**
  64826. * The value of the path cursor
  64827. */
  64828. value: number;
  64829. /**
  64830. * The animation array of the path cursor
  64831. */
  64832. animations: Animation[];
  64833. /**
  64834. * Initializes the path cursor
  64835. * @param path The path to track
  64836. */
  64837. constructor(path: Path2);
  64838. /**
  64839. * Gets the cursor point on the path
  64840. * @returns A point on the path cursor at the cursor location
  64841. */
  64842. getPoint(): Vector3;
  64843. /**
  64844. * Moves the cursor ahead by the step amount
  64845. * @param step The amount to move the cursor forward
  64846. * @returns This path cursor
  64847. */
  64848. moveAhead(step?: number): PathCursor;
  64849. /**
  64850. * Moves the cursor behind by the step amount
  64851. * @param step The amount to move the cursor back
  64852. * @returns This path cursor
  64853. */
  64854. moveBack(step?: number): PathCursor;
  64855. /**
  64856. * Moves the cursor by the step amount
  64857. * If the step amount is greater than one, an exception is thrown
  64858. * @param step The amount to move the cursor
  64859. * @returns This path cursor
  64860. */
  64861. move(step: number): PathCursor;
  64862. /**
  64863. * Ensures that the value is limited between zero and one
  64864. * @returns This path cursor
  64865. */
  64866. private ensureLimits;
  64867. /**
  64868. * Runs onchange callbacks on change (used by the animation engine)
  64869. * @returns This path cursor
  64870. */
  64871. private raiseOnChange;
  64872. /**
  64873. * Executes a function on change
  64874. * @param f A path cursor onchange callback
  64875. * @returns This path cursor
  64876. */
  64877. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64878. }
  64879. }
  64880. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  64881. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  64882. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  64883. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  64884. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  64885. }
  64886. declare module "babylonjs/Engines/Processors/Expressions/index" {
  64887. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  64888. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  64889. }
  64890. declare module "babylonjs/Engines/Processors/index" {
  64891. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  64892. export * from "babylonjs/Engines/Processors/Expressions/index";
  64893. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  64894. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  64895. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  64896. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  64897. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  64898. export * from "babylonjs/Engines/Processors/shaderProcessor";
  64899. }
  64900. declare module "babylonjs/Legacy/legacy" {
  64901. import * as Babylon from "babylonjs/index";
  64902. export * from "babylonjs/index";
  64903. }
  64904. declare module "babylonjs/Shaders/blur.fragment" {
  64905. /** @hidden */
  64906. export var blurPixelShader: {
  64907. name: string;
  64908. shader: string;
  64909. };
  64910. }
  64911. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  64912. /** @hidden */
  64913. export var pointCloudVertexDeclaration: {
  64914. name: string;
  64915. shader: string;
  64916. };
  64917. }
  64918. declare module "babylonjs" {
  64919. export * from "babylonjs/Legacy/legacy";
  64920. }
  64921. declare module BABYLON {
  64922. /** Alias type for value that can be null */
  64923. export type Nullable<T> = T | null;
  64924. /**
  64925. * Alias type for number that are floats
  64926. * @ignorenaming
  64927. */
  64928. export type float = number;
  64929. /**
  64930. * Alias type for number that are doubles.
  64931. * @ignorenaming
  64932. */
  64933. export type double = number;
  64934. /**
  64935. * Alias type for number that are integer
  64936. * @ignorenaming
  64937. */
  64938. export type int = number;
  64939. /** Alias type for number array or Float32Array */
  64940. export type FloatArray = number[] | Float32Array;
  64941. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  64942. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  64943. /**
  64944. * Alias for types that can be used by a Buffer or VertexBuffer.
  64945. */
  64946. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  64947. /**
  64948. * Alias type for primitive types
  64949. * @ignorenaming
  64950. */
  64951. type Primitive = undefined | null | boolean | string | number | Function;
  64952. /**
  64953. * Type modifier to make all the properties of an object Readonly
  64954. */
  64955. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  64956. /**
  64957. * Type modifier to make all the properties of an object Readonly recursively
  64958. */
  64959. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  64960. /** @hidden */
  64961. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  64962. }
  64963. /** @hidden */
  64964. /** @hidden */
  64965. type DeepImmutableObject<T> = {
  64966. readonly [K in keyof T]: DeepImmutable<T[K]>;
  64967. };
  64968. }
  64969. declare module BABYLON {
  64970. /**
  64971. * A class serves as a medium between the observable and its observers
  64972. */
  64973. export class EventState {
  64974. /**
  64975. * Create a new EventState
  64976. * @param mask defines the mask associated with this state
  64977. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64978. * @param target defines the original target of the state
  64979. * @param currentTarget defines the current target of the state
  64980. */
  64981. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64982. /**
  64983. * Initialize the current event state
  64984. * @param mask defines the mask associated with this state
  64985. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64986. * @param target defines the original target of the state
  64987. * @param currentTarget defines the current target of the state
  64988. * @returns the current event state
  64989. */
  64990. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64991. /**
  64992. * An Observer can set this property to true to prevent subsequent observers of being notified
  64993. */
  64994. skipNextObservers: boolean;
  64995. /**
  64996. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64997. */
  64998. mask: number;
  64999. /**
  65000. * The object that originally notified the event
  65001. */
  65002. target?: any;
  65003. /**
  65004. * The current object in the bubbling phase
  65005. */
  65006. currentTarget?: any;
  65007. /**
  65008. * This will be populated with the return value of the last function that was executed.
  65009. * If it is the first function in the callback chain it will be the event data.
  65010. */
  65011. lastReturnValue?: any;
  65012. }
  65013. /**
  65014. * Represent an Observer registered to a given Observable object.
  65015. */
  65016. export class Observer<T> {
  65017. /**
  65018. * Defines the callback to call when the observer is notified
  65019. */
  65020. callback: (eventData: T, eventState: EventState) => void;
  65021. /**
  65022. * Defines the mask of the observer (used to filter notifications)
  65023. */
  65024. mask: number;
  65025. /**
  65026. * Defines the current scope used to restore the JS context
  65027. */
  65028. scope: any;
  65029. /** @hidden */
  65030. _willBeUnregistered: boolean;
  65031. /**
  65032. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65033. */
  65034. unregisterOnNextCall: boolean;
  65035. /**
  65036. * Creates a new observer
  65037. * @param callback defines the callback to call when the observer is notified
  65038. * @param mask defines the mask of the observer (used to filter notifications)
  65039. * @param scope defines the current scope used to restore the JS context
  65040. */
  65041. constructor(
  65042. /**
  65043. * Defines the callback to call when the observer is notified
  65044. */
  65045. callback: (eventData: T, eventState: EventState) => void,
  65046. /**
  65047. * Defines the mask of the observer (used to filter notifications)
  65048. */
  65049. mask: number,
  65050. /**
  65051. * Defines the current scope used to restore the JS context
  65052. */
  65053. scope?: any);
  65054. }
  65055. /**
  65056. * Represent a list of observers registered to multiple Observables object.
  65057. */
  65058. export class MultiObserver<T> {
  65059. private _observers;
  65060. private _observables;
  65061. /**
  65062. * Release associated resources
  65063. */
  65064. dispose(): void;
  65065. /**
  65066. * Raise a callback when one of the observable will notify
  65067. * @param observables defines a list of observables to watch
  65068. * @param callback defines the callback to call on notification
  65069. * @param mask defines the mask used to filter notifications
  65070. * @param scope defines the current scope used to restore the JS context
  65071. * @returns the new MultiObserver
  65072. */
  65073. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65074. }
  65075. /**
  65076. * The Observable class is a simple implementation of the Observable pattern.
  65077. *
  65078. * 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.
  65079. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65080. * 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).
  65081. * 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.
  65082. */
  65083. export class Observable<T> {
  65084. private _observers;
  65085. private _eventState;
  65086. private _onObserverAdded;
  65087. /**
  65088. * Gets the list of observers
  65089. */
  65090. readonly observers: Array<Observer<T>>;
  65091. /**
  65092. * Creates a new observable
  65093. * @param onObserverAdded defines a callback to call when a new observer is added
  65094. */
  65095. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65096. /**
  65097. * Create a new Observer with the specified callback
  65098. * @param callback the callback that will be executed for that Observer
  65099. * @param mask the mask used to filter observers
  65100. * @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.
  65101. * @param scope optional scope for the callback to be called from
  65102. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65103. * @returns the new observer created for the callback
  65104. */
  65105. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65106. /**
  65107. * Create a new Observer with the specified callback and unregisters after the next notification
  65108. * @param callback the callback that will be executed for that Observer
  65109. * @returns the new observer created for the callback
  65110. */
  65111. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65112. /**
  65113. * Remove an Observer from the Observable object
  65114. * @param observer the instance of the Observer to remove
  65115. * @returns false if it doesn't belong to this Observable
  65116. */
  65117. remove(observer: Nullable<Observer<T>>): boolean;
  65118. /**
  65119. * Remove a callback from the Observable object
  65120. * @param callback the callback to remove
  65121. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65122. * @returns false if it doesn't belong to this Observable
  65123. */
  65124. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65125. private _deferUnregister;
  65126. private _remove;
  65127. /**
  65128. * Moves the observable to the top of the observer list making it get called first when notified
  65129. * @param observer the observer to move
  65130. */
  65131. makeObserverTopPriority(observer: Observer<T>): void;
  65132. /**
  65133. * Moves the observable to the bottom of the observer list making it get called last when notified
  65134. * @param observer the observer to move
  65135. */
  65136. makeObserverBottomPriority(observer: Observer<T>): void;
  65137. /**
  65138. * Notify all Observers by calling their respective callback with the given data
  65139. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  65140. * @param eventData defines the data to send to all observers
  65141. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  65142. * @param target defines the original target of the state
  65143. * @param currentTarget defines the current target of the state
  65144. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  65145. */
  65146. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  65147. /**
  65148. * Calling this will execute each callback, expecting it to be a promise or return a value.
  65149. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  65150. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  65151. * and it is crucial that all callbacks will be executed.
  65152. * The order of the callbacks is kept, callbacks are not executed parallel.
  65153. *
  65154. * @param eventData The data to be sent to each callback
  65155. * @param mask is used to filter observers defaults to -1
  65156. * @param target defines the callback target (see EventState)
  65157. * @param currentTarget defines he current object in the bubbling phase
  65158. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  65159. */
  65160. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  65161. /**
  65162. * Notify a specific observer
  65163. * @param observer defines the observer to notify
  65164. * @param eventData defines the data to be sent to each callback
  65165. * @param mask is used to filter observers defaults to -1
  65166. */
  65167. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  65168. /**
  65169. * Gets a boolean indicating if the observable has at least one observer
  65170. * @returns true is the Observable has at least one Observer registered
  65171. */
  65172. hasObservers(): boolean;
  65173. /**
  65174. * Clear the list of observers
  65175. */
  65176. clear(): void;
  65177. /**
  65178. * Clone the current observable
  65179. * @returns a new observable
  65180. */
  65181. clone(): Observable<T>;
  65182. /**
  65183. * Does this observable handles observer registered with a given mask
  65184. * @param mask defines the mask to be tested
  65185. * @return whether or not one observer registered with the given mask is handeled
  65186. **/
  65187. hasSpecificMask(mask?: number): boolean;
  65188. }
  65189. }
  65190. declare module BABYLON {
  65191. /**
  65192. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  65193. * Babylon.js
  65194. */
  65195. export class DomManagement {
  65196. /**
  65197. * Checks if the window object exists
  65198. * @returns true if the window object exists
  65199. */
  65200. static IsWindowObjectExist(): boolean;
  65201. /**
  65202. * Extracts text content from a DOM element hierarchy
  65203. * @param element defines the root element
  65204. * @returns a string
  65205. */
  65206. static GetDOMTextContent(element: HTMLElement): string;
  65207. }
  65208. }
  65209. declare module BABYLON {
  65210. /**
  65211. * Logger used througouht the application to allow configuration of
  65212. * the log level required for the messages.
  65213. */
  65214. export class Logger {
  65215. /**
  65216. * No log
  65217. */
  65218. static readonly NoneLogLevel: number;
  65219. /**
  65220. * Only message logs
  65221. */
  65222. static readonly MessageLogLevel: number;
  65223. /**
  65224. * Only warning logs
  65225. */
  65226. static readonly WarningLogLevel: number;
  65227. /**
  65228. * Only error logs
  65229. */
  65230. static readonly ErrorLogLevel: number;
  65231. /**
  65232. * All logs
  65233. */
  65234. static readonly AllLogLevel: number;
  65235. private static _LogCache;
  65236. /**
  65237. * Gets a value indicating the number of loading errors
  65238. * @ignorenaming
  65239. */
  65240. static errorsCount: number;
  65241. /**
  65242. * Callback called when a new log is added
  65243. */
  65244. static OnNewCacheEntry: (entry: string) => void;
  65245. private static _AddLogEntry;
  65246. private static _FormatMessage;
  65247. private static _LogDisabled;
  65248. private static _LogEnabled;
  65249. private static _WarnDisabled;
  65250. private static _WarnEnabled;
  65251. private static _ErrorDisabled;
  65252. private static _ErrorEnabled;
  65253. /**
  65254. * Log a message to the console
  65255. */
  65256. static Log: (message: string) => void;
  65257. /**
  65258. * Write a warning message to the console
  65259. */
  65260. static Warn: (message: string) => void;
  65261. /**
  65262. * Write an error message to the console
  65263. */
  65264. static Error: (message: string) => void;
  65265. /**
  65266. * Gets current log cache (list of logs)
  65267. */
  65268. static readonly LogCache: string;
  65269. /**
  65270. * Clears the log cache
  65271. */
  65272. static ClearLogCache(): void;
  65273. /**
  65274. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  65275. */
  65276. static LogLevels: number;
  65277. }
  65278. }
  65279. declare module BABYLON {
  65280. /** @hidden */
  65281. export class _TypeStore {
  65282. /** @hidden */
  65283. static RegisteredTypes: {
  65284. [key: string]: Object;
  65285. };
  65286. /** @hidden */
  65287. static GetClass(fqdn: string): any;
  65288. }
  65289. }
  65290. declare module BABYLON {
  65291. /**
  65292. * Class containing a set of static utilities functions for deep copy.
  65293. */
  65294. export class DeepCopier {
  65295. /**
  65296. * Tries to copy an object by duplicating every property
  65297. * @param source defines the source object
  65298. * @param destination defines the target object
  65299. * @param doNotCopyList defines a list of properties to avoid
  65300. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65301. */
  65302. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65303. }
  65304. }
  65305. declare module BABYLON {
  65306. /**
  65307. * Class containing a set of static utilities functions for precision date
  65308. */
  65309. export class PrecisionDate {
  65310. /**
  65311. * Gets either window.performance.now() if supported or Date.now() else
  65312. */
  65313. static readonly Now: number;
  65314. }
  65315. }
  65316. declare module BABYLON {
  65317. /** @hidden */
  65318. export class _DevTools {
  65319. static WarnImport(name: string): string;
  65320. }
  65321. }
  65322. declare module BABYLON {
  65323. /**
  65324. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  65325. */
  65326. export class WebRequest {
  65327. private _xhr;
  65328. /**
  65329. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  65330. * i.e. when loading files, where the server/service expects an Authorization header
  65331. */
  65332. static CustomRequestHeaders: {
  65333. [key: string]: string;
  65334. };
  65335. /**
  65336. * Add callback functions in this array to update all the requests before they get sent to the network
  65337. */
  65338. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  65339. private _injectCustomRequestHeaders;
  65340. /**
  65341. * Gets or sets a function to be called when loading progress changes
  65342. */
  65343. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  65344. /**
  65345. * Returns client's state
  65346. */
  65347. readonly readyState: number;
  65348. /**
  65349. * Returns client's status
  65350. */
  65351. readonly status: number;
  65352. /**
  65353. * Returns client's status as a text
  65354. */
  65355. readonly statusText: string;
  65356. /**
  65357. * Returns client's response
  65358. */
  65359. readonly response: any;
  65360. /**
  65361. * Returns client's response url
  65362. */
  65363. readonly responseURL: string;
  65364. /**
  65365. * Returns client's response as text
  65366. */
  65367. readonly responseText: string;
  65368. /**
  65369. * Gets or sets the expected response type
  65370. */
  65371. responseType: XMLHttpRequestResponseType;
  65372. /** @hidden */
  65373. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65374. /** @hidden */
  65375. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65376. /**
  65377. * Cancels any network activity
  65378. */
  65379. abort(): void;
  65380. /**
  65381. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65382. * @param body defines an optional request body
  65383. */
  65384. send(body?: Document | BodyInit | null): void;
  65385. /**
  65386. * Sets the request method, request URL
  65387. * @param method defines the method to use (GET, POST, etc..)
  65388. * @param url defines the url to connect with
  65389. */
  65390. open(method: string, url: string): void;
  65391. }
  65392. }
  65393. declare module BABYLON {
  65394. /**
  65395. * File request interface
  65396. */
  65397. export interface IFileRequest {
  65398. /**
  65399. * Raised when the request is complete (success or error).
  65400. */
  65401. onCompleteObservable: Observable<IFileRequest>;
  65402. /**
  65403. * Aborts the request for a file.
  65404. */
  65405. abort: () => void;
  65406. }
  65407. }
  65408. declare module BABYLON {
  65409. /**
  65410. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65411. */
  65412. export class PerformanceMonitor {
  65413. private _enabled;
  65414. private _rollingFrameTime;
  65415. private _lastFrameTimeMs;
  65416. /**
  65417. * constructor
  65418. * @param frameSampleSize The number of samples required to saturate the sliding window
  65419. */
  65420. constructor(frameSampleSize?: number);
  65421. /**
  65422. * Samples current frame
  65423. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65424. */
  65425. sampleFrame(timeMs?: number): void;
  65426. /**
  65427. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65428. */
  65429. readonly averageFrameTime: number;
  65430. /**
  65431. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65432. */
  65433. readonly averageFrameTimeVariance: number;
  65434. /**
  65435. * Returns the frame time of the most recent frame
  65436. */
  65437. readonly instantaneousFrameTime: number;
  65438. /**
  65439. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65440. */
  65441. readonly averageFPS: number;
  65442. /**
  65443. * Returns the average framerate in frames per second using the most recent frame time
  65444. */
  65445. readonly instantaneousFPS: number;
  65446. /**
  65447. * Returns true if enough samples have been taken to completely fill the sliding window
  65448. */
  65449. readonly isSaturated: boolean;
  65450. /**
  65451. * Enables contributions to the sliding window sample set
  65452. */
  65453. enable(): void;
  65454. /**
  65455. * Disables contributions to the sliding window sample set
  65456. * Samples will not be interpolated over the disabled period
  65457. */
  65458. disable(): void;
  65459. /**
  65460. * Returns true if sampling is enabled
  65461. */
  65462. readonly isEnabled: boolean;
  65463. /**
  65464. * Resets performance monitor
  65465. */
  65466. reset(): void;
  65467. }
  65468. /**
  65469. * RollingAverage
  65470. *
  65471. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65472. */
  65473. export class RollingAverage {
  65474. /**
  65475. * Current average
  65476. */
  65477. average: number;
  65478. /**
  65479. * Current variance
  65480. */
  65481. variance: number;
  65482. protected _samples: Array<number>;
  65483. protected _sampleCount: number;
  65484. protected _pos: number;
  65485. protected _m2: number;
  65486. /**
  65487. * constructor
  65488. * @param length The number of samples required to saturate the sliding window
  65489. */
  65490. constructor(length: number);
  65491. /**
  65492. * Adds a sample to the sample set
  65493. * @param v The sample value
  65494. */
  65495. add(v: number): void;
  65496. /**
  65497. * Returns previously added values or null if outside of history or outside the sliding window domain
  65498. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65499. * @return Value previously recorded with add() or null if outside of range
  65500. */
  65501. history(i: number): number;
  65502. /**
  65503. * Returns true if enough samples have been taken to completely fill the sliding window
  65504. * @return true if sample-set saturated
  65505. */
  65506. isSaturated(): boolean;
  65507. /**
  65508. * Resets the rolling average (equivalent to 0 samples taken so far)
  65509. */
  65510. reset(): void;
  65511. /**
  65512. * Wraps a value around the sample range boundaries
  65513. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65514. * @return Wrapped position in sample range
  65515. */
  65516. protected _wrapPosition(i: number): number;
  65517. }
  65518. }
  65519. declare module BABYLON {
  65520. /**
  65521. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65522. * The underlying implementation relies on an associative array to ensure the best performances.
  65523. * The value can be anything including 'null' but except 'undefined'
  65524. */
  65525. export class StringDictionary<T> {
  65526. /**
  65527. * This will clear this dictionary and copy the content from the 'source' one.
  65528. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65529. * @param source the dictionary to take the content from and copy to this dictionary
  65530. */
  65531. copyFrom(source: StringDictionary<T>): void;
  65532. /**
  65533. * Get a value based from its key
  65534. * @param key the given key to get the matching value from
  65535. * @return the value if found, otherwise undefined is returned
  65536. */
  65537. get(key: string): T | undefined;
  65538. /**
  65539. * Get a value from its key or add it if it doesn't exist.
  65540. * This method will ensure you that a given key/data will be present in the dictionary.
  65541. * @param key the given key to get the matching value from
  65542. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65543. * The factory will only be invoked if there's no data for the given key.
  65544. * @return the value corresponding to the key.
  65545. */
  65546. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65547. /**
  65548. * Get a value from its key if present in the dictionary otherwise add it
  65549. * @param key the key to get the value from
  65550. * @param val if there's no such key/value pair in the dictionary add it with this value
  65551. * @return the value corresponding to the key
  65552. */
  65553. getOrAdd(key: string, val: T): T;
  65554. /**
  65555. * Check if there's a given key in the dictionary
  65556. * @param key the key to check for
  65557. * @return true if the key is present, false otherwise
  65558. */
  65559. contains(key: string): boolean;
  65560. /**
  65561. * Add a new key and its corresponding value
  65562. * @param key the key to add
  65563. * @param value the value corresponding to the key
  65564. * @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
  65565. */
  65566. add(key: string, value: T): boolean;
  65567. /**
  65568. * Update a specific value associated to a key
  65569. * @param key defines the key to use
  65570. * @param value defines the value to store
  65571. * @returns true if the value was updated (or false if the key was not found)
  65572. */
  65573. set(key: string, value: T): boolean;
  65574. /**
  65575. * Get the element of the given key and remove it from the dictionary
  65576. * @param key defines the key to search
  65577. * @returns the value associated with the key or null if not found
  65578. */
  65579. getAndRemove(key: string): Nullable<T>;
  65580. /**
  65581. * Remove a key/value from the dictionary.
  65582. * @param key the key to remove
  65583. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65584. */
  65585. remove(key: string): boolean;
  65586. /**
  65587. * Clear the whole content of the dictionary
  65588. */
  65589. clear(): void;
  65590. /**
  65591. * Gets the current count
  65592. */
  65593. readonly count: number;
  65594. /**
  65595. * Execute a callback on each key/val of the dictionary.
  65596. * Note that you can remove any element in this dictionary in the callback implementation
  65597. * @param callback the callback to execute on a given key/value pair
  65598. */
  65599. forEach(callback: (key: string, val: T) => void): void;
  65600. /**
  65601. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65602. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65603. * Note that you can remove any element in this dictionary in the callback implementation
  65604. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65605. * @returns the first item
  65606. */
  65607. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65608. private _count;
  65609. private _data;
  65610. }
  65611. }
  65612. declare module BABYLON {
  65613. /**
  65614. * Class used to store gfx data (like WebGLBuffer)
  65615. */
  65616. export class DataBuffer {
  65617. /**
  65618. * Gets or sets the number of objects referencing this buffer
  65619. */
  65620. references: number;
  65621. /** Gets or sets the size of the underlying buffer */
  65622. capacity: number;
  65623. /**
  65624. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65625. */
  65626. is32Bits: boolean;
  65627. /**
  65628. * Gets the underlying buffer
  65629. */
  65630. readonly underlyingResource: any;
  65631. }
  65632. }
  65633. declare module BABYLON {
  65634. /**
  65635. * Class used to store data that will be store in GPU memory
  65636. */
  65637. export class Buffer {
  65638. private _engine;
  65639. private _buffer;
  65640. /** @hidden */
  65641. _data: Nullable<DataArray>;
  65642. private _updatable;
  65643. private _instanced;
  65644. /**
  65645. * Gets the byte stride.
  65646. */
  65647. readonly byteStride: number;
  65648. /**
  65649. * Constructor
  65650. * @param engine the engine
  65651. * @param data the data to use for this buffer
  65652. * @param updatable whether the data is updatable
  65653. * @param stride the stride (optional)
  65654. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65655. * @param instanced whether the buffer is instanced (optional)
  65656. * @param useBytes set to true if the stride in in bytes (optional)
  65657. */
  65658. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65659. /**
  65660. * Create a new VertexBuffer based on the current buffer
  65661. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65662. * @param offset defines offset in the buffer (0 by default)
  65663. * @param size defines the size in floats of attributes (position is 3 for instance)
  65664. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65665. * @param instanced defines if the vertex buffer contains indexed data
  65666. * @param useBytes defines if the offset and stride are in bytes
  65667. * @returns the new vertex buffer
  65668. */
  65669. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65670. /**
  65671. * Gets a boolean indicating if the Buffer is updatable?
  65672. * @returns true if the buffer is updatable
  65673. */
  65674. isUpdatable(): boolean;
  65675. /**
  65676. * Gets current buffer's data
  65677. * @returns a DataArray or null
  65678. */
  65679. getData(): Nullable<DataArray>;
  65680. /**
  65681. * Gets underlying native buffer
  65682. * @returns underlying native buffer
  65683. */
  65684. getBuffer(): Nullable<DataBuffer>;
  65685. /**
  65686. * Gets the stride in float32 units (i.e. byte stride / 4).
  65687. * May not be an integer if the byte stride is not divisible by 4.
  65688. * DEPRECATED. Use byteStride instead.
  65689. * @returns the stride in float32 units
  65690. */
  65691. getStrideSize(): number;
  65692. /**
  65693. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65694. * @param data defines the data to store
  65695. */
  65696. create(data?: Nullable<DataArray>): void;
  65697. /** @hidden */
  65698. _rebuild(): void;
  65699. /**
  65700. * Update current buffer data
  65701. * @param data defines the data to store
  65702. */
  65703. update(data: DataArray): void;
  65704. /**
  65705. * Updates the data directly.
  65706. * @param data the new data
  65707. * @param offset the new offset
  65708. * @param vertexCount the vertex count (optional)
  65709. * @param useBytes set to true if the offset is in bytes
  65710. */
  65711. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65712. /**
  65713. * Release all resources
  65714. */
  65715. dispose(): void;
  65716. }
  65717. /**
  65718. * Specialized buffer used to store vertex data
  65719. */
  65720. export class VertexBuffer {
  65721. /** @hidden */
  65722. _buffer: Buffer;
  65723. private _kind;
  65724. private _size;
  65725. private _ownsBuffer;
  65726. private _instanced;
  65727. private _instanceDivisor;
  65728. /**
  65729. * The byte type.
  65730. */
  65731. static readonly BYTE: number;
  65732. /**
  65733. * The unsigned byte type.
  65734. */
  65735. static readonly UNSIGNED_BYTE: number;
  65736. /**
  65737. * The short type.
  65738. */
  65739. static readonly SHORT: number;
  65740. /**
  65741. * The unsigned short type.
  65742. */
  65743. static readonly UNSIGNED_SHORT: number;
  65744. /**
  65745. * The integer type.
  65746. */
  65747. static readonly INT: number;
  65748. /**
  65749. * The unsigned integer type.
  65750. */
  65751. static readonly UNSIGNED_INT: number;
  65752. /**
  65753. * The float type.
  65754. */
  65755. static readonly FLOAT: number;
  65756. /**
  65757. * Gets or sets the instance divisor when in instanced mode
  65758. */
  65759. instanceDivisor: number;
  65760. /**
  65761. * Gets the byte stride.
  65762. */
  65763. readonly byteStride: number;
  65764. /**
  65765. * Gets the byte offset.
  65766. */
  65767. readonly byteOffset: number;
  65768. /**
  65769. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65770. */
  65771. readonly normalized: boolean;
  65772. /**
  65773. * Gets the data type of each component in the array.
  65774. */
  65775. readonly type: number;
  65776. /**
  65777. * Constructor
  65778. * @param engine the engine
  65779. * @param data the data to use for this vertex buffer
  65780. * @param kind the vertex buffer kind
  65781. * @param updatable whether the data is updatable
  65782. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65783. * @param stride the stride (optional)
  65784. * @param instanced whether the buffer is instanced (optional)
  65785. * @param offset the offset of the data (optional)
  65786. * @param size the number of components (optional)
  65787. * @param type the type of the component (optional)
  65788. * @param normalized whether the data contains normalized data (optional)
  65789. * @param useBytes set to true if stride and offset are in bytes (optional)
  65790. */
  65791. 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);
  65792. /** @hidden */
  65793. _rebuild(): void;
  65794. /**
  65795. * Returns the kind of the VertexBuffer (string)
  65796. * @returns a string
  65797. */
  65798. getKind(): string;
  65799. /**
  65800. * Gets a boolean indicating if the VertexBuffer is updatable?
  65801. * @returns true if the buffer is updatable
  65802. */
  65803. isUpdatable(): boolean;
  65804. /**
  65805. * Gets current buffer's data
  65806. * @returns a DataArray or null
  65807. */
  65808. getData(): Nullable<DataArray>;
  65809. /**
  65810. * Gets underlying native buffer
  65811. * @returns underlying native buffer
  65812. */
  65813. getBuffer(): Nullable<DataBuffer>;
  65814. /**
  65815. * Gets the stride in float32 units (i.e. byte stride / 4).
  65816. * May not be an integer if the byte stride is not divisible by 4.
  65817. * DEPRECATED. Use byteStride instead.
  65818. * @returns the stride in float32 units
  65819. */
  65820. getStrideSize(): number;
  65821. /**
  65822. * Returns the offset as a multiple of the type byte length.
  65823. * DEPRECATED. Use byteOffset instead.
  65824. * @returns the offset in bytes
  65825. */
  65826. getOffset(): number;
  65827. /**
  65828. * Returns the number of components per vertex attribute (integer)
  65829. * @returns the size in float
  65830. */
  65831. getSize(): number;
  65832. /**
  65833. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65834. * @returns true if this buffer is instanced
  65835. */
  65836. getIsInstanced(): boolean;
  65837. /**
  65838. * Returns the instancing divisor, zero for non-instanced (integer).
  65839. * @returns a number
  65840. */
  65841. getInstanceDivisor(): number;
  65842. /**
  65843. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65844. * @param data defines the data to store
  65845. */
  65846. create(data?: DataArray): void;
  65847. /**
  65848. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65849. * This function will create a new buffer if the current one is not updatable
  65850. * @param data defines the data to store
  65851. */
  65852. update(data: DataArray): void;
  65853. /**
  65854. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65855. * Returns the directly updated WebGLBuffer.
  65856. * @param data the new data
  65857. * @param offset the new offset
  65858. * @param useBytes set to true if the offset is in bytes
  65859. */
  65860. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65861. /**
  65862. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65863. */
  65864. dispose(): void;
  65865. /**
  65866. * Enumerates each value of this vertex buffer as numbers.
  65867. * @param count the number of values to enumerate
  65868. * @param callback the callback function called for each value
  65869. */
  65870. forEach(count: number, callback: (value: number, index: number) => void): void;
  65871. /**
  65872. * Positions
  65873. */
  65874. static readonly PositionKind: string;
  65875. /**
  65876. * Normals
  65877. */
  65878. static readonly NormalKind: string;
  65879. /**
  65880. * Tangents
  65881. */
  65882. static readonly TangentKind: string;
  65883. /**
  65884. * Texture coordinates
  65885. */
  65886. static readonly UVKind: string;
  65887. /**
  65888. * Texture coordinates 2
  65889. */
  65890. static readonly UV2Kind: string;
  65891. /**
  65892. * Texture coordinates 3
  65893. */
  65894. static readonly UV3Kind: string;
  65895. /**
  65896. * Texture coordinates 4
  65897. */
  65898. static readonly UV4Kind: string;
  65899. /**
  65900. * Texture coordinates 5
  65901. */
  65902. static readonly UV5Kind: string;
  65903. /**
  65904. * Texture coordinates 6
  65905. */
  65906. static readonly UV6Kind: string;
  65907. /**
  65908. * Colors
  65909. */
  65910. static readonly ColorKind: string;
  65911. /**
  65912. * Matrix indices (for bones)
  65913. */
  65914. static readonly MatricesIndicesKind: string;
  65915. /**
  65916. * Matrix weights (for bones)
  65917. */
  65918. static readonly MatricesWeightsKind: string;
  65919. /**
  65920. * Additional matrix indices (for bones)
  65921. */
  65922. static readonly MatricesIndicesExtraKind: string;
  65923. /**
  65924. * Additional matrix weights (for bones)
  65925. */
  65926. static readonly MatricesWeightsExtraKind: string;
  65927. /**
  65928. * Deduces the stride given a kind.
  65929. * @param kind The kind string to deduce
  65930. * @returns The deduced stride
  65931. */
  65932. static DeduceStride(kind: string): number;
  65933. /**
  65934. * Gets the byte length of the given type.
  65935. * @param type the type
  65936. * @returns the number of bytes
  65937. */
  65938. static GetTypeByteLength(type: number): number;
  65939. /**
  65940. * Enumerates each value of the given parameters as numbers.
  65941. * @param data the data to enumerate
  65942. * @param byteOffset the byte offset of the data
  65943. * @param byteStride the byte stride of the data
  65944. * @param componentCount the number of components per element
  65945. * @param componentType the type of the component
  65946. * @param count the number of values to enumerate
  65947. * @param normalized whether the data is normalized
  65948. * @param callback the callback function called for each value
  65949. */
  65950. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65951. private static _GetFloatValue;
  65952. }
  65953. }
  65954. declare module BABYLON {
  65955. /**
  65956. * Scalar computation library
  65957. */
  65958. export class Scalar {
  65959. /**
  65960. * Two pi constants convenient for computation.
  65961. */
  65962. static TwoPi: number;
  65963. /**
  65964. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65965. * @param a number
  65966. * @param b number
  65967. * @param epsilon (default = 1.401298E-45)
  65968. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65969. */
  65970. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  65971. /**
  65972. * Returns a string : the upper case translation of the number i to hexadecimal.
  65973. * @param i number
  65974. * @returns the upper case translation of the number i to hexadecimal.
  65975. */
  65976. static ToHex(i: number): string;
  65977. /**
  65978. * Returns -1 if value is negative and +1 is value is positive.
  65979. * @param value the value
  65980. * @returns the value itself if it's equal to zero.
  65981. */
  65982. static Sign(value: number): number;
  65983. /**
  65984. * Returns the value itself if it's between min and max.
  65985. * Returns min if the value is lower than min.
  65986. * Returns max if the value is greater than max.
  65987. * @param value the value to clmap
  65988. * @param min the min value to clamp to (default: 0)
  65989. * @param max the max value to clamp to (default: 1)
  65990. * @returns the clamped value
  65991. */
  65992. static Clamp(value: number, min?: number, max?: number): number;
  65993. /**
  65994. * the log2 of value.
  65995. * @param value the value to compute log2 of
  65996. * @returns the log2 of value.
  65997. */
  65998. static Log2(value: number): number;
  65999. /**
  66000. * Loops the value, so that it is never larger than length and never smaller than 0.
  66001. *
  66002. * This is similar to the modulo operator but it works with floating point numbers.
  66003. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66004. * With t = 5 and length = 2.5, the result would be 0.0.
  66005. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66006. * @param value the value
  66007. * @param length the length
  66008. * @returns the looped value
  66009. */
  66010. static Repeat(value: number, length: number): number;
  66011. /**
  66012. * Normalize the value between 0.0 and 1.0 using min and max values
  66013. * @param value value to normalize
  66014. * @param min max to normalize between
  66015. * @param max min to normalize between
  66016. * @returns the normalized value
  66017. */
  66018. static Normalize(value: number, min: number, max: number): number;
  66019. /**
  66020. * Denormalize the value from 0.0 and 1.0 using min and max values
  66021. * @param normalized value to denormalize
  66022. * @param min max to denormalize between
  66023. * @param max min to denormalize between
  66024. * @returns the denormalized value
  66025. */
  66026. static Denormalize(normalized: number, min: number, max: number): number;
  66027. /**
  66028. * Calculates the shortest difference between two given angles given in degrees.
  66029. * @param current current angle in degrees
  66030. * @param target target angle in degrees
  66031. * @returns the delta
  66032. */
  66033. static DeltaAngle(current: number, target: number): number;
  66034. /**
  66035. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66036. * @param tx value
  66037. * @param length length
  66038. * @returns The returned value will move back and forth between 0 and length
  66039. */
  66040. static PingPong(tx: number, length: number): number;
  66041. /**
  66042. * Interpolates between min and max with smoothing at the limits.
  66043. *
  66044. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66045. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66046. * @param from from
  66047. * @param to to
  66048. * @param tx value
  66049. * @returns the smooth stepped value
  66050. */
  66051. static SmoothStep(from: number, to: number, tx: number): number;
  66052. /**
  66053. * Moves a value current towards target.
  66054. *
  66055. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66056. * Negative values of maxDelta pushes the value away from target.
  66057. * @param current current value
  66058. * @param target target value
  66059. * @param maxDelta max distance to move
  66060. * @returns resulting value
  66061. */
  66062. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66063. /**
  66064. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66065. *
  66066. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66067. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66068. * @param current current value
  66069. * @param target target value
  66070. * @param maxDelta max distance to move
  66071. * @returns resulting angle
  66072. */
  66073. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66074. /**
  66075. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66076. * @param start start value
  66077. * @param end target value
  66078. * @param amount amount to lerp between
  66079. * @returns the lerped value
  66080. */
  66081. static Lerp(start: number, end: number, amount: number): number;
  66082. /**
  66083. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66084. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66085. * @param start start value
  66086. * @param end target value
  66087. * @param amount amount to lerp between
  66088. * @returns the lerped value
  66089. */
  66090. static LerpAngle(start: number, end: number, amount: number): number;
  66091. /**
  66092. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66093. * @param a start value
  66094. * @param b target value
  66095. * @param value value between a and b
  66096. * @returns the inverseLerp value
  66097. */
  66098. static InverseLerp(a: number, b: number, value: number): number;
  66099. /**
  66100. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66101. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66102. * @param value1 spline value
  66103. * @param tangent1 spline value
  66104. * @param value2 spline value
  66105. * @param tangent2 spline value
  66106. * @param amount input value
  66107. * @returns hermite result
  66108. */
  66109. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66110. /**
  66111. * Returns a random float number between and min and max values
  66112. * @param min min value of random
  66113. * @param max max value of random
  66114. * @returns random value
  66115. */
  66116. static RandomRange(min: number, max: number): number;
  66117. /**
  66118. * This function returns percentage of a number in a given range.
  66119. *
  66120. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66121. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66122. * @param number to convert to percentage
  66123. * @param min min range
  66124. * @param max max range
  66125. * @returns the percentage
  66126. */
  66127. static RangeToPercent(number: number, min: number, max: number): number;
  66128. /**
  66129. * This function returns number that corresponds to the percentage in a given range.
  66130. *
  66131. * PercentToRange(0.34,0,100) will return 34.
  66132. * @param percent to convert to number
  66133. * @param min min range
  66134. * @param max max range
  66135. * @returns the number
  66136. */
  66137. static PercentToRange(percent: number, min: number, max: number): number;
  66138. /**
  66139. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66140. * @param angle The angle to normalize in radian.
  66141. * @return The converted angle.
  66142. */
  66143. static NormalizeRadians(angle: number): number;
  66144. }
  66145. }
  66146. declare module BABYLON {
  66147. /**
  66148. * Constant used to convert a value to gamma space
  66149. * @ignorenaming
  66150. */
  66151. export const ToGammaSpace: number;
  66152. /**
  66153. * Constant used to convert a value to linear space
  66154. * @ignorenaming
  66155. */
  66156. export const ToLinearSpace = 2.2;
  66157. /**
  66158. * Constant used to define the minimal number value in Babylon.js
  66159. * @ignorenaming
  66160. */
  66161. let Epsilon: number;
  66162. }
  66163. declare module BABYLON {
  66164. /**
  66165. * Class used to represent a viewport on screen
  66166. */
  66167. export class Viewport {
  66168. /** viewport left coordinate */
  66169. x: number;
  66170. /** viewport top coordinate */
  66171. y: number;
  66172. /**viewport width */
  66173. width: number;
  66174. /** viewport height */
  66175. height: number;
  66176. /**
  66177. * Creates a Viewport object located at (x, y) and sized (width, height)
  66178. * @param x defines viewport left coordinate
  66179. * @param y defines viewport top coordinate
  66180. * @param width defines the viewport width
  66181. * @param height defines the viewport height
  66182. */
  66183. constructor(
  66184. /** viewport left coordinate */
  66185. x: number,
  66186. /** viewport top coordinate */
  66187. y: number,
  66188. /**viewport width */
  66189. width: number,
  66190. /** viewport height */
  66191. height: number);
  66192. /**
  66193. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66194. * @param renderWidth defines the rendering width
  66195. * @param renderHeight defines the rendering height
  66196. * @returns a new Viewport
  66197. */
  66198. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66199. /**
  66200. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66201. * @param renderWidth defines the rendering width
  66202. * @param renderHeight defines the rendering height
  66203. * @param ref defines the target viewport
  66204. * @returns the current viewport
  66205. */
  66206. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66207. /**
  66208. * Returns a new Viewport copied from the current one
  66209. * @returns a new Viewport
  66210. */
  66211. clone(): Viewport;
  66212. }
  66213. }
  66214. declare module BABYLON {
  66215. /**
  66216. * Class containing a set of static utilities functions for arrays.
  66217. */
  66218. export class ArrayTools {
  66219. /**
  66220. * Returns an array of the given size filled with element built from the given constructor and the paramters
  66221. * @param size the number of element to construct and put in the array
  66222. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  66223. * @returns a new array filled with new objects
  66224. */
  66225. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  66226. }
  66227. }
  66228. declare module BABYLON {
  66229. /**
  66230. * @hidden
  66231. */
  66232. export interface IColor4Like {
  66233. r: float;
  66234. g: float;
  66235. b: float;
  66236. a: float;
  66237. }
  66238. /**
  66239. * @hidden
  66240. */
  66241. export interface IColor3Like {
  66242. r: float;
  66243. g: float;
  66244. b: float;
  66245. }
  66246. /**
  66247. * @hidden
  66248. */
  66249. export interface IVector4Like {
  66250. x: float;
  66251. y: float;
  66252. z: float;
  66253. w: float;
  66254. }
  66255. /**
  66256. * @hidden
  66257. */
  66258. export interface IVector3Like {
  66259. x: float;
  66260. y: float;
  66261. z: float;
  66262. }
  66263. /**
  66264. * @hidden
  66265. */
  66266. export interface IVector2Like {
  66267. x: float;
  66268. y: float;
  66269. }
  66270. /**
  66271. * @hidden
  66272. */
  66273. export interface IMatrixLike {
  66274. toArray(): DeepImmutable<Float32Array>;
  66275. updateFlag: int;
  66276. }
  66277. /**
  66278. * @hidden
  66279. */
  66280. export interface IViewportLike {
  66281. x: float;
  66282. y: float;
  66283. width: float;
  66284. height: float;
  66285. }
  66286. /**
  66287. * @hidden
  66288. */
  66289. export interface IPlaneLike {
  66290. normal: IVector3Like;
  66291. d: float;
  66292. normalize(): void;
  66293. }
  66294. }
  66295. declare module BABYLON {
  66296. /**
  66297. * Class representing a vector containing 2 coordinates
  66298. */
  66299. export class Vector2 {
  66300. /** defines the first coordinate */
  66301. x: number;
  66302. /** defines the second coordinate */
  66303. y: number;
  66304. /**
  66305. * Creates a new Vector2 from the given x and y coordinates
  66306. * @param x defines the first coordinate
  66307. * @param y defines the second coordinate
  66308. */
  66309. constructor(
  66310. /** defines the first coordinate */
  66311. x?: number,
  66312. /** defines the second coordinate */
  66313. y?: number);
  66314. /**
  66315. * Gets a string with the Vector2 coordinates
  66316. * @returns a string with the Vector2 coordinates
  66317. */
  66318. toString(): string;
  66319. /**
  66320. * Gets class name
  66321. * @returns the string "Vector2"
  66322. */
  66323. getClassName(): string;
  66324. /**
  66325. * Gets current vector hash code
  66326. * @returns the Vector2 hash code as a number
  66327. */
  66328. getHashCode(): number;
  66329. /**
  66330. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  66331. * @param array defines the source array
  66332. * @param index defines the offset in source array
  66333. * @returns the current Vector2
  66334. */
  66335. toArray(array: FloatArray, index?: number): Vector2;
  66336. /**
  66337. * Copy the current vector to an array
  66338. * @returns a new array with 2 elements: the Vector2 coordinates.
  66339. */
  66340. asArray(): number[];
  66341. /**
  66342. * Sets the Vector2 coordinates with the given Vector2 coordinates
  66343. * @param source defines the source Vector2
  66344. * @returns the current updated Vector2
  66345. */
  66346. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  66347. /**
  66348. * Sets the Vector2 coordinates with the given floats
  66349. * @param x defines the first coordinate
  66350. * @param y defines the second coordinate
  66351. * @returns the current updated Vector2
  66352. */
  66353. copyFromFloats(x: number, y: number): Vector2;
  66354. /**
  66355. * Sets the Vector2 coordinates with the given floats
  66356. * @param x defines the first coordinate
  66357. * @param y defines the second coordinate
  66358. * @returns the current updated Vector2
  66359. */
  66360. set(x: number, y: number): Vector2;
  66361. /**
  66362. * Add another vector with the current one
  66363. * @param otherVector defines the other vector
  66364. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  66365. */
  66366. add(otherVector: DeepImmutable<Vector2>): Vector2;
  66367. /**
  66368. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  66369. * @param otherVector defines the other vector
  66370. * @param result defines the target vector
  66371. * @returns the unmodified current Vector2
  66372. */
  66373. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66374. /**
  66375. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  66376. * @param otherVector defines the other vector
  66377. * @returns the current updated Vector2
  66378. */
  66379. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66380. /**
  66381. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  66382. * @param otherVector defines the other vector
  66383. * @returns a new Vector2
  66384. */
  66385. addVector3(otherVector: Vector3): Vector2;
  66386. /**
  66387. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  66388. * @param otherVector defines the other vector
  66389. * @returns a new Vector2
  66390. */
  66391. subtract(otherVector: Vector2): Vector2;
  66392. /**
  66393. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  66394. * @param otherVector defines the other vector
  66395. * @param result defines the target vector
  66396. * @returns the unmodified current Vector2
  66397. */
  66398. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66399. /**
  66400. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  66401. * @param otherVector defines the other vector
  66402. * @returns the current updated Vector2
  66403. */
  66404. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66405. /**
  66406. * Multiplies in place the current Vector2 coordinates by the given ones
  66407. * @param otherVector defines the other vector
  66408. * @returns the current updated Vector2
  66409. */
  66410. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66411. /**
  66412. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  66413. * @param otherVector defines the other vector
  66414. * @returns a new Vector2
  66415. */
  66416. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  66417. /**
  66418. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  66419. * @param otherVector defines the other vector
  66420. * @param result defines the target vector
  66421. * @returns the unmodified current Vector2
  66422. */
  66423. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66424. /**
  66425. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  66426. * @param x defines the first coordinate
  66427. * @param y defines the second coordinate
  66428. * @returns a new Vector2
  66429. */
  66430. multiplyByFloats(x: number, y: number): Vector2;
  66431. /**
  66432. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  66433. * @param otherVector defines the other vector
  66434. * @returns a new Vector2
  66435. */
  66436. divide(otherVector: Vector2): Vector2;
  66437. /**
  66438. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  66439. * @param otherVector defines the other vector
  66440. * @param result defines the target vector
  66441. * @returns the unmodified current Vector2
  66442. */
  66443. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66444. /**
  66445. * Divides the current Vector2 coordinates by the given ones
  66446. * @param otherVector defines the other vector
  66447. * @returns the current updated Vector2
  66448. */
  66449. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66450. /**
  66451. * Gets a new Vector2 with current Vector2 negated coordinates
  66452. * @returns a new Vector2
  66453. */
  66454. negate(): Vector2;
  66455. /**
  66456. * Multiply the Vector2 coordinates by scale
  66457. * @param scale defines the scaling factor
  66458. * @returns the current updated Vector2
  66459. */
  66460. scaleInPlace(scale: number): Vector2;
  66461. /**
  66462. * Returns a new Vector2 scaled by "scale" from the current Vector2
  66463. * @param scale defines the scaling factor
  66464. * @returns a new Vector2
  66465. */
  66466. scale(scale: number): Vector2;
  66467. /**
  66468. * Scale the current Vector2 values by a factor to a given Vector2
  66469. * @param scale defines the scale factor
  66470. * @param result defines the Vector2 object where to store the result
  66471. * @returns the unmodified current Vector2
  66472. */
  66473. scaleToRef(scale: number, result: Vector2): Vector2;
  66474. /**
  66475. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  66476. * @param scale defines the scale factor
  66477. * @param result defines the Vector2 object where to store the result
  66478. * @returns the unmodified current Vector2
  66479. */
  66480. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  66481. /**
  66482. * Gets a boolean if two vectors are equals
  66483. * @param otherVector defines the other vector
  66484. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  66485. */
  66486. equals(otherVector: DeepImmutable<Vector2>): boolean;
  66487. /**
  66488. * Gets a boolean if two vectors are equals (using an epsilon value)
  66489. * @param otherVector defines the other vector
  66490. * @param epsilon defines the minimal distance to consider equality
  66491. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  66492. */
  66493. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  66494. /**
  66495. * Gets a new Vector2 from current Vector2 floored values
  66496. * @returns a new Vector2
  66497. */
  66498. floor(): Vector2;
  66499. /**
  66500. * Gets a new Vector2 from current Vector2 floored values
  66501. * @returns a new Vector2
  66502. */
  66503. fract(): Vector2;
  66504. /**
  66505. * Gets the length of the vector
  66506. * @returns the vector length (float)
  66507. */
  66508. length(): number;
  66509. /**
  66510. * Gets the vector squared length
  66511. * @returns the vector squared length (float)
  66512. */
  66513. lengthSquared(): number;
  66514. /**
  66515. * Normalize the vector
  66516. * @returns the current updated Vector2
  66517. */
  66518. normalize(): Vector2;
  66519. /**
  66520. * Gets a new Vector2 copied from the Vector2
  66521. * @returns a new Vector2
  66522. */
  66523. clone(): Vector2;
  66524. /**
  66525. * Gets a new Vector2(0, 0)
  66526. * @returns a new Vector2
  66527. */
  66528. static Zero(): Vector2;
  66529. /**
  66530. * Gets a new Vector2(1, 1)
  66531. * @returns a new Vector2
  66532. */
  66533. static One(): Vector2;
  66534. /**
  66535. * Gets a new Vector2 set from the given index element of the given array
  66536. * @param array defines the data source
  66537. * @param offset defines the offset in the data source
  66538. * @returns a new Vector2
  66539. */
  66540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  66541. /**
  66542. * Sets "result" from the given index element of the given array
  66543. * @param array defines the data source
  66544. * @param offset defines the offset in the data source
  66545. * @param result defines the target vector
  66546. */
  66547. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  66548. /**
  66549. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  66550. * @param value1 defines 1st point of control
  66551. * @param value2 defines 2nd point of control
  66552. * @param value3 defines 3rd point of control
  66553. * @param value4 defines 4th point of control
  66554. * @param amount defines the interpolation factor
  66555. * @returns a new Vector2
  66556. */
  66557. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  66558. /**
  66559. * 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".
  66560. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  66561. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  66562. * @param value defines the value to clamp
  66563. * @param min defines the lower limit
  66564. * @param max defines the upper limit
  66565. * @returns a new Vector2
  66566. */
  66567. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  66568. /**
  66569. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  66570. * @param value1 defines the 1st control point
  66571. * @param tangent1 defines the outgoing tangent
  66572. * @param value2 defines the 2nd control point
  66573. * @param tangent2 defines the incoming tangent
  66574. * @param amount defines the interpolation factor
  66575. * @returns a new Vector2
  66576. */
  66577. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  66578. /**
  66579. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  66580. * @param start defines the start vector
  66581. * @param end defines the end vector
  66582. * @param amount defines the interpolation factor
  66583. * @returns a new Vector2
  66584. */
  66585. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  66586. /**
  66587. * Gets the dot product of the vector "left" and the vector "right"
  66588. * @param left defines first vector
  66589. * @param right defines second vector
  66590. * @returns the dot product (float)
  66591. */
  66592. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  66593. /**
  66594. * Returns a new Vector2 equal to the normalized given vector
  66595. * @param vector defines the vector to normalize
  66596. * @returns a new Vector2
  66597. */
  66598. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  66599. /**
  66600. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  66601. * @param left defines 1st vector
  66602. * @param right defines 2nd vector
  66603. * @returns a new Vector2
  66604. */
  66605. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66606. /**
  66607. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  66608. * @param left defines 1st vector
  66609. * @param right defines 2nd vector
  66610. * @returns a new Vector2
  66611. */
  66612. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66613. /**
  66614. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  66615. * @param vector defines the vector to transform
  66616. * @param transformation defines the matrix to apply
  66617. * @returns a new Vector2
  66618. */
  66619. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  66620. /**
  66621. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  66622. * @param vector defines the vector to transform
  66623. * @param transformation defines the matrix to apply
  66624. * @param result defines the target vector
  66625. */
  66626. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  66627. /**
  66628. * Determines if a given vector is included in a triangle
  66629. * @param p defines the vector to test
  66630. * @param p0 defines 1st triangle point
  66631. * @param p1 defines 2nd triangle point
  66632. * @param p2 defines 3rd triangle point
  66633. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  66634. */
  66635. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  66636. /**
  66637. * Gets the distance between the vectors "value1" and "value2"
  66638. * @param value1 defines first vector
  66639. * @param value2 defines second vector
  66640. * @returns the distance between vectors
  66641. */
  66642. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66643. /**
  66644. * Returns the squared distance between the vectors "value1" and "value2"
  66645. * @param value1 defines first vector
  66646. * @param value2 defines second vector
  66647. * @returns the squared distance between vectors
  66648. */
  66649. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66650. /**
  66651. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  66652. * @param value1 defines first vector
  66653. * @param value2 defines second vector
  66654. * @returns a new Vector2
  66655. */
  66656. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  66657. /**
  66658. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  66659. * @param p defines the middle point
  66660. * @param segA defines one point of the segment
  66661. * @param segB defines the other point of the segment
  66662. * @returns the shortest distance
  66663. */
  66664. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  66665. }
  66666. /**
  66667. * Classed used to store (x,y,z) vector representation
  66668. * A Vector3 is the main object used in 3D geometry
  66669. * It can represent etiher the coordinates of a point the space, either a direction
  66670. * Reminder: js uses a left handed forward facing system
  66671. */
  66672. export class Vector3 {
  66673. /**
  66674. * Defines the first coordinates (on X axis)
  66675. */
  66676. x: number;
  66677. /**
  66678. * Defines the second coordinates (on Y axis)
  66679. */
  66680. y: number;
  66681. /**
  66682. * Defines the third coordinates (on Z axis)
  66683. */
  66684. z: number;
  66685. private static _UpReadOnly;
  66686. private static _ZeroReadOnly;
  66687. /**
  66688. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  66689. * @param x defines the first coordinates (on X axis)
  66690. * @param y defines the second coordinates (on Y axis)
  66691. * @param z defines the third coordinates (on Z axis)
  66692. */
  66693. constructor(
  66694. /**
  66695. * Defines the first coordinates (on X axis)
  66696. */
  66697. x?: number,
  66698. /**
  66699. * Defines the second coordinates (on Y axis)
  66700. */
  66701. y?: number,
  66702. /**
  66703. * Defines the third coordinates (on Z axis)
  66704. */
  66705. z?: number);
  66706. /**
  66707. * Creates a string representation of the Vector3
  66708. * @returns a string with the Vector3 coordinates.
  66709. */
  66710. toString(): string;
  66711. /**
  66712. * Gets the class name
  66713. * @returns the string "Vector3"
  66714. */
  66715. getClassName(): string;
  66716. /**
  66717. * Creates the Vector3 hash code
  66718. * @returns a number which tends to be unique between Vector3 instances
  66719. */
  66720. getHashCode(): number;
  66721. /**
  66722. * Creates an array containing three elements : the coordinates of the Vector3
  66723. * @returns a new array of numbers
  66724. */
  66725. asArray(): number[];
  66726. /**
  66727. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66728. * @param array defines the destination array
  66729. * @param index defines the offset in the destination array
  66730. * @returns the current Vector3
  66731. */
  66732. toArray(array: FloatArray, index?: number): Vector3;
  66733. /**
  66734. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66735. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66736. */
  66737. toQuaternion(): Quaternion;
  66738. /**
  66739. * Adds the given vector to the current Vector3
  66740. * @param otherVector defines the second operand
  66741. * @returns the current updated Vector3
  66742. */
  66743. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66744. /**
  66745. * Adds the given coordinates to the current Vector3
  66746. * @param x defines the x coordinate of the operand
  66747. * @param y defines the y coordinate of the operand
  66748. * @param z defines the z coordinate of the operand
  66749. * @returns the current updated Vector3
  66750. */
  66751. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66752. /**
  66753. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66754. * @param otherVector defines the second operand
  66755. * @returns the resulting Vector3
  66756. */
  66757. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66758. /**
  66759. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66760. * @param otherVector defines the second operand
  66761. * @param result defines the Vector3 object where to store the result
  66762. * @returns the current Vector3
  66763. */
  66764. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66765. /**
  66766. * Subtract the given vector from the current Vector3
  66767. * @param otherVector defines the second operand
  66768. * @returns the current updated Vector3
  66769. */
  66770. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66771. /**
  66772. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66773. * @param otherVector defines the second operand
  66774. * @returns the resulting Vector3
  66775. */
  66776. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66777. /**
  66778. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66779. * @param otherVector defines the second operand
  66780. * @param result defines the Vector3 object where to store the result
  66781. * @returns the current Vector3
  66782. */
  66783. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66784. /**
  66785. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66786. * @param x defines the x coordinate of the operand
  66787. * @param y defines the y coordinate of the operand
  66788. * @param z defines the z coordinate of the operand
  66789. * @returns the resulting Vector3
  66790. */
  66791. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66792. /**
  66793. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66794. * @param x defines the x coordinate of the operand
  66795. * @param y defines the y coordinate of the operand
  66796. * @param z defines the z coordinate of the operand
  66797. * @param result defines the Vector3 object where to store the result
  66798. * @returns the current Vector3
  66799. */
  66800. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66801. /**
  66802. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66803. * @returns a new Vector3
  66804. */
  66805. negate(): Vector3;
  66806. /**
  66807. * Multiplies the Vector3 coordinates by the float "scale"
  66808. * @param scale defines the multiplier factor
  66809. * @returns the current updated Vector3
  66810. */
  66811. scaleInPlace(scale: number): Vector3;
  66812. /**
  66813. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66814. * @param scale defines the multiplier factor
  66815. * @returns a new Vector3
  66816. */
  66817. scale(scale: number): Vector3;
  66818. /**
  66819. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66820. * @param scale defines the multiplier factor
  66821. * @param result defines the Vector3 object where to store the result
  66822. * @returns the current Vector3
  66823. */
  66824. scaleToRef(scale: number, result: Vector3): Vector3;
  66825. /**
  66826. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66827. * @param scale defines the scale factor
  66828. * @param result defines the Vector3 object where to store the result
  66829. * @returns the unmodified current Vector3
  66830. */
  66831. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66832. /**
  66833. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66834. * @param otherVector defines the second operand
  66835. * @returns true if both vectors are equals
  66836. */
  66837. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66838. /**
  66839. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66840. * @param otherVector defines the second operand
  66841. * @param epsilon defines the minimal distance to define values as equals
  66842. * @returns true if both vectors are distant less than epsilon
  66843. */
  66844. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66845. /**
  66846. * Returns true if the current Vector3 coordinates equals the given floats
  66847. * @param x defines the x coordinate of the operand
  66848. * @param y defines the y coordinate of the operand
  66849. * @param z defines the z coordinate of the operand
  66850. * @returns true if both vectors are equals
  66851. */
  66852. equalsToFloats(x: number, y: number, z: number): boolean;
  66853. /**
  66854. * Multiplies the current Vector3 coordinates by the given ones
  66855. * @param otherVector defines the second operand
  66856. * @returns the current updated Vector3
  66857. */
  66858. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66859. /**
  66860. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  66861. * @param otherVector defines the second operand
  66862. * @returns the new Vector3
  66863. */
  66864. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  66865. /**
  66866. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  66867. * @param otherVector defines the second operand
  66868. * @param result defines the Vector3 object where to store the result
  66869. * @returns the current Vector3
  66870. */
  66871. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66872. /**
  66873. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  66874. * @param x defines the x coordinate of the operand
  66875. * @param y defines the y coordinate of the operand
  66876. * @param z defines the z coordinate of the operand
  66877. * @returns the new Vector3
  66878. */
  66879. multiplyByFloats(x: number, y: number, z: number): Vector3;
  66880. /**
  66881. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  66882. * @param otherVector defines the second operand
  66883. * @returns the new Vector3
  66884. */
  66885. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  66886. /**
  66887. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  66888. * @param otherVector defines the second operand
  66889. * @param result defines the Vector3 object where to store the result
  66890. * @returns the current Vector3
  66891. */
  66892. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66893. /**
  66894. * Divides the current Vector3 coordinates by the given ones.
  66895. * @param otherVector defines the second operand
  66896. * @returns the current updated Vector3
  66897. */
  66898. divideInPlace(otherVector: Vector3): Vector3;
  66899. /**
  66900. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  66901. * @param other defines the second operand
  66902. * @returns the current updated Vector3
  66903. */
  66904. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66905. /**
  66906. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  66907. * @param other defines the second operand
  66908. * @returns the current updated Vector3
  66909. */
  66910. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66911. /**
  66912. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  66913. * @param x defines the x coordinate of the operand
  66914. * @param y defines the y coordinate of the operand
  66915. * @param z defines the z coordinate of the operand
  66916. * @returns the current updated Vector3
  66917. */
  66918. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66919. /**
  66920. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  66921. * @param x defines the x coordinate of the operand
  66922. * @param y defines the y coordinate of the operand
  66923. * @param z defines the z coordinate of the operand
  66924. * @returns the current updated Vector3
  66925. */
  66926. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66927. /**
  66928. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  66929. * Check if is non uniform within a certain amount of decimal places to account for this
  66930. * @param epsilon the amount the values can differ
  66931. * @returns if the the vector is non uniform to a certain number of decimal places
  66932. */
  66933. isNonUniformWithinEpsilon(epsilon: number): boolean;
  66934. /**
  66935. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  66936. */
  66937. readonly isNonUniform: boolean;
  66938. /**
  66939. * Gets a new Vector3 from current Vector3 floored values
  66940. * @returns a new Vector3
  66941. */
  66942. floor(): Vector3;
  66943. /**
  66944. * Gets a new Vector3 from current Vector3 floored values
  66945. * @returns a new Vector3
  66946. */
  66947. fract(): Vector3;
  66948. /**
  66949. * Gets the length of the Vector3
  66950. * @returns the length of the Vector3
  66951. */
  66952. length(): number;
  66953. /**
  66954. * Gets the squared length of the Vector3
  66955. * @returns squared length of the Vector3
  66956. */
  66957. lengthSquared(): number;
  66958. /**
  66959. * Normalize the current Vector3.
  66960. * Please note that this is an in place operation.
  66961. * @returns the current updated Vector3
  66962. */
  66963. normalize(): Vector3;
  66964. /**
  66965. * Reorders the x y z properties of the vector in place
  66966. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  66967. * @returns the current updated vector
  66968. */
  66969. reorderInPlace(order: string): this;
  66970. /**
  66971. * Rotates the vector around 0,0,0 by a quaternion
  66972. * @param quaternion the rotation quaternion
  66973. * @param result vector to store the result
  66974. * @returns the resulting vector
  66975. */
  66976. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  66977. /**
  66978. * Rotates a vector around a given point
  66979. * @param quaternion the rotation quaternion
  66980. * @param point the point to rotate around
  66981. * @param result vector to store the result
  66982. * @returns the resulting vector
  66983. */
  66984. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  66985. /**
  66986. * Normalize the current Vector3 with the given input length.
  66987. * Please note that this is an in place operation.
  66988. * @param len the length of the vector
  66989. * @returns the current updated Vector3
  66990. */
  66991. normalizeFromLength(len: number): Vector3;
  66992. /**
  66993. * Normalize the current Vector3 to a new vector
  66994. * @returns the new Vector3
  66995. */
  66996. normalizeToNew(): Vector3;
  66997. /**
  66998. * Normalize the current Vector3 to the reference
  66999. * @param reference define the Vector3 to update
  67000. * @returns the updated Vector3
  67001. */
  67002. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67003. /**
  67004. * Creates a new Vector3 copied from the current Vector3
  67005. * @returns the new Vector3
  67006. */
  67007. clone(): Vector3;
  67008. /**
  67009. * Copies the given vector coordinates to the current Vector3 ones
  67010. * @param source defines the source Vector3
  67011. * @returns the current updated Vector3
  67012. */
  67013. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67014. /**
  67015. * Copies the given floats to the current Vector3 coordinates
  67016. * @param x defines the x coordinate of the operand
  67017. * @param y defines the y coordinate of the operand
  67018. * @param z defines the z coordinate of the operand
  67019. * @returns the current updated Vector3
  67020. */
  67021. copyFromFloats(x: number, y: number, z: number): Vector3;
  67022. /**
  67023. * Copies the given floats to the current Vector3 coordinates
  67024. * @param x defines the x coordinate of the operand
  67025. * @param y defines the y coordinate of the operand
  67026. * @param z defines the z coordinate of the operand
  67027. * @returns the current updated Vector3
  67028. */
  67029. set(x: number, y: number, z: number): Vector3;
  67030. /**
  67031. * Copies the given float to the current Vector3 coordinates
  67032. * @param v defines the x, y and z coordinates of the operand
  67033. * @returns the current updated Vector3
  67034. */
  67035. setAll(v: number): Vector3;
  67036. /**
  67037. * Get the clip factor between two vectors
  67038. * @param vector0 defines the first operand
  67039. * @param vector1 defines the second operand
  67040. * @param axis defines the axis to use
  67041. * @param size defines the size along the axis
  67042. * @returns the clip factor
  67043. */
  67044. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67045. /**
  67046. * Get angle between two vectors
  67047. * @param vector0 angle between vector0 and vector1
  67048. * @param vector1 angle between vector0 and vector1
  67049. * @param normal direction of the normal
  67050. * @return the angle between vector0 and vector1
  67051. */
  67052. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67053. /**
  67054. * Returns a new Vector3 set from the index "offset" of the given array
  67055. * @param array defines the source array
  67056. * @param offset defines the offset in the source array
  67057. * @returns the new Vector3
  67058. */
  67059. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67060. /**
  67061. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67062. * This function is deprecated. Use FromArray instead
  67063. * @param array defines the source array
  67064. * @param offset defines the offset in the source array
  67065. * @returns the new Vector3
  67066. */
  67067. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67068. /**
  67069. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67070. * @param array defines the source array
  67071. * @param offset defines the offset in the source array
  67072. * @param result defines the Vector3 where to store the result
  67073. */
  67074. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67075. /**
  67076. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67077. * This function is deprecated. Use FromArrayToRef instead.
  67078. * @param array defines the source array
  67079. * @param offset defines the offset in the source array
  67080. * @param result defines the Vector3 where to store the result
  67081. */
  67082. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67083. /**
  67084. * Sets the given vector "result" with the given floats.
  67085. * @param x defines the x coordinate of the source
  67086. * @param y defines the y coordinate of the source
  67087. * @param z defines the z coordinate of the source
  67088. * @param result defines the Vector3 where to store the result
  67089. */
  67090. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67091. /**
  67092. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67093. * @returns a new empty Vector3
  67094. */
  67095. static Zero(): Vector3;
  67096. /**
  67097. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67098. * @returns a new unit Vector3
  67099. */
  67100. static One(): Vector3;
  67101. /**
  67102. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67103. * @returns a new up Vector3
  67104. */
  67105. static Up(): Vector3;
  67106. /**
  67107. * Gets a up Vector3 that must not be updated
  67108. */
  67109. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67110. /**
  67111. * Gets a zero Vector3 that must not be updated
  67112. */
  67113. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67114. /**
  67115. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67116. * @returns a new down Vector3
  67117. */
  67118. static Down(): Vector3;
  67119. /**
  67120. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67121. * @returns a new forward Vector3
  67122. */
  67123. static Forward(): Vector3;
  67124. /**
  67125. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67126. * @returns a new forward Vector3
  67127. */
  67128. static Backward(): Vector3;
  67129. /**
  67130. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67131. * @returns a new right Vector3
  67132. */
  67133. static Right(): Vector3;
  67134. /**
  67135. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67136. * @returns a new left Vector3
  67137. */
  67138. static Left(): Vector3;
  67139. /**
  67140. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67141. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67142. * @param vector defines the Vector3 to transform
  67143. * @param transformation defines the transformation matrix
  67144. * @returns the transformed Vector3
  67145. */
  67146. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67147. /**
  67148. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  67149. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67150. * @param vector defines the Vector3 to transform
  67151. * @param transformation defines the transformation matrix
  67152. * @param result defines the Vector3 where to store the result
  67153. */
  67154. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67155. /**
  67156. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  67157. * This method computes tranformed coordinates only, not transformed direction vectors
  67158. * @param x define the x coordinate of the source vector
  67159. * @param y define the y coordinate of the source vector
  67160. * @param z define the z coordinate of the source vector
  67161. * @param transformation defines the transformation matrix
  67162. * @param result defines the Vector3 where to store the result
  67163. */
  67164. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67165. /**
  67166. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  67167. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67168. * @param vector defines the Vector3 to transform
  67169. * @param transformation defines the transformation matrix
  67170. * @returns the new Vector3
  67171. */
  67172. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67173. /**
  67174. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  67175. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67176. * @param vector defines the Vector3 to transform
  67177. * @param transformation defines the transformation matrix
  67178. * @param result defines the Vector3 where to store the result
  67179. */
  67180. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67181. /**
  67182. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  67183. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67184. * @param x define the x coordinate of the source vector
  67185. * @param y define the y coordinate of the source vector
  67186. * @param z define the z coordinate of the source vector
  67187. * @param transformation defines the transformation matrix
  67188. * @param result defines the Vector3 where to store the result
  67189. */
  67190. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67191. /**
  67192. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  67193. * @param value1 defines the first control point
  67194. * @param value2 defines the second control point
  67195. * @param value3 defines the third control point
  67196. * @param value4 defines the fourth control point
  67197. * @param amount defines the amount on the spline to use
  67198. * @returns the new Vector3
  67199. */
  67200. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  67201. /**
  67202. * 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"
  67203. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67204. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67205. * @param value defines the current value
  67206. * @param min defines the lower range value
  67207. * @param max defines the upper range value
  67208. * @returns the new Vector3
  67209. */
  67210. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  67211. /**
  67212. * 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"
  67213. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67214. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67215. * @param value defines the current value
  67216. * @param min defines the lower range value
  67217. * @param max defines the upper range value
  67218. * @param result defines the Vector3 where to store the result
  67219. */
  67220. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  67221. /**
  67222. * Checks if a given vector is inside a specific range
  67223. * @param v defines the vector to test
  67224. * @param min defines the minimum range
  67225. * @param max defines the maximum range
  67226. */
  67227. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  67228. /**
  67229. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  67230. * @param value1 defines the first control point
  67231. * @param tangent1 defines the first tangent vector
  67232. * @param value2 defines the second control point
  67233. * @param tangent2 defines the second tangent vector
  67234. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  67235. * @returns the new Vector3
  67236. */
  67237. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  67238. /**
  67239. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  67240. * @param start defines the start value
  67241. * @param end defines the end value
  67242. * @param amount max defines amount between both (between 0 and 1)
  67243. * @returns the new Vector3
  67244. */
  67245. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  67246. /**
  67247. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  67248. * @param start defines the start value
  67249. * @param end defines the end value
  67250. * @param amount max defines amount between both (between 0 and 1)
  67251. * @param result defines the Vector3 where to store the result
  67252. */
  67253. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  67254. /**
  67255. * Returns the dot product (float) between the vectors "left" and "right"
  67256. * @param left defines the left operand
  67257. * @param right defines the right operand
  67258. * @returns the dot product
  67259. */
  67260. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  67261. /**
  67262. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  67263. * The cross product is then orthogonal to both "left" and "right"
  67264. * @param left defines the left operand
  67265. * @param right defines the right operand
  67266. * @returns the cross product
  67267. */
  67268. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67269. /**
  67270. * Sets the given vector "result" with the cross product of "left" and "right"
  67271. * The cross product is then orthogonal to both "left" and "right"
  67272. * @param left defines the left operand
  67273. * @param right defines the right operand
  67274. * @param result defines the Vector3 where to store the result
  67275. */
  67276. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  67277. /**
  67278. * Returns a new Vector3 as the normalization of the given vector
  67279. * @param vector defines the Vector3 to normalize
  67280. * @returns the new Vector3
  67281. */
  67282. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  67283. /**
  67284. * Sets the given vector "result" with the normalization of the given first vector
  67285. * @param vector defines the Vector3 to normalize
  67286. * @param result defines the Vector3 where to store the result
  67287. */
  67288. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  67289. /**
  67290. * Project a Vector3 onto screen space
  67291. * @param vector defines the Vector3 to project
  67292. * @param world defines the world matrix to use
  67293. * @param transform defines the transform (view x projection) matrix to use
  67294. * @param viewport defines the screen viewport to use
  67295. * @returns the new Vector3
  67296. */
  67297. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  67298. /** @hidden */
  67299. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  67300. /**
  67301. * Unproject from screen space to object space
  67302. * @param source defines the screen space Vector3 to use
  67303. * @param viewportWidth defines the current width of the viewport
  67304. * @param viewportHeight defines the current height of the viewport
  67305. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67306. * @param transform defines the transform (view x projection) matrix to use
  67307. * @returns the new Vector3
  67308. */
  67309. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  67310. /**
  67311. * Unproject from screen space to object space
  67312. * @param source defines the screen space Vector3 to use
  67313. * @param viewportWidth defines the current width of the viewport
  67314. * @param viewportHeight defines the current height of the viewport
  67315. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67316. * @param view defines the view matrix to use
  67317. * @param projection defines the projection matrix to use
  67318. * @returns the new Vector3
  67319. */
  67320. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  67321. /**
  67322. * Unproject from screen space to object space
  67323. * @param source defines the screen space Vector3 to use
  67324. * @param viewportWidth defines the current width of the viewport
  67325. * @param viewportHeight defines the current height of the viewport
  67326. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67327. * @param view defines the view matrix to use
  67328. * @param projection defines the projection matrix to use
  67329. * @param result defines the Vector3 where to store the result
  67330. */
  67331. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67332. /**
  67333. * Unproject from screen space to object space
  67334. * @param sourceX defines the screen space x coordinate to use
  67335. * @param sourceY defines the screen space y coordinate to use
  67336. * @param sourceZ defines the screen space z coordinate to use
  67337. * @param viewportWidth defines the current width of the viewport
  67338. * @param viewportHeight defines the current height of the viewport
  67339. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67340. * @param view defines the view matrix to use
  67341. * @param projection defines the projection matrix to use
  67342. * @param result defines the Vector3 where to store the result
  67343. */
  67344. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67345. /**
  67346. * Gets the minimal coordinate values between two Vector3
  67347. * @param left defines the first operand
  67348. * @param right defines the second operand
  67349. * @returns the new Vector3
  67350. */
  67351. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67352. /**
  67353. * Gets the maximal coordinate values between two Vector3
  67354. * @param left defines the first operand
  67355. * @param right defines the second operand
  67356. * @returns the new Vector3
  67357. */
  67358. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67359. /**
  67360. * Returns the distance between the vectors "value1" and "value2"
  67361. * @param value1 defines the first operand
  67362. * @param value2 defines the second operand
  67363. * @returns the distance
  67364. */
  67365. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67366. /**
  67367. * Returns the squared distance between the vectors "value1" and "value2"
  67368. * @param value1 defines the first operand
  67369. * @param value2 defines the second operand
  67370. * @returns the squared distance
  67371. */
  67372. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67373. /**
  67374. * Returns a new Vector3 located at the center between "value1" and "value2"
  67375. * @param value1 defines the first operand
  67376. * @param value2 defines the second operand
  67377. * @returns the new Vector3
  67378. */
  67379. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  67380. /**
  67381. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  67382. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  67383. * to something in order to rotate it from its local system to the given target system
  67384. * Note: axis1, axis2 and axis3 are normalized during this operation
  67385. * @param axis1 defines the first axis
  67386. * @param axis2 defines the second axis
  67387. * @param axis3 defines the third axis
  67388. * @returns a new Vector3
  67389. */
  67390. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  67391. /**
  67392. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  67393. * @param axis1 defines the first axis
  67394. * @param axis2 defines the second axis
  67395. * @param axis3 defines the third axis
  67396. * @param ref defines the Vector3 where to store the result
  67397. */
  67398. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  67399. }
  67400. /**
  67401. * Vector4 class created for EulerAngle class conversion to Quaternion
  67402. */
  67403. export class Vector4 {
  67404. /** x value of the vector */
  67405. x: number;
  67406. /** y value of the vector */
  67407. y: number;
  67408. /** z value of the vector */
  67409. z: number;
  67410. /** w value of the vector */
  67411. w: number;
  67412. /**
  67413. * Creates a Vector4 object from the given floats.
  67414. * @param x x value of the vector
  67415. * @param y y value of the vector
  67416. * @param z z value of the vector
  67417. * @param w w value of the vector
  67418. */
  67419. constructor(
  67420. /** x value of the vector */
  67421. x: number,
  67422. /** y value of the vector */
  67423. y: number,
  67424. /** z value of the vector */
  67425. z: number,
  67426. /** w value of the vector */
  67427. w: number);
  67428. /**
  67429. * Returns the string with the Vector4 coordinates.
  67430. * @returns a string containing all the vector values
  67431. */
  67432. toString(): string;
  67433. /**
  67434. * Returns the string "Vector4".
  67435. * @returns "Vector4"
  67436. */
  67437. getClassName(): string;
  67438. /**
  67439. * Returns the Vector4 hash code.
  67440. * @returns a unique hash code
  67441. */
  67442. getHashCode(): number;
  67443. /**
  67444. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  67445. * @returns the resulting array
  67446. */
  67447. asArray(): number[];
  67448. /**
  67449. * Populates the given array from the given index with the Vector4 coordinates.
  67450. * @param array array to populate
  67451. * @param index index of the array to start at (default: 0)
  67452. * @returns the Vector4.
  67453. */
  67454. toArray(array: FloatArray, index?: number): Vector4;
  67455. /**
  67456. * Adds the given vector to the current Vector4.
  67457. * @param otherVector the vector to add
  67458. * @returns the updated Vector4.
  67459. */
  67460. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67461. /**
  67462. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  67463. * @param otherVector the vector to add
  67464. * @returns the resulting vector
  67465. */
  67466. add(otherVector: DeepImmutable<Vector4>): Vector4;
  67467. /**
  67468. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  67469. * @param otherVector the vector to add
  67470. * @param result the vector to store the result
  67471. * @returns the current Vector4.
  67472. */
  67473. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67474. /**
  67475. * Subtract in place the given vector from the current Vector4.
  67476. * @param otherVector the vector to subtract
  67477. * @returns the updated Vector4.
  67478. */
  67479. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67480. /**
  67481. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  67482. * @param otherVector the vector to add
  67483. * @returns the new vector with the result
  67484. */
  67485. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  67486. /**
  67487. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  67488. * @param otherVector the vector to subtract
  67489. * @param result the vector to store the result
  67490. * @returns the current Vector4.
  67491. */
  67492. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67493. /**
  67494. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67495. */
  67496. /**
  67497. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67498. * @param x value to subtract
  67499. * @param y value to subtract
  67500. * @param z value to subtract
  67501. * @param w value to subtract
  67502. * @returns new vector containing the result
  67503. */
  67504. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67505. /**
  67506. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67507. * @param x value to subtract
  67508. * @param y value to subtract
  67509. * @param z value to subtract
  67510. * @param w value to subtract
  67511. * @param result the vector to store the result in
  67512. * @returns the current Vector4.
  67513. */
  67514. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  67515. /**
  67516. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  67517. * @returns a new vector with the negated values
  67518. */
  67519. negate(): Vector4;
  67520. /**
  67521. * Multiplies the current Vector4 coordinates by scale (float).
  67522. * @param scale the number to scale with
  67523. * @returns the updated Vector4.
  67524. */
  67525. scaleInPlace(scale: number): Vector4;
  67526. /**
  67527. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  67528. * @param scale the number to scale with
  67529. * @returns a new vector with the result
  67530. */
  67531. scale(scale: number): Vector4;
  67532. /**
  67533. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  67534. * @param scale the number to scale with
  67535. * @param result a vector to store the result in
  67536. * @returns the current Vector4.
  67537. */
  67538. scaleToRef(scale: number, result: Vector4): Vector4;
  67539. /**
  67540. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  67541. * @param scale defines the scale factor
  67542. * @param result defines the Vector4 object where to store the result
  67543. * @returns the unmodified current Vector4
  67544. */
  67545. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  67546. /**
  67547. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  67548. * @param otherVector the vector to compare against
  67549. * @returns true if they are equal
  67550. */
  67551. equals(otherVector: DeepImmutable<Vector4>): boolean;
  67552. /**
  67553. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  67554. * @param otherVector vector to compare against
  67555. * @param epsilon (Default: very small number)
  67556. * @returns true if they are equal
  67557. */
  67558. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  67559. /**
  67560. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  67561. * @param x x value to compare against
  67562. * @param y y value to compare against
  67563. * @param z z value to compare against
  67564. * @param w w value to compare against
  67565. * @returns true if equal
  67566. */
  67567. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  67568. /**
  67569. * Multiplies in place the current Vector4 by the given one.
  67570. * @param otherVector vector to multiple with
  67571. * @returns the updated Vector4.
  67572. */
  67573. multiplyInPlace(otherVector: Vector4): Vector4;
  67574. /**
  67575. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  67576. * @param otherVector vector to multiple with
  67577. * @returns resulting new vector
  67578. */
  67579. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  67580. /**
  67581. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  67582. * @param otherVector vector to multiple with
  67583. * @param result vector to store the result
  67584. * @returns the current Vector4.
  67585. */
  67586. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67587. /**
  67588. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  67589. * @param x x value multiply with
  67590. * @param y y value multiply with
  67591. * @param z z value multiply with
  67592. * @param w w value multiply with
  67593. * @returns resulting new vector
  67594. */
  67595. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  67596. /**
  67597. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  67598. * @param otherVector vector to devide with
  67599. * @returns resulting new vector
  67600. */
  67601. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  67602. /**
  67603. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  67604. * @param otherVector vector to devide with
  67605. * @param result vector to store the result
  67606. * @returns the current Vector4.
  67607. */
  67608. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67609. /**
  67610. * Divides the current Vector3 coordinates by the given ones.
  67611. * @param otherVector vector to devide with
  67612. * @returns the updated Vector3.
  67613. */
  67614. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67615. /**
  67616. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  67617. * @param other defines the second operand
  67618. * @returns the current updated Vector4
  67619. */
  67620. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67621. /**
  67622. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  67623. * @param other defines the second operand
  67624. * @returns the current updated Vector4
  67625. */
  67626. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67627. /**
  67628. * Gets a new Vector4 from current Vector4 floored values
  67629. * @returns a new Vector4
  67630. */
  67631. floor(): Vector4;
  67632. /**
  67633. * Gets a new Vector4 from current Vector3 floored values
  67634. * @returns a new Vector4
  67635. */
  67636. fract(): Vector4;
  67637. /**
  67638. * Returns the Vector4 length (float).
  67639. * @returns the length
  67640. */
  67641. length(): number;
  67642. /**
  67643. * Returns the Vector4 squared length (float).
  67644. * @returns the length squared
  67645. */
  67646. lengthSquared(): number;
  67647. /**
  67648. * Normalizes in place the Vector4.
  67649. * @returns the updated Vector4.
  67650. */
  67651. normalize(): Vector4;
  67652. /**
  67653. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  67654. * @returns this converted to a new vector3
  67655. */
  67656. toVector3(): Vector3;
  67657. /**
  67658. * Returns a new Vector4 copied from the current one.
  67659. * @returns the new cloned vector
  67660. */
  67661. clone(): Vector4;
  67662. /**
  67663. * Updates the current Vector4 with the given one coordinates.
  67664. * @param source the source vector to copy from
  67665. * @returns the updated Vector4.
  67666. */
  67667. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  67668. /**
  67669. * Updates the current Vector4 coordinates with the given floats.
  67670. * @param x float to copy from
  67671. * @param y float to copy from
  67672. * @param z float to copy from
  67673. * @param w float to copy from
  67674. * @returns the updated Vector4.
  67675. */
  67676. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67677. /**
  67678. * Updates the current Vector4 coordinates with the given floats.
  67679. * @param x float to set from
  67680. * @param y float to set from
  67681. * @param z float to set from
  67682. * @param w float to set from
  67683. * @returns the updated Vector4.
  67684. */
  67685. set(x: number, y: number, z: number, w: number): Vector4;
  67686. /**
  67687. * Copies the given float to the current Vector3 coordinates
  67688. * @param v defines the x, y, z and w coordinates of the operand
  67689. * @returns the current updated Vector3
  67690. */
  67691. setAll(v: number): Vector4;
  67692. /**
  67693. * Returns a new Vector4 set from the starting index of the given array.
  67694. * @param array the array to pull values from
  67695. * @param offset the offset into the array to start at
  67696. * @returns the new vector
  67697. */
  67698. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  67699. /**
  67700. * Updates the given vector "result" from the starting index of the given array.
  67701. * @param array the array to pull values from
  67702. * @param offset the offset into the array to start at
  67703. * @param result the vector to store the result in
  67704. */
  67705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  67706. /**
  67707. * Updates the given vector "result" from the starting index of the given Float32Array.
  67708. * @param array the array to pull values from
  67709. * @param offset the offset into the array to start at
  67710. * @param result the vector to store the result in
  67711. */
  67712. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67713. /**
  67714. * Updates the given vector "result" coordinates from the given floats.
  67715. * @param x float to set from
  67716. * @param y float to set from
  67717. * @param z float to set from
  67718. * @param w float to set from
  67719. * @param result the vector to the floats in
  67720. */
  67721. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67722. /**
  67723. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67724. * @returns the new vector
  67725. */
  67726. static Zero(): Vector4;
  67727. /**
  67728. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67729. * @returns the new vector
  67730. */
  67731. static One(): Vector4;
  67732. /**
  67733. * Returns a new normalized Vector4 from the given one.
  67734. * @param vector the vector to normalize
  67735. * @returns the vector
  67736. */
  67737. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67738. /**
  67739. * Updates the given vector "result" from the normalization of the given one.
  67740. * @param vector the vector to normalize
  67741. * @param result the vector to store the result in
  67742. */
  67743. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67744. /**
  67745. * Returns a vector with the minimum values from the left and right vectors
  67746. * @param left left vector to minimize
  67747. * @param right right vector to minimize
  67748. * @returns a new vector with the minimum of the left and right vector values
  67749. */
  67750. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67751. /**
  67752. * Returns a vector with the maximum values from the left and right vectors
  67753. * @param left left vector to maximize
  67754. * @param right right vector to maximize
  67755. * @returns a new vector with the maximum of the left and right vector values
  67756. */
  67757. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67758. /**
  67759. * Returns the distance (float) between the vectors "value1" and "value2".
  67760. * @param value1 value to calulate the distance between
  67761. * @param value2 value to calulate the distance between
  67762. * @return the distance between the two vectors
  67763. */
  67764. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67765. /**
  67766. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67767. * @param value1 value to calulate the distance between
  67768. * @param value2 value to calulate the distance between
  67769. * @return the distance between the two vectors squared
  67770. */
  67771. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67772. /**
  67773. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67774. * @param value1 value to calulate the center between
  67775. * @param value2 value to calulate the center between
  67776. * @return the center between the two vectors
  67777. */
  67778. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67779. /**
  67780. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67781. * This methods computes transformed normalized direction vectors only.
  67782. * @param vector the vector to transform
  67783. * @param transformation the transformation matrix to apply
  67784. * @returns the new vector
  67785. */
  67786. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67787. /**
  67788. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67789. * This methods computes transformed normalized direction vectors only.
  67790. * @param vector the vector to transform
  67791. * @param transformation the transformation matrix to apply
  67792. * @param result the vector to store the result in
  67793. */
  67794. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67795. /**
  67796. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67797. * This methods computes transformed normalized direction vectors only.
  67798. * @param x value to transform
  67799. * @param y value to transform
  67800. * @param z value to transform
  67801. * @param w value to transform
  67802. * @param transformation the transformation matrix to apply
  67803. * @param result the vector to store the results in
  67804. */
  67805. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67806. /**
  67807. * Creates a new Vector4 from a Vector3
  67808. * @param source defines the source data
  67809. * @param w defines the 4th component (default is 0)
  67810. * @returns a new Vector4
  67811. */
  67812. static FromVector3(source: Vector3, w?: number): Vector4;
  67813. }
  67814. /**
  67815. * Class used to store quaternion data
  67816. * @see https://en.wikipedia.org/wiki/Quaternion
  67817. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67818. */
  67819. export class Quaternion {
  67820. /** defines the first component (0 by default) */
  67821. x: number;
  67822. /** defines the second component (0 by default) */
  67823. y: number;
  67824. /** defines the third component (0 by default) */
  67825. z: number;
  67826. /** defines the fourth component (1.0 by default) */
  67827. w: number;
  67828. /**
  67829. * Creates a new Quaternion from the given floats
  67830. * @param x defines the first component (0 by default)
  67831. * @param y defines the second component (0 by default)
  67832. * @param z defines the third component (0 by default)
  67833. * @param w defines the fourth component (1.0 by default)
  67834. */
  67835. constructor(
  67836. /** defines the first component (0 by default) */
  67837. x?: number,
  67838. /** defines the second component (0 by default) */
  67839. y?: number,
  67840. /** defines the third component (0 by default) */
  67841. z?: number,
  67842. /** defines the fourth component (1.0 by default) */
  67843. w?: number);
  67844. /**
  67845. * Gets a string representation for the current quaternion
  67846. * @returns a string with the Quaternion coordinates
  67847. */
  67848. toString(): string;
  67849. /**
  67850. * Gets the class name of the quaternion
  67851. * @returns the string "Quaternion"
  67852. */
  67853. getClassName(): string;
  67854. /**
  67855. * Gets a hash code for this quaternion
  67856. * @returns the quaternion hash code
  67857. */
  67858. getHashCode(): number;
  67859. /**
  67860. * Copy the quaternion to an array
  67861. * @returns a new array populated with 4 elements from the quaternion coordinates
  67862. */
  67863. asArray(): number[];
  67864. /**
  67865. * Check if two quaternions are equals
  67866. * @param otherQuaternion defines the second operand
  67867. * @return true if the current quaternion and the given one coordinates are strictly equals
  67868. */
  67869. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  67870. /**
  67871. * Clone the current quaternion
  67872. * @returns a new quaternion copied from the current one
  67873. */
  67874. clone(): Quaternion;
  67875. /**
  67876. * Copy a quaternion to the current one
  67877. * @param other defines the other quaternion
  67878. * @returns the updated current quaternion
  67879. */
  67880. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  67881. /**
  67882. * Updates the current quaternion with the given float coordinates
  67883. * @param x defines the x coordinate
  67884. * @param y defines the y coordinate
  67885. * @param z defines the z coordinate
  67886. * @param w defines the w coordinate
  67887. * @returns the updated current quaternion
  67888. */
  67889. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  67890. /**
  67891. * Updates the current quaternion from the given float coordinates
  67892. * @param x defines the x coordinate
  67893. * @param y defines the y coordinate
  67894. * @param z defines the z coordinate
  67895. * @param w defines the w coordinate
  67896. * @returns the updated current quaternion
  67897. */
  67898. set(x: number, y: number, z: number, w: number): Quaternion;
  67899. /**
  67900. * Adds two quaternions
  67901. * @param other defines the second operand
  67902. * @returns a new quaternion as the addition result of the given one and the current quaternion
  67903. */
  67904. add(other: DeepImmutable<Quaternion>): Quaternion;
  67905. /**
  67906. * Add a quaternion to the current one
  67907. * @param other defines the quaternion to add
  67908. * @returns the current quaternion
  67909. */
  67910. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  67911. /**
  67912. * Subtract two quaternions
  67913. * @param other defines the second operand
  67914. * @returns a new quaternion as the subtraction result of the given one from the current one
  67915. */
  67916. subtract(other: Quaternion): Quaternion;
  67917. /**
  67918. * Multiplies the current quaternion by a scale factor
  67919. * @param value defines the scale factor
  67920. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  67921. */
  67922. scale(value: number): Quaternion;
  67923. /**
  67924. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  67925. * @param scale defines the scale factor
  67926. * @param result defines the Quaternion object where to store the result
  67927. * @returns the unmodified current quaternion
  67928. */
  67929. scaleToRef(scale: number, result: Quaternion): Quaternion;
  67930. /**
  67931. * Multiplies in place the current quaternion by a scale factor
  67932. * @param value defines the scale factor
  67933. * @returns the current modified quaternion
  67934. */
  67935. scaleInPlace(value: number): Quaternion;
  67936. /**
  67937. * Scale the current quaternion values by a factor and add the result to a given quaternion
  67938. * @param scale defines the scale factor
  67939. * @param result defines the Quaternion object where to store the result
  67940. * @returns the unmodified current quaternion
  67941. */
  67942. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  67943. /**
  67944. * Multiplies two quaternions
  67945. * @param q1 defines the second operand
  67946. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  67947. */
  67948. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  67949. /**
  67950. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  67951. * @param q1 defines the second operand
  67952. * @param result defines the target quaternion
  67953. * @returns the current quaternion
  67954. */
  67955. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  67956. /**
  67957. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  67958. * @param q1 defines the second operand
  67959. * @returns the currentupdated quaternion
  67960. */
  67961. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  67962. /**
  67963. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  67964. * @param ref defines the target quaternion
  67965. * @returns the current quaternion
  67966. */
  67967. conjugateToRef(ref: Quaternion): Quaternion;
  67968. /**
  67969. * Conjugates in place (1-q) the current quaternion
  67970. * @returns the current updated quaternion
  67971. */
  67972. conjugateInPlace(): Quaternion;
  67973. /**
  67974. * Conjugates in place (1-q) the current quaternion
  67975. * @returns a new quaternion
  67976. */
  67977. conjugate(): Quaternion;
  67978. /**
  67979. * Gets length of current quaternion
  67980. * @returns the quaternion length (float)
  67981. */
  67982. length(): number;
  67983. /**
  67984. * Normalize in place the current quaternion
  67985. * @returns the current updated quaternion
  67986. */
  67987. normalize(): Quaternion;
  67988. /**
  67989. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  67990. * @param order is a reserved parameter and is ignore for now
  67991. * @returns a new Vector3 containing the Euler angles
  67992. */
  67993. toEulerAngles(order?: string): Vector3;
  67994. /**
  67995. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67996. * @param result defines the vector which will be filled with the Euler angles
  67997. * @param order is a reserved parameter and is ignore for now
  67998. * @returns the current unchanged quaternion
  67999. */
  68000. toEulerAnglesToRef(result: Vector3): Quaternion;
  68001. /**
  68002. * Updates the given rotation matrix with the current quaternion values
  68003. * @param result defines the target matrix
  68004. * @returns the current unchanged quaternion
  68005. */
  68006. toRotationMatrix(result: Matrix): Quaternion;
  68007. /**
  68008. * Updates the current quaternion from the given rotation matrix values
  68009. * @param matrix defines the source matrix
  68010. * @returns the current updated quaternion
  68011. */
  68012. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68013. /**
  68014. * Creates a new quaternion from a rotation matrix
  68015. * @param matrix defines the source matrix
  68016. * @returns a new quaternion created from the given rotation matrix values
  68017. */
  68018. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68019. /**
  68020. * Updates the given quaternion with the given rotation matrix values
  68021. * @param matrix defines the source matrix
  68022. * @param result defines the target quaternion
  68023. */
  68024. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68025. /**
  68026. * Returns the dot product (float) between the quaternions "left" and "right"
  68027. * @param left defines the left operand
  68028. * @param right defines the right operand
  68029. * @returns the dot product
  68030. */
  68031. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68032. /**
  68033. * Checks if the two quaternions are close to each other
  68034. * @param quat0 defines the first quaternion to check
  68035. * @param quat1 defines the second quaternion to check
  68036. * @returns true if the two quaternions are close to each other
  68037. */
  68038. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68039. /**
  68040. * Creates an empty quaternion
  68041. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68042. */
  68043. static Zero(): Quaternion;
  68044. /**
  68045. * Inverse a given quaternion
  68046. * @param q defines the source quaternion
  68047. * @returns a new quaternion as the inverted current quaternion
  68048. */
  68049. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68050. /**
  68051. * Inverse a given quaternion
  68052. * @param q defines the source quaternion
  68053. * @param result the quaternion the result will be stored in
  68054. * @returns the result quaternion
  68055. */
  68056. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68057. /**
  68058. * Creates an identity quaternion
  68059. * @returns the identity quaternion
  68060. */
  68061. static Identity(): Quaternion;
  68062. /**
  68063. * Gets a boolean indicating if the given quaternion is identity
  68064. * @param quaternion defines the quaternion to check
  68065. * @returns true if the quaternion is identity
  68066. */
  68067. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68068. /**
  68069. * Creates a quaternion from a rotation around an axis
  68070. * @param axis defines the axis to use
  68071. * @param angle defines the angle to use
  68072. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68073. */
  68074. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68075. /**
  68076. * Creates a rotation around an axis and stores it into the given quaternion
  68077. * @param axis defines the axis to use
  68078. * @param angle defines the angle to use
  68079. * @param result defines the target quaternion
  68080. * @returns the target quaternion
  68081. */
  68082. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68083. /**
  68084. * Creates a new quaternion from data stored into an array
  68085. * @param array defines the data source
  68086. * @param offset defines the offset in the source array where the data starts
  68087. * @returns a new quaternion
  68088. */
  68089. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68090. /**
  68091. * Create a quaternion from Euler rotation angles
  68092. * @param x Pitch
  68093. * @param y Yaw
  68094. * @param z Roll
  68095. * @returns the new Quaternion
  68096. */
  68097. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68098. /**
  68099. * Updates a quaternion from Euler rotation angles
  68100. * @param x Pitch
  68101. * @param y Yaw
  68102. * @param z Roll
  68103. * @param result the quaternion to store the result
  68104. * @returns the updated quaternion
  68105. */
  68106. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68107. /**
  68108. * Create a quaternion from Euler rotation vector
  68109. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68110. * @returns the new Quaternion
  68111. */
  68112. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68113. /**
  68114. * Updates a quaternion from Euler rotation vector
  68115. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68116. * @param result the quaternion to store the result
  68117. * @returns the updated quaternion
  68118. */
  68119. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68120. /**
  68121. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68122. * @param yaw defines the rotation around Y axis
  68123. * @param pitch defines the rotation around X axis
  68124. * @param roll defines the rotation around Z axis
  68125. * @returns the new quaternion
  68126. */
  68127. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68128. /**
  68129. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68130. * @param yaw defines the rotation around Y axis
  68131. * @param pitch defines the rotation around X axis
  68132. * @param roll defines the rotation around Z axis
  68133. * @param result defines the target quaternion
  68134. */
  68135. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68136. /**
  68137. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68138. * @param alpha defines the rotation around first axis
  68139. * @param beta defines the rotation around second axis
  68140. * @param gamma defines the rotation around third axis
  68141. * @returns the new quaternion
  68142. */
  68143. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68144. /**
  68145. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  68146. * @param alpha defines the rotation around first axis
  68147. * @param beta defines the rotation around second axis
  68148. * @param gamma defines the rotation around third axis
  68149. * @param result defines the target quaternion
  68150. */
  68151. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  68152. /**
  68153. * 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)
  68154. * @param axis1 defines the first axis
  68155. * @param axis2 defines the second axis
  68156. * @param axis3 defines the third axis
  68157. * @returns the new quaternion
  68158. */
  68159. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  68160. /**
  68161. * 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
  68162. * @param axis1 defines the first axis
  68163. * @param axis2 defines the second axis
  68164. * @param axis3 defines the third axis
  68165. * @param ref defines the target quaternion
  68166. */
  68167. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  68168. /**
  68169. * Interpolates between two quaternions
  68170. * @param left defines first quaternion
  68171. * @param right defines second quaternion
  68172. * @param amount defines the gradient to use
  68173. * @returns the new interpolated quaternion
  68174. */
  68175. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68176. /**
  68177. * Interpolates between two quaternions and stores it into a target quaternion
  68178. * @param left defines first quaternion
  68179. * @param right defines second quaternion
  68180. * @param amount defines the gradient to use
  68181. * @param result defines the target quaternion
  68182. */
  68183. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  68184. /**
  68185. * Interpolate between two quaternions using Hermite interpolation
  68186. * @param value1 defines first quaternion
  68187. * @param tangent1 defines the incoming tangent
  68188. * @param value2 defines second quaternion
  68189. * @param tangent2 defines the outgoing tangent
  68190. * @param amount defines the target quaternion
  68191. * @returns the new interpolated quaternion
  68192. */
  68193. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68194. }
  68195. /**
  68196. * Class used to store matrix data (4x4)
  68197. */
  68198. export class Matrix {
  68199. private static _updateFlagSeed;
  68200. private static _identityReadOnly;
  68201. private _isIdentity;
  68202. private _isIdentityDirty;
  68203. private _isIdentity3x2;
  68204. private _isIdentity3x2Dirty;
  68205. /**
  68206. * Gets the update flag of the matrix which is an unique number for the matrix.
  68207. * It will be incremented every time the matrix data change.
  68208. * You can use it to speed the comparison between two versions of the same matrix.
  68209. */
  68210. updateFlag: number;
  68211. private readonly _m;
  68212. /**
  68213. * Gets the internal data of the matrix
  68214. */
  68215. readonly m: DeepImmutable<Float32Array>;
  68216. /** @hidden */
  68217. _markAsUpdated(): void;
  68218. /** @hidden */
  68219. private _updateIdentityStatus;
  68220. /**
  68221. * Creates an empty matrix (filled with zeros)
  68222. */
  68223. constructor();
  68224. /**
  68225. * Check if the current matrix is identity
  68226. * @returns true is the matrix is the identity matrix
  68227. */
  68228. isIdentity(): boolean;
  68229. /**
  68230. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  68231. * @returns true is the matrix is the identity matrix
  68232. */
  68233. isIdentityAs3x2(): boolean;
  68234. /**
  68235. * Gets the determinant of the matrix
  68236. * @returns the matrix determinant
  68237. */
  68238. determinant(): number;
  68239. /**
  68240. * Returns the matrix as a Float32Array
  68241. * @returns the matrix underlying array
  68242. */
  68243. toArray(): DeepImmutable<Float32Array>;
  68244. /**
  68245. * Returns the matrix as a Float32Array
  68246. * @returns the matrix underlying array.
  68247. */
  68248. asArray(): DeepImmutable<Float32Array>;
  68249. /**
  68250. * Inverts the current matrix in place
  68251. * @returns the current inverted matrix
  68252. */
  68253. invert(): Matrix;
  68254. /**
  68255. * Sets all the matrix elements to zero
  68256. * @returns the current matrix
  68257. */
  68258. reset(): Matrix;
  68259. /**
  68260. * Adds the current matrix with a second one
  68261. * @param other defines the matrix to add
  68262. * @returns a new matrix as the addition of the current matrix and the given one
  68263. */
  68264. add(other: DeepImmutable<Matrix>): Matrix;
  68265. /**
  68266. * Sets the given matrix "result" to the addition of the current matrix and the given one
  68267. * @param other defines the matrix to add
  68268. * @param result defines the target matrix
  68269. * @returns the current matrix
  68270. */
  68271. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68272. /**
  68273. * Adds in place the given matrix to the current matrix
  68274. * @param other defines the second operand
  68275. * @returns the current updated matrix
  68276. */
  68277. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  68278. /**
  68279. * Sets the given matrix to the current inverted Matrix
  68280. * @param other defines the target matrix
  68281. * @returns the unmodified current matrix
  68282. */
  68283. invertToRef(other: Matrix): Matrix;
  68284. /**
  68285. * add a value at the specified position in the current Matrix
  68286. * @param index the index of the value within the matrix. between 0 and 15.
  68287. * @param value the value to be added
  68288. * @returns the current updated matrix
  68289. */
  68290. addAtIndex(index: number, value: number): Matrix;
  68291. /**
  68292. * mutiply the specified position in the current Matrix by a value
  68293. * @param index the index of the value within the matrix. between 0 and 15.
  68294. * @param value the value to be added
  68295. * @returns the current updated matrix
  68296. */
  68297. multiplyAtIndex(index: number, value: number): Matrix;
  68298. /**
  68299. * Inserts the translation vector (using 3 floats) in the current matrix
  68300. * @param x defines the 1st component of the translation
  68301. * @param y defines the 2nd component of the translation
  68302. * @param z defines the 3rd component of the translation
  68303. * @returns the current updated matrix
  68304. */
  68305. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68306. /**
  68307. * Adds the translation vector (using 3 floats) in the current matrix
  68308. * @param x defines the 1st component of the translation
  68309. * @param y defines the 2nd component of the translation
  68310. * @param z defines the 3rd component of the translation
  68311. * @returns the current updated matrix
  68312. */
  68313. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68314. /**
  68315. * Inserts the translation vector in the current matrix
  68316. * @param vector3 defines the translation to insert
  68317. * @returns the current updated matrix
  68318. */
  68319. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  68320. /**
  68321. * Gets the translation value of the current matrix
  68322. * @returns a new Vector3 as the extracted translation from the matrix
  68323. */
  68324. getTranslation(): Vector3;
  68325. /**
  68326. * Fill a Vector3 with the extracted translation from the matrix
  68327. * @param result defines the Vector3 where to store the translation
  68328. * @returns the current matrix
  68329. */
  68330. getTranslationToRef(result: Vector3): Matrix;
  68331. /**
  68332. * Remove rotation and scaling part from the matrix
  68333. * @returns the updated matrix
  68334. */
  68335. removeRotationAndScaling(): Matrix;
  68336. /**
  68337. * Multiply two matrices
  68338. * @param other defines the second operand
  68339. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  68340. */
  68341. multiply(other: DeepImmutable<Matrix>): Matrix;
  68342. /**
  68343. * Copy the current matrix from the given one
  68344. * @param other defines the source matrix
  68345. * @returns the current updated matrix
  68346. */
  68347. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  68348. /**
  68349. * Populates the given array from the starting index with the current matrix values
  68350. * @param array defines the target array
  68351. * @param offset defines the offset in the target array where to start storing values
  68352. * @returns the current matrix
  68353. */
  68354. copyToArray(array: Float32Array, offset?: number): Matrix;
  68355. /**
  68356. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  68357. * @param other defines the second operand
  68358. * @param result defines the matrix where to store the multiplication
  68359. * @returns the current matrix
  68360. */
  68361. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68362. /**
  68363. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  68364. * @param other defines the second operand
  68365. * @param result defines the array where to store the multiplication
  68366. * @param offset defines the offset in the target array where to start storing values
  68367. * @returns the current matrix
  68368. */
  68369. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  68370. /**
  68371. * Check equality between this matrix and a second one
  68372. * @param value defines the second matrix to compare
  68373. * @returns true is the current matrix and the given one values are strictly equal
  68374. */
  68375. equals(value: DeepImmutable<Matrix>): boolean;
  68376. /**
  68377. * Clone the current matrix
  68378. * @returns a new matrix from the current matrix
  68379. */
  68380. clone(): Matrix;
  68381. /**
  68382. * Returns the name of the current matrix class
  68383. * @returns the string "Matrix"
  68384. */
  68385. getClassName(): string;
  68386. /**
  68387. * Gets the hash code of the current matrix
  68388. * @returns the hash code
  68389. */
  68390. getHashCode(): number;
  68391. /**
  68392. * Decomposes the current Matrix into a translation, rotation and scaling components
  68393. * @param scale defines the scale vector3 given as a reference to update
  68394. * @param rotation defines the rotation quaternion given as a reference to update
  68395. * @param translation defines the translation vector3 given as a reference to update
  68396. * @returns true if operation was successful
  68397. */
  68398. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  68399. /**
  68400. * Gets specific row of the matrix
  68401. * @param index defines the number of the row to get
  68402. * @returns the index-th row of the current matrix as a new Vector4
  68403. */
  68404. getRow(index: number): Nullable<Vector4>;
  68405. /**
  68406. * Sets the index-th row of the current matrix to the vector4 values
  68407. * @param index defines the number of the row to set
  68408. * @param row defines the target vector4
  68409. * @returns the updated current matrix
  68410. */
  68411. setRow(index: number, row: Vector4): Matrix;
  68412. /**
  68413. * Compute the transpose of the matrix
  68414. * @returns the new transposed matrix
  68415. */
  68416. transpose(): Matrix;
  68417. /**
  68418. * Compute the transpose of the matrix and store it in a given matrix
  68419. * @param result defines the target matrix
  68420. * @returns the current matrix
  68421. */
  68422. transposeToRef(result: Matrix): Matrix;
  68423. /**
  68424. * Sets the index-th row of the current matrix with the given 4 x float values
  68425. * @param index defines the row index
  68426. * @param x defines the x component to set
  68427. * @param y defines the y component to set
  68428. * @param z defines the z component to set
  68429. * @param w defines the w component to set
  68430. * @returns the updated current matrix
  68431. */
  68432. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  68433. /**
  68434. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  68435. * @param scale defines the scale factor
  68436. * @returns a new matrix
  68437. */
  68438. scale(scale: number): Matrix;
  68439. /**
  68440. * Scale the current matrix values by a factor to a given result matrix
  68441. * @param scale defines the scale factor
  68442. * @param result defines the matrix to store the result
  68443. * @returns the current matrix
  68444. */
  68445. scaleToRef(scale: number, result: Matrix): Matrix;
  68446. /**
  68447. * Scale the current matrix values by a factor and add the result to a given matrix
  68448. * @param scale defines the scale factor
  68449. * @param result defines the Matrix to store the result
  68450. * @returns the current matrix
  68451. */
  68452. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  68453. /**
  68454. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  68455. * @param ref matrix to store the result
  68456. */
  68457. toNormalMatrix(ref: Matrix): void;
  68458. /**
  68459. * Gets only rotation part of the current matrix
  68460. * @returns a new matrix sets to the extracted rotation matrix from the current one
  68461. */
  68462. getRotationMatrix(): Matrix;
  68463. /**
  68464. * Extracts the rotation matrix from the current one and sets it as the given "result"
  68465. * @param result defines the target matrix to store data to
  68466. * @returns the current matrix
  68467. */
  68468. getRotationMatrixToRef(result: Matrix): Matrix;
  68469. /**
  68470. * Toggles model matrix from being right handed to left handed in place and vice versa
  68471. */
  68472. toggleModelMatrixHandInPlace(): void;
  68473. /**
  68474. * Toggles projection matrix from being right handed to left handed in place and vice versa
  68475. */
  68476. toggleProjectionMatrixHandInPlace(): void;
  68477. /**
  68478. * Creates a matrix from an array
  68479. * @param array defines the source array
  68480. * @param offset defines an offset in the source array
  68481. * @returns a new Matrix set from the starting index of the given array
  68482. */
  68483. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  68484. /**
  68485. * Copy the content of an array into a given matrix
  68486. * @param array defines the source array
  68487. * @param offset defines an offset in the source array
  68488. * @param result defines the target matrix
  68489. */
  68490. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  68491. /**
  68492. * Stores an array into a matrix after having multiplied each component by a given factor
  68493. * @param array defines the source array
  68494. * @param offset defines the offset in the source array
  68495. * @param scale defines the scaling factor
  68496. * @param result defines the target matrix
  68497. */
  68498. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  68499. /**
  68500. * Gets an identity matrix that must not be updated
  68501. */
  68502. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  68503. /**
  68504. * Stores a list of values (16) inside a given matrix
  68505. * @param initialM11 defines 1st value of 1st row
  68506. * @param initialM12 defines 2nd value of 1st row
  68507. * @param initialM13 defines 3rd value of 1st row
  68508. * @param initialM14 defines 4th value of 1st row
  68509. * @param initialM21 defines 1st value of 2nd row
  68510. * @param initialM22 defines 2nd value of 2nd row
  68511. * @param initialM23 defines 3rd value of 2nd row
  68512. * @param initialM24 defines 4th value of 2nd row
  68513. * @param initialM31 defines 1st value of 3rd row
  68514. * @param initialM32 defines 2nd value of 3rd row
  68515. * @param initialM33 defines 3rd value of 3rd row
  68516. * @param initialM34 defines 4th value of 3rd row
  68517. * @param initialM41 defines 1st value of 4th row
  68518. * @param initialM42 defines 2nd value of 4th row
  68519. * @param initialM43 defines 3rd value of 4th row
  68520. * @param initialM44 defines 4th value of 4th row
  68521. * @param result defines the target matrix
  68522. */
  68523. 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;
  68524. /**
  68525. * Creates new matrix from a list of values (16)
  68526. * @param initialM11 defines 1st value of 1st row
  68527. * @param initialM12 defines 2nd value of 1st row
  68528. * @param initialM13 defines 3rd value of 1st row
  68529. * @param initialM14 defines 4th value of 1st row
  68530. * @param initialM21 defines 1st value of 2nd row
  68531. * @param initialM22 defines 2nd value of 2nd row
  68532. * @param initialM23 defines 3rd value of 2nd row
  68533. * @param initialM24 defines 4th value of 2nd row
  68534. * @param initialM31 defines 1st value of 3rd row
  68535. * @param initialM32 defines 2nd value of 3rd row
  68536. * @param initialM33 defines 3rd value of 3rd row
  68537. * @param initialM34 defines 4th value of 3rd row
  68538. * @param initialM41 defines 1st value of 4th row
  68539. * @param initialM42 defines 2nd value of 4th row
  68540. * @param initialM43 defines 3rd value of 4th row
  68541. * @param initialM44 defines 4th value of 4th row
  68542. * @returns the new matrix
  68543. */
  68544. 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;
  68545. /**
  68546. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68547. * @param scale defines the scale vector3
  68548. * @param rotation defines the rotation quaternion
  68549. * @param translation defines the translation vector3
  68550. * @returns a new matrix
  68551. */
  68552. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  68553. /**
  68554. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68555. * @param scale defines the scale vector3
  68556. * @param rotation defines the rotation quaternion
  68557. * @param translation defines the translation vector3
  68558. * @param result defines the target matrix
  68559. */
  68560. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  68561. /**
  68562. * Creates a new identity matrix
  68563. * @returns a new identity matrix
  68564. */
  68565. static Identity(): Matrix;
  68566. /**
  68567. * Creates a new identity matrix and stores the result in a given matrix
  68568. * @param result defines the target matrix
  68569. */
  68570. static IdentityToRef(result: Matrix): void;
  68571. /**
  68572. * Creates a new zero matrix
  68573. * @returns a new zero matrix
  68574. */
  68575. static Zero(): Matrix;
  68576. /**
  68577. * Creates a new rotation matrix for "angle" radians around the X axis
  68578. * @param angle defines the angle (in radians) to use
  68579. * @return the new matrix
  68580. */
  68581. static RotationX(angle: number): Matrix;
  68582. /**
  68583. * Creates a new matrix as the invert of a given matrix
  68584. * @param source defines the source matrix
  68585. * @returns the new matrix
  68586. */
  68587. static Invert(source: DeepImmutable<Matrix>): Matrix;
  68588. /**
  68589. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  68590. * @param angle defines the angle (in radians) to use
  68591. * @param result defines the target matrix
  68592. */
  68593. static RotationXToRef(angle: number, result: Matrix): void;
  68594. /**
  68595. * Creates a new rotation matrix for "angle" radians around the Y axis
  68596. * @param angle defines the angle (in radians) to use
  68597. * @return the new matrix
  68598. */
  68599. static RotationY(angle: number): Matrix;
  68600. /**
  68601. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  68602. * @param angle defines the angle (in radians) to use
  68603. * @param result defines the target matrix
  68604. */
  68605. static RotationYToRef(angle: number, result: Matrix): void;
  68606. /**
  68607. * Creates a new rotation matrix for "angle" radians around the Z axis
  68608. * @param angle defines the angle (in radians) to use
  68609. * @return the new matrix
  68610. */
  68611. static RotationZ(angle: number): Matrix;
  68612. /**
  68613. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  68614. * @param angle defines the angle (in radians) to use
  68615. * @param result defines the target matrix
  68616. */
  68617. static RotationZToRef(angle: number, result: Matrix): void;
  68618. /**
  68619. * Creates a new rotation matrix for "angle" radians around the given axis
  68620. * @param axis defines the axis to use
  68621. * @param angle defines the angle (in radians) to use
  68622. * @return the new matrix
  68623. */
  68624. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  68625. /**
  68626. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  68627. * @param axis defines the axis to use
  68628. * @param angle defines the angle (in radians) to use
  68629. * @param result defines the target matrix
  68630. */
  68631. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  68632. /**
  68633. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  68634. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  68635. * @param from defines the vector to align
  68636. * @param to defines the vector to align to
  68637. * @param result defines the target matrix
  68638. */
  68639. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  68640. /**
  68641. * Creates a rotation matrix
  68642. * @param yaw defines the yaw angle in radians (Y axis)
  68643. * @param pitch defines the pitch angle in radians (X axis)
  68644. * @param roll defines the roll angle in radians (X axis)
  68645. * @returns the new rotation matrix
  68646. */
  68647. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  68648. /**
  68649. * Creates a rotation matrix and stores it in a given matrix
  68650. * @param yaw defines the yaw angle in radians (Y axis)
  68651. * @param pitch defines the pitch angle in radians (X axis)
  68652. * @param roll defines the roll angle in radians (X axis)
  68653. * @param result defines the target matrix
  68654. */
  68655. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  68656. /**
  68657. * Creates a scaling matrix
  68658. * @param x defines the scale factor on X axis
  68659. * @param y defines the scale factor on Y axis
  68660. * @param z defines the scale factor on Z axis
  68661. * @returns the new matrix
  68662. */
  68663. static Scaling(x: number, y: number, z: number): Matrix;
  68664. /**
  68665. * Creates a scaling matrix and stores it in a given matrix
  68666. * @param x defines the scale factor on X axis
  68667. * @param y defines the scale factor on Y axis
  68668. * @param z defines the scale factor on Z axis
  68669. * @param result defines the target matrix
  68670. */
  68671. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  68672. /**
  68673. * Creates a translation matrix
  68674. * @param x defines the translation on X axis
  68675. * @param y defines the translation on Y axis
  68676. * @param z defines the translationon Z axis
  68677. * @returns the new matrix
  68678. */
  68679. static Translation(x: number, y: number, z: number): Matrix;
  68680. /**
  68681. * Creates a translation matrix and stores it in a given matrix
  68682. * @param x defines the translation on X axis
  68683. * @param y defines the translation on Y axis
  68684. * @param z defines the translationon Z axis
  68685. * @param result defines the target matrix
  68686. */
  68687. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  68688. /**
  68689. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68690. * @param startValue defines the start value
  68691. * @param endValue defines the end value
  68692. * @param gradient defines the gradient factor
  68693. * @returns the new matrix
  68694. */
  68695. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68696. /**
  68697. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68698. * @param startValue defines the start value
  68699. * @param endValue defines the end value
  68700. * @param gradient defines the gradient factor
  68701. * @param result defines the Matrix object where to store data
  68702. */
  68703. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68704. /**
  68705. * Builds a new matrix whose values are computed by:
  68706. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68707. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68708. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68709. * @param startValue defines the first matrix
  68710. * @param endValue defines the second matrix
  68711. * @param gradient defines the gradient between the two matrices
  68712. * @returns the new matrix
  68713. */
  68714. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68715. /**
  68716. * Update a matrix to values which are computed by:
  68717. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68718. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68719. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68720. * @param startValue defines the first matrix
  68721. * @param endValue defines the second matrix
  68722. * @param gradient defines the gradient between the two matrices
  68723. * @param result defines the target matrix
  68724. */
  68725. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68726. /**
  68727. * 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"
  68728. * This function works in left handed mode
  68729. * @param eye defines the final position of the entity
  68730. * @param target defines where the entity should look at
  68731. * @param up defines the up vector for the entity
  68732. * @returns the new matrix
  68733. */
  68734. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68735. /**
  68736. * 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".
  68737. * This function works in left handed mode
  68738. * @param eye defines the final position of the entity
  68739. * @param target defines where the entity should look at
  68740. * @param up defines the up vector for the entity
  68741. * @param result defines the target matrix
  68742. */
  68743. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68744. /**
  68745. * 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"
  68746. * This function works in right handed mode
  68747. * @param eye defines the final position of the entity
  68748. * @param target defines where the entity should look at
  68749. * @param up defines the up vector for the entity
  68750. * @returns the new matrix
  68751. */
  68752. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68753. /**
  68754. * 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".
  68755. * This function works in right handed mode
  68756. * @param eye defines the final position of the entity
  68757. * @param target defines where the entity should look at
  68758. * @param up defines the up vector for the entity
  68759. * @param result defines the target matrix
  68760. */
  68761. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68762. /**
  68763. * Create a left-handed orthographic projection matrix
  68764. * @param width defines the viewport width
  68765. * @param height defines the viewport height
  68766. * @param znear defines the near clip plane
  68767. * @param zfar defines the far clip plane
  68768. * @returns a new matrix as a left-handed orthographic projection matrix
  68769. */
  68770. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68771. /**
  68772. * Store a left-handed orthographic projection to a given matrix
  68773. * @param width defines the viewport width
  68774. * @param height defines the viewport height
  68775. * @param znear defines the near clip plane
  68776. * @param zfar defines the far clip plane
  68777. * @param result defines the target matrix
  68778. */
  68779. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68780. /**
  68781. * Create a left-handed orthographic projection matrix
  68782. * @param left defines the viewport left coordinate
  68783. * @param right defines the viewport right coordinate
  68784. * @param bottom defines the viewport bottom coordinate
  68785. * @param top defines the viewport top coordinate
  68786. * @param znear defines the near clip plane
  68787. * @param zfar defines the far clip plane
  68788. * @returns a new matrix as a left-handed orthographic projection matrix
  68789. */
  68790. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68791. /**
  68792. * Stores a left-handed orthographic projection into a given matrix
  68793. * @param left defines the viewport left coordinate
  68794. * @param right defines the viewport right coordinate
  68795. * @param bottom defines the viewport bottom coordinate
  68796. * @param top defines the viewport top coordinate
  68797. * @param znear defines the near clip plane
  68798. * @param zfar defines the far clip plane
  68799. * @param result defines the target matrix
  68800. */
  68801. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68802. /**
  68803. * Creates a right-handed orthographic projection matrix
  68804. * @param left defines the viewport left coordinate
  68805. * @param right defines the viewport right coordinate
  68806. * @param bottom defines the viewport bottom coordinate
  68807. * @param top defines the viewport top coordinate
  68808. * @param znear defines the near clip plane
  68809. * @param zfar defines the far clip plane
  68810. * @returns a new matrix as a right-handed orthographic projection matrix
  68811. */
  68812. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68813. /**
  68814. * Stores a right-handed orthographic projection into a given matrix
  68815. * @param left defines the viewport left coordinate
  68816. * @param right defines the viewport right coordinate
  68817. * @param bottom defines the viewport bottom coordinate
  68818. * @param top defines the viewport top coordinate
  68819. * @param znear defines the near clip plane
  68820. * @param zfar defines the far clip plane
  68821. * @param result defines the target matrix
  68822. */
  68823. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68824. /**
  68825. * Creates a left-handed perspective projection matrix
  68826. * @param width defines the viewport width
  68827. * @param height defines the viewport height
  68828. * @param znear defines the near clip plane
  68829. * @param zfar defines the far clip plane
  68830. * @returns a new matrix as a left-handed perspective projection matrix
  68831. */
  68832. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68833. /**
  68834. * Creates a left-handed perspective projection matrix
  68835. * @param fov defines the horizontal field of view
  68836. * @param aspect defines the aspect ratio
  68837. * @param znear defines the near clip plane
  68838. * @param zfar defines the far clip plane
  68839. * @returns a new matrix as a left-handed perspective projection matrix
  68840. */
  68841. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68842. /**
  68843. * Stores a left-handed perspective projection into a given matrix
  68844. * @param fov defines the horizontal field of view
  68845. * @param aspect defines the aspect ratio
  68846. * @param znear defines the near clip plane
  68847. * @param zfar defines the far clip plane
  68848. * @param result defines the target matrix
  68849. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68850. */
  68851. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68852. /**
  68853. * Creates a right-handed perspective projection matrix
  68854. * @param fov defines the horizontal field of view
  68855. * @param aspect defines the aspect ratio
  68856. * @param znear defines the near clip plane
  68857. * @param zfar defines the far clip plane
  68858. * @returns a new matrix as a right-handed perspective projection matrix
  68859. */
  68860. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68861. /**
  68862. * Stores a right-handed perspective projection into a given matrix
  68863. * @param fov defines the horizontal field of view
  68864. * @param aspect defines the aspect ratio
  68865. * @param znear defines the near clip plane
  68866. * @param zfar defines the far clip plane
  68867. * @param result defines the target matrix
  68868. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68869. */
  68870. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68871. /**
  68872. * Stores a perspective projection for WebVR info a given matrix
  68873. * @param fov defines the field of view
  68874. * @param znear defines the near clip plane
  68875. * @param zfar defines the far clip plane
  68876. * @param result defines the target matrix
  68877. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  68878. */
  68879. static PerspectiveFovWebVRToRef(fov: {
  68880. upDegrees: number;
  68881. downDegrees: number;
  68882. leftDegrees: number;
  68883. rightDegrees: number;
  68884. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  68885. /**
  68886. * Computes a complete transformation matrix
  68887. * @param viewport defines the viewport to use
  68888. * @param world defines the world matrix
  68889. * @param view defines the view matrix
  68890. * @param projection defines the projection matrix
  68891. * @param zmin defines the near clip plane
  68892. * @param zmax defines the far clip plane
  68893. * @returns the transformation matrix
  68894. */
  68895. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  68896. /**
  68897. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  68898. * @param matrix defines the matrix to use
  68899. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  68900. */
  68901. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  68902. /**
  68903. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  68904. * @param matrix defines the matrix to use
  68905. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  68906. */
  68907. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  68908. /**
  68909. * Compute the transpose of a given matrix
  68910. * @param matrix defines the matrix to transpose
  68911. * @returns the new matrix
  68912. */
  68913. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  68914. /**
  68915. * Compute the transpose of a matrix and store it in a target matrix
  68916. * @param matrix defines the matrix to transpose
  68917. * @param result defines the target matrix
  68918. */
  68919. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  68920. /**
  68921. * Computes a reflection matrix from a plane
  68922. * @param plane defines the reflection plane
  68923. * @returns a new matrix
  68924. */
  68925. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  68926. /**
  68927. * Computes a reflection matrix from a plane
  68928. * @param plane defines the reflection plane
  68929. * @param result defines the target matrix
  68930. */
  68931. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  68932. /**
  68933. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  68934. * @param xaxis defines the value of the 1st axis
  68935. * @param yaxis defines the value of the 2nd axis
  68936. * @param zaxis defines the value of the 3rd axis
  68937. * @param result defines the target matrix
  68938. */
  68939. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  68940. /**
  68941. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  68942. * @param quat defines the quaternion to use
  68943. * @param result defines the target matrix
  68944. */
  68945. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  68946. }
  68947. /**
  68948. * @hidden
  68949. */
  68950. export class TmpVectors {
  68951. static Vector2: Vector2[];
  68952. static Vector3: Vector3[];
  68953. static Vector4: Vector4[];
  68954. static Quaternion: Quaternion[];
  68955. static Matrix: Matrix[];
  68956. }
  68957. }
  68958. declare module BABYLON {
  68959. /** Defines the cross module used constants to avoid circular dependncies */
  68960. export class Constants {
  68961. /** Defines that alpha blending is disabled */
  68962. static readonly ALPHA_DISABLE: number;
  68963. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68964. static readonly ALPHA_ADD: number;
  68965. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68966. static readonly ALPHA_COMBINE: number;
  68967. /** Defines that alpha blending to DEST - SRC * DEST */
  68968. static readonly ALPHA_SUBTRACT: number;
  68969. /** Defines that alpha blending to SRC * DEST */
  68970. static readonly ALPHA_MULTIPLY: number;
  68971. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68972. static readonly ALPHA_MAXIMIZED: number;
  68973. /** Defines that alpha blending to SRC + DEST */
  68974. static readonly ALPHA_ONEONE: number;
  68975. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68976. static readonly ALPHA_PREMULTIPLIED: number;
  68977. /**
  68978. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68979. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68980. */
  68981. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68982. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68983. static readonly ALPHA_INTERPOLATE: number;
  68984. /**
  68985. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68986. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68987. */
  68988. static readonly ALPHA_SCREENMODE: number;
  68989. /** Defines that the ressource is not delayed*/
  68990. static readonly DELAYLOADSTATE_NONE: number;
  68991. /** Defines that the ressource was successfully delay loaded */
  68992. static readonly DELAYLOADSTATE_LOADED: number;
  68993. /** Defines that the ressource is currently delay loading */
  68994. static readonly DELAYLOADSTATE_LOADING: number;
  68995. /** Defines that the ressource is delayed and has not started loading */
  68996. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68997. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68998. static readonly NEVER: number;
  68999. /** 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 */
  69000. static readonly ALWAYS: number;
  69001. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69002. static readonly LESS: number;
  69003. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69004. static readonly EQUAL: number;
  69005. /** 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 */
  69006. static readonly LEQUAL: number;
  69007. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69008. static readonly GREATER: number;
  69009. /** 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 */
  69010. static readonly GEQUAL: number;
  69011. /** 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 */
  69012. static readonly NOTEQUAL: number;
  69013. /** Passed to stencilOperation to specify that stencil value must be kept */
  69014. static readonly KEEP: number;
  69015. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69016. static readonly REPLACE: number;
  69017. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69018. static readonly INCR: number;
  69019. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69020. static readonly DECR: number;
  69021. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69022. static readonly INVERT: number;
  69023. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69024. static readonly INCR_WRAP: number;
  69025. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69026. static readonly DECR_WRAP: number;
  69027. /** Texture is not repeating outside of 0..1 UVs */
  69028. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69029. /** Texture is repeating outside of 0..1 UVs */
  69030. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69031. /** Texture is repeating and mirrored */
  69032. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69033. /** ALPHA */
  69034. static readonly TEXTUREFORMAT_ALPHA: number;
  69035. /** LUMINANCE */
  69036. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69037. /** LUMINANCE_ALPHA */
  69038. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69039. /** RGB */
  69040. static readonly TEXTUREFORMAT_RGB: number;
  69041. /** RGBA */
  69042. static readonly TEXTUREFORMAT_RGBA: number;
  69043. /** RED */
  69044. static readonly TEXTUREFORMAT_RED: number;
  69045. /** RED (2nd reference) */
  69046. static readonly TEXTUREFORMAT_R: number;
  69047. /** RG */
  69048. static readonly TEXTUREFORMAT_RG: number;
  69049. /** RED_INTEGER */
  69050. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69051. /** RED_INTEGER (2nd reference) */
  69052. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69053. /** RG_INTEGER */
  69054. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69055. /** RGB_INTEGER */
  69056. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69057. /** RGBA_INTEGER */
  69058. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69059. /** UNSIGNED_BYTE */
  69060. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69061. /** UNSIGNED_BYTE (2nd reference) */
  69062. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69063. /** FLOAT */
  69064. static readonly TEXTURETYPE_FLOAT: number;
  69065. /** HALF_FLOAT */
  69066. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69067. /** BYTE */
  69068. static readonly TEXTURETYPE_BYTE: number;
  69069. /** SHORT */
  69070. static readonly TEXTURETYPE_SHORT: number;
  69071. /** UNSIGNED_SHORT */
  69072. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69073. /** INT */
  69074. static readonly TEXTURETYPE_INT: number;
  69075. /** UNSIGNED_INT */
  69076. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69077. /** UNSIGNED_SHORT_4_4_4_4 */
  69078. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69079. /** UNSIGNED_SHORT_5_5_5_1 */
  69080. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69081. /** UNSIGNED_SHORT_5_6_5 */
  69082. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69083. /** UNSIGNED_INT_2_10_10_10_REV */
  69084. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69085. /** UNSIGNED_INT_24_8 */
  69086. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69087. /** UNSIGNED_INT_10F_11F_11F_REV */
  69088. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69089. /** UNSIGNED_INT_5_9_9_9_REV */
  69090. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69091. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69092. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69093. /** nearest is mag = nearest and min = nearest and mip = linear */
  69094. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69095. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69096. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69097. /** Trilinear is mag = linear and min = linear and mip = linear */
  69098. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69099. /** nearest is mag = nearest and min = nearest and mip = linear */
  69100. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69101. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69102. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69103. /** Trilinear is mag = linear and min = linear and mip = linear */
  69104. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69105. /** mag = nearest and min = nearest and mip = nearest */
  69106. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69107. /** mag = nearest and min = linear and mip = nearest */
  69108. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69109. /** mag = nearest and min = linear and mip = linear */
  69110. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69111. /** mag = nearest and min = linear and mip = none */
  69112. static readonly TEXTURE_NEAREST_LINEAR: number;
  69113. /** mag = nearest and min = nearest and mip = none */
  69114. static readonly TEXTURE_NEAREST_NEAREST: number;
  69115. /** mag = linear and min = nearest and mip = nearest */
  69116. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69117. /** mag = linear and min = nearest and mip = linear */
  69118. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69119. /** mag = linear and min = linear and mip = none */
  69120. static readonly TEXTURE_LINEAR_LINEAR: number;
  69121. /** mag = linear and min = nearest and mip = none */
  69122. static readonly TEXTURE_LINEAR_NEAREST: number;
  69123. /** Explicit coordinates mode */
  69124. static readonly TEXTURE_EXPLICIT_MODE: number;
  69125. /** Spherical coordinates mode */
  69126. static readonly TEXTURE_SPHERICAL_MODE: number;
  69127. /** Planar coordinates mode */
  69128. static readonly TEXTURE_PLANAR_MODE: number;
  69129. /** Cubic coordinates mode */
  69130. static readonly TEXTURE_CUBIC_MODE: number;
  69131. /** Projection coordinates mode */
  69132. static readonly TEXTURE_PROJECTION_MODE: number;
  69133. /** Skybox coordinates mode */
  69134. static readonly TEXTURE_SKYBOX_MODE: number;
  69135. /** Inverse Cubic coordinates mode */
  69136. static readonly TEXTURE_INVCUBIC_MODE: number;
  69137. /** Equirectangular coordinates mode */
  69138. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69139. /** Equirectangular Fixed coordinates mode */
  69140. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69141. /** Equirectangular Fixed Mirrored coordinates mode */
  69142. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69143. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69144. static readonly SCALEMODE_FLOOR: number;
  69145. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69146. static readonly SCALEMODE_NEAREST: number;
  69147. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69148. static readonly SCALEMODE_CEILING: number;
  69149. /**
  69150. * The dirty texture flag value
  69151. */
  69152. static readonly MATERIAL_TextureDirtyFlag: number;
  69153. /**
  69154. * The dirty light flag value
  69155. */
  69156. static readonly MATERIAL_LightDirtyFlag: number;
  69157. /**
  69158. * The dirty fresnel flag value
  69159. */
  69160. static readonly MATERIAL_FresnelDirtyFlag: number;
  69161. /**
  69162. * The dirty attribute flag value
  69163. */
  69164. static readonly MATERIAL_AttributesDirtyFlag: number;
  69165. /**
  69166. * The dirty misc flag value
  69167. */
  69168. static readonly MATERIAL_MiscDirtyFlag: number;
  69169. /**
  69170. * The all dirty flag value
  69171. */
  69172. static readonly MATERIAL_AllDirtyFlag: number;
  69173. /**
  69174. * Returns the triangle fill mode
  69175. */
  69176. static readonly MATERIAL_TriangleFillMode: number;
  69177. /**
  69178. * Returns the wireframe mode
  69179. */
  69180. static readonly MATERIAL_WireFrameFillMode: number;
  69181. /**
  69182. * Returns the point fill mode
  69183. */
  69184. static readonly MATERIAL_PointFillMode: number;
  69185. /**
  69186. * Returns the point list draw mode
  69187. */
  69188. static readonly MATERIAL_PointListDrawMode: number;
  69189. /**
  69190. * Returns the line list draw mode
  69191. */
  69192. static readonly MATERIAL_LineListDrawMode: number;
  69193. /**
  69194. * Returns the line loop draw mode
  69195. */
  69196. static readonly MATERIAL_LineLoopDrawMode: number;
  69197. /**
  69198. * Returns the line strip draw mode
  69199. */
  69200. static readonly MATERIAL_LineStripDrawMode: number;
  69201. /**
  69202. * Returns the triangle strip draw mode
  69203. */
  69204. static readonly MATERIAL_TriangleStripDrawMode: number;
  69205. /**
  69206. * Returns the triangle fan draw mode
  69207. */
  69208. static readonly MATERIAL_TriangleFanDrawMode: number;
  69209. /**
  69210. * Stores the clock-wise side orientation
  69211. */
  69212. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69213. /**
  69214. * Stores the counter clock-wise side orientation
  69215. */
  69216. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69217. /**
  69218. * Nothing
  69219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69220. */
  69221. static readonly ACTION_NothingTrigger: number;
  69222. /**
  69223. * On pick
  69224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69225. */
  69226. static readonly ACTION_OnPickTrigger: number;
  69227. /**
  69228. * On left pick
  69229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69230. */
  69231. static readonly ACTION_OnLeftPickTrigger: number;
  69232. /**
  69233. * On right pick
  69234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69235. */
  69236. static readonly ACTION_OnRightPickTrigger: number;
  69237. /**
  69238. * On center pick
  69239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69240. */
  69241. static readonly ACTION_OnCenterPickTrigger: number;
  69242. /**
  69243. * On pick down
  69244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69245. */
  69246. static readonly ACTION_OnPickDownTrigger: number;
  69247. /**
  69248. * On double pick
  69249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69250. */
  69251. static readonly ACTION_OnDoublePickTrigger: number;
  69252. /**
  69253. * On pick up
  69254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69255. */
  69256. static readonly ACTION_OnPickUpTrigger: number;
  69257. /**
  69258. * On pick out.
  69259. * This trigger will only be raised if you also declared a OnPickDown
  69260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69261. */
  69262. static readonly ACTION_OnPickOutTrigger: number;
  69263. /**
  69264. * On long press
  69265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69266. */
  69267. static readonly ACTION_OnLongPressTrigger: number;
  69268. /**
  69269. * On pointer over
  69270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69271. */
  69272. static readonly ACTION_OnPointerOverTrigger: number;
  69273. /**
  69274. * On pointer out
  69275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69276. */
  69277. static readonly ACTION_OnPointerOutTrigger: number;
  69278. /**
  69279. * On every frame
  69280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69281. */
  69282. static readonly ACTION_OnEveryFrameTrigger: number;
  69283. /**
  69284. * On intersection enter
  69285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69286. */
  69287. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69288. /**
  69289. * On intersection exit
  69290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69291. */
  69292. static readonly ACTION_OnIntersectionExitTrigger: number;
  69293. /**
  69294. * On key down
  69295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69296. */
  69297. static readonly ACTION_OnKeyDownTrigger: number;
  69298. /**
  69299. * On key up
  69300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69301. */
  69302. static readonly ACTION_OnKeyUpTrigger: number;
  69303. /**
  69304. * Billboard mode will only apply to Y axis
  69305. */
  69306. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69307. /**
  69308. * Billboard mode will apply to all axes
  69309. */
  69310. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69311. /**
  69312. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69313. */
  69314. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69315. /**
  69316. * Gets or sets base Assets URL
  69317. */
  69318. static PARTICLES_BaseAssetsUrl: string;
  69319. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69320. * Test order :
  69321. * Is the bounding sphere outside the frustum ?
  69322. * If not, are the bounding box vertices outside the frustum ?
  69323. * It not, then the cullable object is in the frustum.
  69324. */
  69325. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69326. /** Culling strategy : Bounding Sphere Only.
  69327. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69328. * It's also less accurate than the standard because some not visible objects can still be selected.
  69329. * Test : is the bounding sphere outside the frustum ?
  69330. * If not, then the cullable object is in the frustum.
  69331. */
  69332. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69333. /** Culling strategy : Optimistic Inclusion.
  69334. * This in an inclusion test first, then the standard exclusion test.
  69335. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69336. * 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.
  69337. * Anyway, it's as accurate as the standard strategy.
  69338. * Test :
  69339. * Is the cullable object bounding sphere center in the frustum ?
  69340. * If not, apply the default culling strategy.
  69341. */
  69342. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69343. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69344. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69345. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69346. * 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.
  69347. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69348. * Test :
  69349. * Is the cullable object bounding sphere center in the frustum ?
  69350. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69351. */
  69352. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69353. /**
  69354. * No logging while loading
  69355. */
  69356. static readonly SCENELOADER_NO_LOGGING: number;
  69357. /**
  69358. * Minimal logging while loading
  69359. */
  69360. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69361. /**
  69362. * Summary logging while loading
  69363. */
  69364. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69365. /**
  69366. * Detailled logging while loading
  69367. */
  69368. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69369. }
  69370. }
  69371. declare module BABYLON {
  69372. /**
  69373. * Class used to store and describe the pipeline context associated with an effect
  69374. */
  69375. export interface IPipelineContext {
  69376. /**
  69377. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69378. */
  69379. isAsync: boolean;
  69380. /**
  69381. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69382. */
  69383. isReady: boolean;
  69384. /** @hidden */
  69385. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69386. }
  69387. }
  69388. declare module BABYLON {
  69389. /** @hidden */
  69390. export interface IShaderProcessor {
  69391. attributeProcessor?: (attribute: string) => string;
  69392. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69393. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69394. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69395. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69396. lineProcessor?: (line: string, isFragment: boolean) => string;
  69397. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69398. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69399. }
  69400. }
  69401. declare module BABYLON {
  69402. /** @hidden */
  69403. export interface ProcessingOptions {
  69404. defines: string[];
  69405. indexParameters: any;
  69406. isFragment: boolean;
  69407. shouldUseHighPrecisionShader: boolean;
  69408. supportsUniformBuffers: boolean;
  69409. shadersRepository: string;
  69410. includesShadersStore: {
  69411. [key: string]: string;
  69412. };
  69413. processor?: IShaderProcessor;
  69414. version: string;
  69415. platformName: string;
  69416. lookForClosingBracketForUniformBuffer?: boolean;
  69417. }
  69418. }
  69419. declare module BABYLON {
  69420. /**
  69421. * Helper to manipulate strings
  69422. */
  69423. export class StringTools {
  69424. /**
  69425. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69426. * @param str Source string
  69427. * @param suffix Suffix to search for in the source string
  69428. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69429. */
  69430. static EndsWith(str: string, suffix: string): boolean;
  69431. /**
  69432. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69433. * @param str Source string
  69434. * @param suffix Suffix to search for in the source string
  69435. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69436. */
  69437. static StartsWith(str: string, suffix: string): boolean;
  69438. }
  69439. }
  69440. declare module BABYLON {
  69441. /** @hidden */
  69442. export class ShaderCodeNode {
  69443. line: string;
  69444. children: ShaderCodeNode[];
  69445. additionalDefineKey?: string;
  69446. additionalDefineValue?: string;
  69447. isValid(preprocessors: {
  69448. [key: string]: string;
  69449. }): boolean;
  69450. process(preprocessors: {
  69451. [key: string]: string;
  69452. }, options: ProcessingOptions): string;
  69453. }
  69454. }
  69455. declare module BABYLON {
  69456. /** @hidden */
  69457. export class ShaderCodeCursor {
  69458. private _lines;
  69459. lineIndex: number;
  69460. readonly currentLine: string;
  69461. readonly canRead: boolean;
  69462. lines: string[];
  69463. }
  69464. }
  69465. declare module BABYLON {
  69466. /** @hidden */
  69467. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69468. process(preprocessors: {
  69469. [key: string]: string;
  69470. }, options: ProcessingOptions): string;
  69471. }
  69472. }
  69473. declare module BABYLON {
  69474. /** @hidden */
  69475. export class ShaderDefineExpression {
  69476. isTrue(preprocessors: {
  69477. [key: string]: string;
  69478. }): boolean;
  69479. }
  69480. }
  69481. declare module BABYLON {
  69482. /** @hidden */
  69483. export class ShaderCodeTestNode extends ShaderCodeNode {
  69484. testExpression: ShaderDefineExpression;
  69485. isValid(preprocessors: {
  69486. [key: string]: string;
  69487. }): boolean;
  69488. }
  69489. }
  69490. declare module BABYLON {
  69491. /** @hidden */
  69492. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69493. define: string;
  69494. not: boolean;
  69495. constructor(define: string, not?: boolean);
  69496. isTrue(preprocessors: {
  69497. [key: string]: string;
  69498. }): boolean;
  69499. }
  69500. }
  69501. declare module BABYLON {
  69502. /** @hidden */
  69503. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69504. leftOperand: ShaderDefineExpression;
  69505. rightOperand: ShaderDefineExpression;
  69506. isTrue(preprocessors: {
  69507. [key: string]: string;
  69508. }): boolean;
  69509. }
  69510. }
  69511. declare module BABYLON {
  69512. /** @hidden */
  69513. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69514. leftOperand: ShaderDefineExpression;
  69515. rightOperand: ShaderDefineExpression;
  69516. isTrue(preprocessors: {
  69517. [key: string]: string;
  69518. }): boolean;
  69519. }
  69520. }
  69521. declare module BABYLON {
  69522. /** @hidden */
  69523. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69524. define: string;
  69525. operand: string;
  69526. testValue: string;
  69527. constructor(define: string, operand: string, testValue: string);
  69528. isTrue(preprocessors: {
  69529. [key: string]: string;
  69530. }): boolean;
  69531. }
  69532. }
  69533. declare module BABYLON {
  69534. /**
  69535. * @ignore
  69536. * Application error to support additional information when loading a file
  69537. */
  69538. export class LoadFileError extends Error {
  69539. /** defines the optional web request */
  69540. request?: WebRequest | undefined;
  69541. private static _setPrototypeOf;
  69542. /**
  69543. * Creates a new LoadFileError
  69544. * @param message defines the message of the error
  69545. * @param request defines the optional web request
  69546. */
  69547. constructor(message: string,
  69548. /** defines the optional web request */
  69549. request?: WebRequest | undefined);
  69550. }
  69551. }
  69552. declare module BABYLON {
  69553. /**
  69554. * Class used to enable access to offline support
  69555. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69556. */
  69557. export interface IOfflineProvider {
  69558. /**
  69559. * Gets a boolean indicating if scene must be saved in the database
  69560. */
  69561. enableSceneOffline: boolean;
  69562. /**
  69563. * Gets a boolean indicating if textures must be saved in the database
  69564. */
  69565. enableTexturesOffline: boolean;
  69566. /**
  69567. * Open the offline support and make it available
  69568. * @param successCallback defines the callback to call on success
  69569. * @param errorCallback defines the callback to call on error
  69570. */
  69571. open(successCallback: () => void, errorCallback: () => void): void;
  69572. /**
  69573. * Loads an image from the offline support
  69574. * @param url defines the url to load from
  69575. * @param image defines the target DOM image
  69576. */
  69577. loadImage(url: string, image: HTMLImageElement): void;
  69578. /**
  69579. * Loads a file from offline support
  69580. * @param url defines the URL to load from
  69581. * @param sceneLoaded defines a callback to call on success
  69582. * @param progressCallBack defines a callback to call when progress changed
  69583. * @param errorCallback defines a callback to call on error
  69584. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69585. */
  69586. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69587. }
  69588. }
  69589. declare module BABYLON {
  69590. /**
  69591. * Class used to help managing file picking and drag'n'drop
  69592. * File Storage
  69593. */
  69594. export class FilesInputStore {
  69595. /**
  69596. * List of files ready to be loaded
  69597. */
  69598. static FilesToLoad: {
  69599. [key: string]: File;
  69600. };
  69601. }
  69602. }
  69603. declare module BABYLON {
  69604. /**
  69605. * Class used to define a retry strategy when error happens while loading assets
  69606. */
  69607. export class RetryStrategy {
  69608. /**
  69609. * Function used to defines an exponential back off strategy
  69610. * @param maxRetries defines the maximum number of retries (3 by default)
  69611. * @param baseInterval defines the interval between retries
  69612. * @returns the strategy function to use
  69613. */
  69614. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69615. }
  69616. }
  69617. declare module BABYLON {
  69618. /**
  69619. * @hidden
  69620. */
  69621. export class FileTools {
  69622. /**
  69623. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69624. */
  69625. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69626. /**
  69627. * Gets or sets the base URL to use to load assets
  69628. */
  69629. static BaseUrl: string;
  69630. /**
  69631. * Default behaviour for cors in the application.
  69632. * It can be a string if the expected behavior is identical in the entire app.
  69633. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69634. */
  69635. static CorsBehavior: string | ((url: string | string[]) => string);
  69636. /**
  69637. * Gets or sets a function used to pre-process url before using them to load assets
  69638. */
  69639. static PreprocessUrl: (url: string) => string;
  69640. /**
  69641. * Removes unwanted characters from an url
  69642. * @param url defines the url to clean
  69643. * @returns the cleaned url
  69644. */
  69645. private static _CleanUrl;
  69646. /**
  69647. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69648. * @param url define the url we are trying
  69649. * @param element define the dom element where to configure the cors policy
  69650. */
  69651. static SetCorsBehavior(url: string | string[], element: {
  69652. crossOrigin: string | null;
  69653. }): void;
  69654. /**
  69655. * Loads an image as an HTMLImageElement.
  69656. * @param input url string, ArrayBuffer, or Blob to load
  69657. * @param onLoad callback called when the image successfully loads
  69658. * @param onError callback called when the image fails to load
  69659. * @param offlineProvider offline provider for caching
  69660. * @returns the HTMLImageElement of the loaded image
  69661. */
  69662. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  69663. /**
  69664. * Loads a file
  69665. * @param fileToLoad defines the file to load
  69666. * @param callback defines the callback to call when data is loaded
  69667. * @param progressCallBack defines the callback to call during loading process
  69668. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69669. * @returns a file request object
  69670. */
  69671. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  69672. /**
  69673. * Loads a file
  69674. * @param url url string, ArrayBuffer, or Blob to load
  69675. * @param onSuccess callback called when the file successfully loads
  69676. * @param onProgress callback called while file is loading (if the server supports this mode)
  69677. * @param offlineProvider defines the offline provider for caching
  69678. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69679. * @param onError callback called when the file fails to load
  69680. * @returns a file request object
  69681. */
  69682. 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;
  69683. /**
  69684. * Checks if the loaded document was accessed via `file:`-Protocol.
  69685. * @returns boolean
  69686. */
  69687. static IsFileURL(): boolean;
  69688. }
  69689. }
  69690. declare module BABYLON {
  69691. /** @hidden */
  69692. export class ShaderProcessor {
  69693. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69694. private static _ProcessPrecision;
  69695. private static _ExtractOperation;
  69696. private static _BuildSubExpression;
  69697. private static _BuildExpression;
  69698. private static _MoveCursorWithinIf;
  69699. private static _MoveCursor;
  69700. private static _EvaluatePreProcessors;
  69701. private static _PreparePreProcessors;
  69702. private static _ProcessShaderConversion;
  69703. private static _ProcessIncludes;
  69704. }
  69705. }
  69706. declare module BABYLON {
  69707. /**
  69708. * Class used to hold a RBG color
  69709. */
  69710. export class Color3 {
  69711. /**
  69712. * Defines the red component (between 0 and 1, default is 0)
  69713. */
  69714. r: number;
  69715. /**
  69716. * Defines the green component (between 0 and 1, default is 0)
  69717. */
  69718. g: number;
  69719. /**
  69720. * Defines the blue component (between 0 and 1, default is 0)
  69721. */
  69722. b: number;
  69723. /**
  69724. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69725. * @param r defines the red component (between 0 and 1, default is 0)
  69726. * @param g defines the green component (between 0 and 1, default is 0)
  69727. * @param b defines the blue component (between 0 and 1, default is 0)
  69728. */
  69729. constructor(
  69730. /**
  69731. * Defines the red component (between 0 and 1, default is 0)
  69732. */
  69733. r?: number,
  69734. /**
  69735. * Defines the green component (between 0 and 1, default is 0)
  69736. */
  69737. g?: number,
  69738. /**
  69739. * Defines the blue component (between 0 and 1, default is 0)
  69740. */
  69741. b?: number);
  69742. /**
  69743. * Creates a string with the Color3 current values
  69744. * @returns the string representation of the Color3 object
  69745. */
  69746. toString(): string;
  69747. /**
  69748. * Returns the string "Color3"
  69749. * @returns "Color3"
  69750. */
  69751. getClassName(): string;
  69752. /**
  69753. * Compute the Color3 hash code
  69754. * @returns an unique number that can be used to hash Color3 objects
  69755. */
  69756. getHashCode(): number;
  69757. /**
  69758. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69759. * @param array defines the array where to store the r,g,b components
  69760. * @param index defines an optional index in the target array to define where to start storing values
  69761. * @returns the current Color3 object
  69762. */
  69763. toArray(array: FloatArray, index?: number): Color3;
  69764. /**
  69765. * Returns a new Color4 object from the current Color3 and the given alpha
  69766. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69767. * @returns a new Color4 object
  69768. */
  69769. toColor4(alpha?: number): Color4;
  69770. /**
  69771. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69772. * @returns the new array
  69773. */
  69774. asArray(): number[];
  69775. /**
  69776. * Returns the luminance value
  69777. * @returns a float value
  69778. */
  69779. toLuminance(): number;
  69780. /**
  69781. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69782. * @param otherColor defines the second operand
  69783. * @returns the new Color3 object
  69784. */
  69785. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69786. /**
  69787. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69788. * @param otherColor defines the second operand
  69789. * @param result defines the Color3 object where to store the result
  69790. * @returns the current Color3
  69791. */
  69792. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69793. /**
  69794. * Determines equality between Color3 objects
  69795. * @param otherColor defines the second operand
  69796. * @returns true if the rgb values are equal to the given ones
  69797. */
  69798. equals(otherColor: DeepImmutable<Color3>): boolean;
  69799. /**
  69800. * Determines equality between the current Color3 object and a set of r,b,g values
  69801. * @param r defines the red component to check
  69802. * @param g defines the green component to check
  69803. * @param b defines the blue component to check
  69804. * @returns true if the rgb values are equal to the given ones
  69805. */
  69806. equalsFloats(r: number, g: number, b: number): boolean;
  69807. /**
  69808. * Multiplies in place each rgb value by scale
  69809. * @param scale defines the scaling factor
  69810. * @returns the updated Color3
  69811. */
  69812. scale(scale: number): Color3;
  69813. /**
  69814. * Multiplies the rgb values by scale and stores the result into "result"
  69815. * @param scale defines the scaling factor
  69816. * @param result defines the Color3 object where to store the result
  69817. * @returns the unmodified current Color3
  69818. */
  69819. scaleToRef(scale: number, result: Color3): Color3;
  69820. /**
  69821. * Scale the current Color3 values by a factor and add the result to a given Color3
  69822. * @param scale defines the scale factor
  69823. * @param result defines color to store the result into
  69824. * @returns the unmodified current Color3
  69825. */
  69826. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69827. /**
  69828. * Clamps the rgb values by the min and max values and stores the result into "result"
  69829. * @param min defines minimum clamping value (default is 0)
  69830. * @param max defines maximum clamping value (default is 1)
  69831. * @param result defines color to store the result into
  69832. * @returns the original Color3
  69833. */
  69834. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69835. /**
  69836. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69837. * @param otherColor defines the second operand
  69838. * @returns the new Color3
  69839. */
  69840. add(otherColor: DeepImmutable<Color3>): Color3;
  69841. /**
  69842. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69843. * @param otherColor defines the second operand
  69844. * @param result defines Color3 object to store the result into
  69845. * @returns the unmodified current Color3
  69846. */
  69847. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69848. /**
  69849. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69850. * @param otherColor defines the second operand
  69851. * @returns the new Color3
  69852. */
  69853. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69854. /**
  69855. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69856. * @param otherColor defines the second operand
  69857. * @param result defines Color3 object to store the result into
  69858. * @returns the unmodified current Color3
  69859. */
  69860. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69861. /**
  69862. * Copy the current object
  69863. * @returns a new Color3 copied the current one
  69864. */
  69865. clone(): Color3;
  69866. /**
  69867. * Copies the rgb values from the source in the current Color3
  69868. * @param source defines the source Color3 object
  69869. * @returns the updated Color3 object
  69870. */
  69871. copyFrom(source: DeepImmutable<Color3>): Color3;
  69872. /**
  69873. * Updates the Color3 rgb values from the given floats
  69874. * @param r defines the red component to read from
  69875. * @param g defines the green component to read from
  69876. * @param b defines the blue component to read from
  69877. * @returns the current Color3 object
  69878. */
  69879. copyFromFloats(r: number, g: number, b: number): Color3;
  69880. /**
  69881. * Updates the Color3 rgb values from the given floats
  69882. * @param r defines the red component to read from
  69883. * @param g defines the green component to read from
  69884. * @param b defines the blue component to read from
  69885. * @returns the current Color3 object
  69886. */
  69887. set(r: number, g: number, b: number): Color3;
  69888. /**
  69889. * Compute the Color3 hexadecimal code as a string
  69890. * @returns a string containing the hexadecimal representation of the Color3 object
  69891. */
  69892. toHexString(): string;
  69893. /**
  69894. * Computes a new Color3 converted from the current one to linear space
  69895. * @returns a new Color3 object
  69896. */
  69897. toLinearSpace(): Color3;
  69898. /**
  69899. * Converts current color in rgb space to HSV values
  69900. * @returns a new color3 representing the HSV values
  69901. */
  69902. toHSV(): Color3;
  69903. /**
  69904. * Converts current color in rgb space to HSV values
  69905. * @param result defines the Color3 where to store the HSV values
  69906. */
  69907. toHSVToRef(result: Color3): void;
  69908. /**
  69909. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69910. * @param convertedColor defines the Color3 object where to store the linear space version
  69911. * @returns the unmodified Color3
  69912. */
  69913. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69914. /**
  69915. * Computes a new Color3 converted from the current one to gamma space
  69916. * @returns a new Color3 object
  69917. */
  69918. toGammaSpace(): Color3;
  69919. /**
  69920. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69921. * @param convertedColor defines the Color3 object where to store the gamma space version
  69922. * @returns the unmodified Color3
  69923. */
  69924. toGammaSpaceToRef(convertedColor: Color3): Color3;
  69925. private static _BlackReadOnly;
  69926. /**
  69927. * Convert Hue, saturation and value to a Color3 (RGB)
  69928. * @param hue defines the hue
  69929. * @param saturation defines the saturation
  69930. * @param value defines the value
  69931. * @param result defines the Color3 where to store the RGB values
  69932. */
  69933. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  69934. /**
  69935. * Creates a new Color3 from the string containing valid hexadecimal values
  69936. * @param hex defines a string containing valid hexadecimal values
  69937. * @returns a new Color3 object
  69938. */
  69939. static FromHexString(hex: string): Color3;
  69940. /**
  69941. * Creates a new Color3 from the starting index of the given array
  69942. * @param array defines the source array
  69943. * @param offset defines an offset in the source array
  69944. * @returns a new Color3 object
  69945. */
  69946. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  69947. /**
  69948. * Creates a new Color3 from integer values (< 256)
  69949. * @param r defines the red component to read from (value between 0 and 255)
  69950. * @param g defines the green component to read from (value between 0 and 255)
  69951. * @param b defines the blue component to read from (value between 0 and 255)
  69952. * @returns a new Color3 object
  69953. */
  69954. static FromInts(r: number, g: number, b: number): Color3;
  69955. /**
  69956. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69957. * @param start defines the start Color3 value
  69958. * @param end defines the end Color3 value
  69959. * @param amount defines the gradient value between start and end
  69960. * @returns a new Color3 object
  69961. */
  69962. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69963. /**
  69964. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69965. * @param left defines the start value
  69966. * @param right defines the end value
  69967. * @param amount defines the gradient factor
  69968. * @param result defines the Color3 object where to store the result
  69969. */
  69970. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69971. /**
  69972. * Returns a Color3 value containing a red color
  69973. * @returns a new Color3 object
  69974. */
  69975. static Red(): Color3;
  69976. /**
  69977. * Returns a Color3 value containing a green color
  69978. * @returns a new Color3 object
  69979. */
  69980. static Green(): Color3;
  69981. /**
  69982. * Returns a Color3 value containing a blue color
  69983. * @returns a new Color3 object
  69984. */
  69985. static Blue(): Color3;
  69986. /**
  69987. * Returns a Color3 value containing a black color
  69988. * @returns a new Color3 object
  69989. */
  69990. static Black(): Color3;
  69991. /**
  69992. * Gets a Color3 value containing a black color that must not be updated
  69993. */
  69994. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69995. /**
  69996. * Returns a Color3 value containing a white color
  69997. * @returns a new Color3 object
  69998. */
  69999. static White(): Color3;
  70000. /**
  70001. * Returns a Color3 value containing a purple color
  70002. * @returns a new Color3 object
  70003. */
  70004. static Purple(): Color3;
  70005. /**
  70006. * Returns a Color3 value containing a magenta color
  70007. * @returns a new Color3 object
  70008. */
  70009. static Magenta(): Color3;
  70010. /**
  70011. * Returns a Color3 value containing a yellow color
  70012. * @returns a new Color3 object
  70013. */
  70014. static Yellow(): Color3;
  70015. /**
  70016. * Returns a Color3 value containing a gray color
  70017. * @returns a new Color3 object
  70018. */
  70019. static Gray(): Color3;
  70020. /**
  70021. * Returns a Color3 value containing a teal color
  70022. * @returns a new Color3 object
  70023. */
  70024. static Teal(): Color3;
  70025. /**
  70026. * Returns a Color3 value containing a random color
  70027. * @returns a new Color3 object
  70028. */
  70029. static Random(): Color3;
  70030. }
  70031. /**
  70032. * Class used to hold a RBGA color
  70033. */
  70034. export class Color4 {
  70035. /**
  70036. * Defines the red component (between 0 and 1, default is 0)
  70037. */
  70038. r: number;
  70039. /**
  70040. * Defines the green component (between 0 and 1, default is 0)
  70041. */
  70042. g: number;
  70043. /**
  70044. * Defines the blue component (between 0 and 1, default is 0)
  70045. */
  70046. b: number;
  70047. /**
  70048. * Defines the alpha component (between 0 and 1, default is 1)
  70049. */
  70050. a: number;
  70051. /**
  70052. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70053. * @param r defines the red component (between 0 and 1, default is 0)
  70054. * @param g defines the green component (between 0 and 1, default is 0)
  70055. * @param b defines the blue component (between 0 and 1, default is 0)
  70056. * @param a defines the alpha component (between 0 and 1, default is 1)
  70057. */
  70058. constructor(
  70059. /**
  70060. * Defines the red component (between 0 and 1, default is 0)
  70061. */
  70062. r?: number,
  70063. /**
  70064. * Defines the green component (between 0 and 1, default is 0)
  70065. */
  70066. g?: number,
  70067. /**
  70068. * Defines the blue component (between 0 and 1, default is 0)
  70069. */
  70070. b?: number,
  70071. /**
  70072. * Defines the alpha component (between 0 and 1, default is 1)
  70073. */
  70074. a?: number);
  70075. /**
  70076. * Adds in place the given Color4 values to the current Color4 object
  70077. * @param right defines the second operand
  70078. * @returns the current updated Color4 object
  70079. */
  70080. addInPlace(right: DeepImmutable<Color4>): Color4;
  70081. /**
  70082. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70083. * @returns the new array
  70084. */
  70085. asArray(): number[];
  70086. /**
  70087. * Stores from the starting index in the given array the Color4 successive values
  70088. * @param array defines the array where to store the r,g,b components
  70089. * @param index defines an optional index in the target array to define where to start storing values
  70090. * @returns the current Color4 object
  70091. */
  70092. toArray(array: number[], index?: number): Color4;
  70093. /**
  70094. * Determines equality between Color4 objects
  70095. * @param otherColor defines the second operand
  70096. * @returns true if the rgba values are equal to the given ones
  70097. */
  70098. equals(otherColor: DeepImmutable<Color4>): boolean;
  70099. /**
  70100. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70101. * @param right defines the second operand
  70102. * @returns a new Color4 object
  70103. */
  70104. add(right: DeepImmutable<Color4>): Color4;
  70105. /**
  70106. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70107. * @param right defines the second operand
  70108. * @returns a new Color4 object
  70109. */
  70110. subtract(right: DeepImmutable<Color4>): Color4;
  70111. /**
  70112. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70113. * @param right defines the second operand
  70114. * @param result defines the Color4 object where to store the result
  70115. * @returns the current Color4 object
  70116. */
  70117. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70118. /**
  70119. * Creates a new Color4 with the current Color4 values multiplied by scale
  70120. * @param scale defines the scaling factor to apply
  70121. * @returns a new Color4 object
  70122. */
  70123. scale(scale: number): Color4;
  70124. /**
  70125. * Multiplies the current Color4 values by scale and stores the result in "result"
  70126. * @param scale defines the scaling factor to apply
  70127. * @param result defines the Color4 object where to store the result
  70128. * @returns the current unmodified Color4
  70129. */
  70130. scaleToRef(scale: number, result: Color4): Color4;
  70131. /**
  70132. * Scale the current Color4 values by a factor and add the result to a given Color4
  70133. * @param scale defines the scale factor
  70134. * @param result defines the Color4 object where to store the result
  70135. * @returns the unmodified current Color4
  70136. */
  70137. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70138. /**
  70139. * Clamps the rgb values by the min and max values and stores the result into "result"
  70140. * @param min defines minimum clamping value (default is 0)
  70141. * @param max defines maximum clamping value (default is 1)
  70142. * @param result defines color to store the result into.
  70143. * @returns the cuurent Color4
  70144. */
  70145. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70146. /**
  70147. * Multipy an Color4 value by another and return a new Color4 object
  70148. * @param color defines the Color4 value to multiply by
  70149. * @returns a new Color4 object
  70150. */
  70151. multiply(color: Color4): Color4;
  70152. /**
  70153. * Multipy a Color4 value by another and push the result in a reference value
  70154. * @param color defines the Color4 value to multiply by
  70155. * @param result defines the Color4 to fill the result in
  70156. * @returns the result Color4
  70157. */
  70158. multiplyToRef(color: Color4, result: Color4): Color4;
  70159. /**
  70160. * Creates a string with the Color4 current values
  70161. * @returns the string representation of the Color4 object
  70162. */
  70163. toString(): string;
  70164. /**
  70165. * Returns the string "Color4"
  70166. * @returns "Color4"
  70167. */
  70168. getClassName(): string;
  70169. /**
  70170. * Compute the Color4 hash code
  70171. * @returns an unique number that can be used to hash Color4 objects
  70172. */
  70173. getHashCode(): number;
  70174. /**
  70175. * Creates a new Color4 copied from the current one
  70176. * @returns a new Color4 object
  70177. */
  70178. clone(): Color4;
  70179. /**
  70180. * Copies the given Color4 values into the current one
  70181. * @param source defines the source Color4 object
  70182. * @returns the current updated Color4 object
  70183. */
  70184. copyFrom(source: Color4): Color4;
  70185. /**
  70186. * Copies the given float values into the current one
  70187. * @param r defines the red component to read from
  70188. * @param g defines the green component to read from
  70189. * @param b defines the blue component to read from
  70190. * @param a defines the alpha component to read from
  70191. * @returns the current updated Color4 object
  70192. */
  70193. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70194. /**
  70195. * Copies the given float values into the current one
  70196. * @param r defines the red component to read from
  70197. * @param g defines the green component to read from
  70198. * @param b defines the blue component to read from
  70199. * @param a defines the alpha component to read from
  70200. * @returns the current updated Color4 object
  70201. */
  70202. set(r: number, g: number, b: number, a: number): Color4;
  70203. /**
  70204. * Compute the Color4 hexadecimal code as a string
  70205. * @returns a string containing the hexadecimal representation of the Color4 object
  70206. */
  70207. toHexString(): string;
  70208. /**
  70209. * Computes a new Color4 converted from the current one to linear space
  70210. * @returns a new Color4 object
  70211. */
  70212. toLinearSpace(): Color4;
  70213. /**
  70214. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70215. * @param convertedColor defines the Color4 object where to store the linear space version
  70216. * @returns the unmodified Color4
  70217. */
  70218. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70219. /**
  70220. * Computes a new Color4 converted from the current one to gamma space
  70221. * @returns a new Color4 object
  70222. */
  70223. toGammaSpace(): Color4;
  70224. /**
  70225. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70226. * @param convertedColor defines the Color4 object where to store the gamma space version
  70227. * @returns the unmodified Color4
  70228. */
  70229. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70230. /**
  70231. * Creates a new Color4 from the string containing valid hexadecimal values
  70232. * @param hex defines a string containing valid hexadecimal values
  70233. * @returns a new Color4 object
  70234. */
  70235. static FromHexString(hex: string): Color4;
  70236. /**
  70237. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70238. * @param left defines the start value
  70239. * @param right defines the end value
  70240. * @param amount defines the gradient factor
  70241. * @returns a new Color4 object
  70242. */
  70243. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70244. /**
  70245. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70246. * @param left defines the start value
  70247. * @param right defines the end value
  70248. * @param amount defines the gradient factor
  70249. * @param result defines the Color4 object where to store data
  70250. */
  70251. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70252. /**
  70253. * Creates a new Color4 from a Color3 and an alpha value
  70254. * @param color3 defines the source Color3 to read from
  70255. * @param alpha defines the alpha component (1.0 by default)
  70256. * @returns a new Color4 object
  70257. */
  70258. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70259. /**
  70260. * Creates a new Color4 from the starting index element of the given array
  70261. * @param array defines the source array to read from
  70262. * @param offset defines the offset in the source array
  70263. * @returns a new Color4 object
  70264. */
  70265. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70266. /**
  70267. * Creates a new Color3 from integer values (< 256)
  70268. * @param r defines the red component to read from (value between 0 and 255)
  70269. * @param g defines the green component to read from (value between 0 and 255)
  70270. * @param b defines the blue component to read from (value between 0 and 255)
  70271. * @param a defines the alpha component to read from (value between 0 and 255)
  70272. * @returns a new Color3 object
  70273. */
  70274. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70275. /**
  70276. * Check the content of a given array and convert it to an array containing RGBA data
  70277. * If the original array was already containing count * 4 values then it is returned directly
  70278. * @param colors defines the array to check
  70279. * @param count defines the number of RGBA data to expect
  70280. * @returns an array containing count * 4 values (RGBA)
  70281. */
  70282. static CheckColors4(colors: number[], count: number): number[];
  70283. }
  70284. /**
  70285. * @hidden
  70286. */
  70287. export class TmpColors {
  70288. static Color3: Color3[];
  70289. static Color4: Color4[];
  70290. }
  70291. }
  70292. declare module BABYLON {
  70293. /**
  70294. * Class representing spherical harmonics coefficients to the 3rd degree
  70295. */
  70296. export class SphericalHarmonics {
  70297. /**
  70298. * Defines whether or not the harmonics have been prescaled for rendering.
  70299. */
  70300. preScaled: boolean;
  70301. /**
  70302. * The l0,0 coefficients of the spherical harmonics
  70303. */
  70304. l00: Vector3;
  70305. /**
  70306. * The l1,-1 coefficients of the spherical harmonics
  70307. */
  70308. l1_1: Vector3;
  70309. /**
  70310. * The l1,0 coefficients of the spherical harmonics
  70311. */
  70312. l10: Vector3;
  70313. /**
  70314. * The l1,1 coefficients of the spherical harmonics
  70315. */
  70316. l11: Vector3;
  70317. /**
  70318. * The l2,-2 coefficients of the spherical harmonics
  70319. */
  70320. l2_2: Vector3;
  70321. /**
  70322. * The l2,-1 coefficients of the spherical harmonics
  70323. */
  70324. l2_1: Vector3;
  70325. /**
  70326. * The l2,0 coefficients of the spherical harmonics
  70327. */
  70328. l20: Vector3;
  70329. /**
  70330. * The l2,1 coefficients of the spherical harmonics
  70331. */
  70332. l21: Vector3;
  70333. /**
  70334. * The l2,2 coefficients of the spherical harmonics
  70335. */
  70336. l22: Vector3;
  70337. /**
  70338. * Adds a light to the spherical harmonics
  70339. * @param direction the direction of the light
  70340. * @param color the color of the light
  70341. * @param deltaSolidAngle the delta solid angle of the light
  70342. */
  70343. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70344. /**
  70345. * Scales the spherical harmonics by the given amount
  70346. * @param scale the amount to scale
  70347. */
  70348. scaleInPlace(scale: number): void;
  70349. /**
  70350. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70351. *
  70352. * ```
  70353. * E_lm = A_l * L_lm
  70354. * ```
  70355. *
  70356. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70357. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70358. * the scaling factors are given in equation 9.
  70359. */
  70360. convertIncidentRadianceToIrradiance(): void;
  70361. /**
  70362. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70363. *
  70364. * ```
  70365. * L = (1/pi) * E * rho
  70366. * ```
  70367. *
  70368. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70369. */
  70370. convertIrradianceToLambertianRadiance(): void;
  70371. /**
  70372. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70373. * required operations at run time.
  70374. *
  70375. * This is simply done by scaling back the SH with Ylm constants parameter.
  70376. * The trigonometric part being applied by the shader at run time.
  70377. */
  70378. preScaleForRendering(): void;
  70379. /**
  70380. * Constructs a spherical harmonics from an array.
  70381. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70382. * @returns the spherical harmonics
  70383. */
  70384. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70385. /**
  70386. * Gets the spherical harmonics from polynomial
  70387. * @param polynomial the spherical polynomial
  70388. * @returns the spherical harmonics
  70389. */
  70390. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70391. }
  70392. /**
  70393. * Class representing spherical polynomial coefficients to the 3rd degree
  70394. */
  70395. export class SphericalPolynomial {
  70396. private _harmonics;
  70397. /**
  70398. * The spherical harmonics used to create the polynomials.
  70399. */
  70400. readonly preScaledHarmonics: SphericalHarmonics;
  70401. /**
  70402. * The x coefficients of the spherical polynomial
  70403. */
  70404. x: Vector3;
  70405. /**
  70406. * The y coefficients of the spherical polynomial
  70407. */
  70408. y: Vector3;
  70409. /**
  70410. * The z coefficients of the spherical polynomial
  70411. */
  70412. z: Vector3;
  70413. /**
  70414. * The xx coefficients of the spherical polynomial
  70415. */
  70416. xx: Vector3;
  70417. /**
  70418. * The yy coefficients of the spherical polynomial
  70419. */
  70420. yy: Vector3;
  70421. /**
  70422. * The zz coefficients of the spherical polynomial
  70423. */
  70424. zz: Vector3;
  70425. /**
  70426. * The xy coefficients of the spherical polynomial
  70427. */
  70428. xy: Vector3;
  70429. /**
  70430. * The yz coefficients of the spherical polynomial
  70431. */
  70432. yz: Vector3;
  70433. /**
  70434. * The zx coefficients of the spherical polynomial
  70435. */
  70436. zx: Vector3;
  70437. /**
  70438. * Adds an ambient color to the spherical polynomial
  70439. * @param color the color to add
  70440. */
  70441. addAmbient(color: Color3): void;
  70442. /**
  70443. * Scales the spherical polynomial by the given amount
  70444. * @param scale the amount to scale
  70445. */
  70446. scaleInPlace(scale: number): void;
  70447. /**
  70448. * Gets the spherical polynomial from harmonics
  70449. * @param harmonics the spherical harmonics
  70450. * @returns the spherical polynomial
  70451. */
  70452. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70453. /**
  70454. * Constructs a spherical polynomial from an array.
  70455. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70456. * @returns the spherical polynomial
  70457. */
  70458. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70459. }
  70460. }
  70461. declare module BABYLON {
  70462. /**
  70463. * Define options used to create a render target texture
  70464. */
  70465. export class RenderTargetCreationOptions {
  70466. /**
  70467. * Specifies is mipmaps must be generated
  70468. */
  70469. generateMipMaps?: boolean;
  70470. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70471. generateDepthBuffer?: boolean;
  70472. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70473. generateStencilBuffer?: boolean;
  70474. /** Defines texture type (int by default) */
  70475. type?: number;
  70476. /** Defines sampling mode (trilinear by default) */
  70477. samplingMode?: number;
  70478. /** Defines format (RGBA by default) */
  70479. format?: number;
  70480. }
  70481. }
  70482. declare module BABYLON {
  70483. /**
  70484. * @hidden
  70485. **/
  70486. export class _AlphaState {
  70487. private _isAlphaBlendDirty;
  70488. private _isBlendFunctionParametersDirty;
  70489. private _isBlendEquationParametersDirty;
  70490. private _isBlendConstantsDirty;
  70491. private _alphaBlend;
  70492. private _blendFunctionParameters;
  70493. private _blendEquationParameters;
  70494. private _blendConstants;
  70495. /**
  70496. * Initializes the state.
  70497. */
  70498. constructor();
  70499. readonly isDirty: boolean;
  70500. alphaBlend: boolean;
  70501. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  70502. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  70503. setAlphaEquationParameters(rgb: number, alpha: number): void;
  70504. reset(): void;
  70505. apply(gl: WebGLRenderingContext): void;
  70506. }
  70507. }
  70508. declare module BABYLON {
  70509. /**
  70510. * @hidden
  70511. **/
  70512. export class _DepthCullingState {
  70513. private _isDepthTestDirty;
  70514. private _isDepthMaskDirty;
  70515. private _isDepthFuncDirty;
  70516. private _isCullFaceDirty;
  70517. private _isCullDirty;
  70518. private _isZOffsetDirty;
  70519. private _isFrontFaceDirty;
  70520. private _depthTest;
  70521. private _depthMask;
  70522. private _depthFunc;
  70523. private _cull;
  70524. private _cullFace;
  70525. private _zOffset;
  70526. private _frontFace;
  70527. /**
  70528. * Initializes the state.
  70529. */
  70530. constructor();
  70531. readonly isDirty: boolean;
  70532. zOffset: number;
  70533. cullFace: Nullable<number>;
  70534. cull: Nullable<boolean>;
  70535. depthFunc: Nullable<number>;
  70536. depthMask: boolean;
  70537. depthTest: boolean;
  70538. frontFace: Nullable<number>;
  70539. reset(): void;
  70540. apply(gl: WebGLRenderingContext): void;
  70541. }
  70542. }
  70543. declare module BABYLON {
  70544. /**
  70545. * @hidden
  70546. **/
  70547. export class _StencilState {
  70548. /** 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 */
  70549. static readonly ALWAYS: number;
  70550. /** Passed to stencilOperation to specify that stencil value must be kept */
  70551. static readonly KEEP: number;
  70552. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70553. static readonly REPLACE: number;
  70554. private _isStencilTestDirty;
  70555. private _isStencilMaskDirty;
  70556. private _isStencilFuncDirty;
  70557. private _isStencilOpDirty;
  70558. private _stencilTest;
  70559. private _stencilMask;
  70560. private _stencilFunc;
  70561. private _stencilFuncRef;
  70562. private _stencilFuncMask;
  70563. private _stencilOpStencilFail;
  70564. private _stencilOpDepthFail;
  70565. private _stencilOpStencilDepthPass;
  70566. readonly isDirty: boolean;
  70567. stencilFunc: number;
  70568. stencilFuncRef: number;
  70569. stencilFuncMask: number;
  70570. stencilOpStencilFail: number;
  70571. stencilOpDepthFail: number;
  70572. stencilOpStencilDepthPass: number;
  70573. stencilMask: number;
  70574. stencilTest: boolean;
  70575. constructor();
  70576. reset(): void;
  70577. apply(gl: WebGLRenderingContext): void;
  70578. }
  70579. }
  70580. declare module BABYLON {
  70581. /**
  70582. * @hidden
  70583. **/
  70584. export class _TimeToken {
  70585. _startTimeQuery: Nullable<WebGLQuery>;
  70586. _endTimeQuery: Nullable<WebGLQuery>;
  70587. _timeElapsedQuery: Nullable<WebGLQuery>;
  70588. _timeElapsedQueryEnded: boolean;
  70589. }
  70590. }
  70591. declare module BABYLON {
  70592. /**
  70593. * Class used to evalaute queries containing `and` and `or` operators
  70594. */
  70595. export class AndOrNotEvaluator {
  70596. /**
  70597. * Evaluate a query
  70598. * @param query defines the query to evaluate
  70599. * @param evaluateCallback defines the callback used to filter result
  70600. * @returns true if the query matches
  70601. */
  70602. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70603. private static _HandleParenthesisContent;
  70604. private static _SimplifyNegation;
  70605. }
  70606. }
  70607. declare module BABYLON {
  70608. /**
  70609. * Class used to store custom tags
  70610. */
  70611. export class Tags {
  70612. /**
  70613. * Adds support for tags on the given object
  70614. * @param obj defines the object to use
  70615. */
  70616. static EnableFor(obj: any): void;
  70617. /**
  70618. * Removes tags support
  70619. * @param obj defines the object to use
  70620. */
  70621. static DisableFor(obj: any): void;
  70622. /**
  70623. * Gets a boolean indicating if the given object has tags
  70624. * @param obj defines the object to use
  70625. * @returns a boolean
  70626. */
  70627. static HasTags(obj: any): boolean;
  70628. /**
  70629. * Gets the tags available on a given object
  70630. * @param obj defines the object to use
  70631. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70632. * @returns the tags
  70633. */
  70634. static GetTags(obj: any, asString?: boolean): any;
  70635. /**
  70636. * Adds tags to an object
  70637. * @param obj defines the object to use
  70638. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70639. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70640. */
  70641. static AddTagsTo(obj: any, tagsString: string): void;
  70642. /**
  70643. * @hidden
  70644. */
  70645. static _AddTagTo(obj: any, tag: string): void;
  70646. /**
  70647. * Removes specific tags from a specific object
  70648. * @param obj defines the object to use
  70649. * @param tagsString defines the tags to remove
  70650. */
  70651. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70652. /**
  70653. * @hidden
  70654. */
  70655. static _RemoveTagFrom(obj: any, tag: string): void;
  70656. /**
  70657. * Defines if tags hosted on an object match a given query
  70658. * @param obj defines the object to use
  70659. * @param tagsQuery defines the tag query
  70660. * @returns a boolean
  70661. */
  70662. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70663. }
  70664. }
  70665. declare module BABYLON {
  70666. /**
  70667. * Defines potential orientation for back face culling
  70668. */
  70669. export enum Orientation {
  70670. /**
  70671. * Clockwise
  70672. */
  70673. CW = 0,
  70674. /** Counter clockwise */
  70675. CCW = 1
  70676. }
  70677. /** Class used to represent a Bezier curve */
  70678. export class BezierCurve {
  70679. /**
  70680. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  70681. * @param t defines the time
  70682. * @param x1 defines the left coordinate on X axis
  70683. * @param y1 defines the left coordinate on Y axis
  70684. * @param x2 defines the right coordinate on X axis
  70685. * @param y2 defines the right coordinate on Y axis
  70686. * @returns the interpolated value
  70687. */
  70688. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  70689. }
  70690. /**
  70691. * Defines angle representation
  70692. */
  70693. export class Angle {
  70694. private _radians;
  70695. /**
  70696. * Creates an Angle object of "radians" radians (float).
  70697. * @param radians the angle in radians
  70698. */
  70699. constructor(radians: number);
  70700. /**
  70701. * Get value in degrees
  70702. * @returns the Angle value in degrees (float)
  70703. */
  70704. degrees(): number;
  70705. /**
  70706. * Get value in radians
  70707. * @returns the Angle value in radians (float)
  70708. */
  70709. radians(): number;
  70710. /**
  70711. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  70712. * @param a defines first vector
  70713. * @param b defines second vector
  70714. * @returns a new Angle
  70715. */
  70716. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70717. /**
  70718. * Gets a new Angle object from the given float in radians
  70719. * @param radians defines the angle value in radians
  70720. * @returns a new Angle
  70721. */
  70722. static FromRadians(radians: number): Angle;
  70723. /**
  70724. * Gets a new Angle object from the given float in degrees
  70725. * @param degrees defines the angle value in degrees
  70726. * @returns a new Angle
  70727. */
  70728. static FromDegrees(degrees: number): Angle;
  70729. }
  70730. /**
  70731. * This represents an arc in a 2d space.
  70732. */
  70733. export class Arc2 {
  70734. /** Defines the start point of the arc */
  70735. startPoint: Vector2;
  70736. /** Defines the mid point of the arc */
  70737. midPoint: Vector2;
  70738. /** Defines the end point of the arc */
  70739. endPoint: Vector2;
  70740. /**
  70741. * Defines the center point of the arc.
  70742. */
  70743. centerPoint: Vector2;
  70744. /**
  70745. * Defines the radius of the arc.
  70746. */
  70747. radius: number;
  70748. /**
  70749. * Defines the angle of the arc (from mid point to end point).
  70750. */
  70751. angle: Angle;
  70752. /**
  70753. * Defines the start angle of the arc (from start point to middle point).
  70754. */
  70755. startAngle: Angle;
  70756. /**
  70757. * Defines the orientation of the arc (clock wise/counter clock wise).
  70758. */
  70759. orientation: Orientation;
  70760. /**
  70761. * Creates an Arc object from the three given points : start, middle and end.
  70762. * @param startPoint Defines the start point of the arc
  70763. * @param midPoint Defines the midlle point of the arc
  70764. * @param endPoint Defines the end point of the arc
  70765. */
  70766. constructor(
  70767. /** Defines the start point of the arc */
  70768. startPoint: Vector2,
  70769. /** Defines the mid point of the arc */
  70770. midPoint: Vector2,
  70771. /** Defines the end point of the arc */
  70772. endPoint: Vector2);
  70773. }
  70774. /**
  70775. * Represents a 2D path made up of multiple 2D points
  70776. */
  70777. export class Path2 {
  70778. private _points;
  70779. private _length;
  70780. /**
  70781. * If the path start and end point are the same
  70782. */
  70783. closed: boolean;
  70784. /**
  70785. * Creates a Path2 object from the starting 2D coordinates x and y.
  70786. * @param x the starting points x value
  70787. * @param y the starting points y value
  70788. */
  70789. constructor(x: number, y: number);
  70790. /**
  70791. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70792. * @param x the added points x value
  70793. * @param y the added points y value
  70794. * @returns the updated Path2.
  70795. */
  70796. addLineTo(x: number, y: number): Path2;
  70797. /**
  70798. * 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.
  70799. * @param midX middle point x value
  70800. * @param midY middle point y value
  70801. * @param endX end point x value
  70802. * @param endY end point y value
  70803. * @param numberOfSegments (default: 36)
  70804. * @returns the updated Path2.
  70805. */
  70806. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70807. /**
  70808. * Closes the Path2.
  70809. * @returns the Path2.
  70810. */
  70811. close(): Path2;
  70812. /**
  70813. * Gets the sum of the distance between each sequential point in the path
  70814. * @returns the Path2 total length (float).
  70815. */
  70816. length(): number;
  70817. /**
  70818. * Gets the points which construct the path
  70819. * @returns the Path2 internal array of points.
  70820. */
  70821. getPoints(): Vector2[];
  70822. /**
  70823. * Retreives the point at the distance aways from the starting point
  70824. * @param normalizedLengthPosition the length along the path to retreive the point from
  70825. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70826. */
  70827. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70828. /**
  70829. * Creates a new path starting from an x and y position
  70830. * @param x starting x value
  70831. * @param y starting y value
  70832. * @returns a new Path2 starting at the coordinates (x, y).
  70833. */
  70834. static StartingAt(x: number, y: number): Path2;
  70835. }
  70836. /**
  70837. * Represents a 3D path made up of multiple 3D points
  70838. */
  70839. export class Path3D {
  70840. /**
  70841. * an array of Vector3, the curve axis of the Path3D
  70842. */
  70843. path: Vector3[];
  70844. private _curve;
  70845. private _distances;
  70846. private _tangents;
  70847. private _normals;
  70848. private _binormals;
  70849. private _raw;
  70850. /**
  70851. * new Path3D(path, normal, raw)
  70852. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70853. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70854. * @param path an array of Vector3, the curve axis of the Path3D
  70855. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70856. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70857. */
  70858. constructor(
  70859. /**
  70860. * an array of Vector3, the curve axis of the Path3D
  70861. */
  70862. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  70863. /**
  70864. * Returns the Path3D array of successive Vector3 designing its curve.
  70865. * @returns the Path3D array of successive Vector3 designing its curve.
  70866. */
  70867. getCurve(): Vector3[];
  70868. /**
  70869. * Returns an array populated with tangent vectors on each Path3D curve point.
  70870. * @returns an array populated with tangent vectors on each Path3D curve point.
  70871. */
  70872. getTangents(): Vector3[];
  70873. /**
  70874. * Returns an array populated with normal vectors on each Path3D curve point.
  70875. * @returns an array populated with normal vectors on each Path3D curve point.
  70876. */
  70877. getNormals(): Vector3[];
  70878. /**
  70879. * Returns an array populated with binormal vectors on each Path3D curve point.
  70880. * @returns an array populated with binormal vectors on each Path3D curve point.
  70881. */
  70882. getBinormals(): Vector3[];
  70883. /**
  70884. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  70885. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  70886. */
  70887. getDistances(): number[];
  70888. /**
  70889. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  70890. * @param path path which all values are copied into the curves points
  70891. * @param firstNormal which should be projected onto the curve
  70892. * @returns the same object updated.
  70893. */
  70894. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  70895. private _compute;
  70896. private _getFirstNonNullVector;
  70897. private _getLastNonNullVector;
  70898. private _normalVector;
  70899. }
  70900. /**
  70901. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70902. * A Curve3 is designed from a series of successive Vector3.
  70903. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  70904. */
  70905. export class Curve3 {
  70906. private _points;
  70907. private _length;
  70908. /**
  70909. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  70910. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  70911. * @param v1 (Vector3) the control point
  70912. * @param v2 (Vector3) the end point of the Quadratic Bezier
  70913. * @param nbPoints (integer) the wanted number of points in the curve
  70914. * @returns the created Curve3
  70915. */
  70916. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70917. /**
  70918. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  70919. * @param v0 (Vector3) the origin point of the Cubic Bezier
  70920. * @param v1 (Vector3) the first control point
  70921. * @param v2 (Vector3) the second control point
  70922. * @param v3 (Vector3) the end point of the Cubic Bezier
  70923. * @param nbPoints (integer) the wanted number of points in the curve
  70924. * @returns the created Curve3
  70925. */
  70926. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70927. /**
  70928. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  70929. * @param p1 (Vector3) the origin point of the Hermite Spline
  70930. * @param t1 (Vector3) the tangent vector at the origin point
  70931. * @param p2 (Vector3) the end point of the Hermite Spline
  70932. * @param t2 (Vector3) the tangent vector at the end point
  70933. * @param nbPoints (integer) the wanted number of points in the curve
  70934. * @returns the created Curve3
  70935. */
  70936. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70937. /**
  70938. * Returns a Curve3 object along a CatmullRom Spline curve :
  70939. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  70940. * @param nbPoints (integer) the wanted number of points between each curve control points
  70941. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  70942. * @returns the created Curve3
  70943. */
  70944. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  70945. /**
  70946. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70947. * A Curve3 is designed from a series of successive Vector3.
  70948. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  70949. * @param points points which make up the curve
  70950. */
  70951. constructor(points: Vector3[]);
  70952. /**
  70953. * @returns the Curve3 stored array of successive Vector3
  70954. */
  70955. getPoints(): Vector3[];
  70956. /**
  70957. * @returns the computed length (float) of the curve.
  70958. */
  70959. length(): number;
  70960. /**
  70961. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  70962. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  70963. * curveA and curveB keep unchanged.
  70964. * @param curve the curve to continue from this curve
  70965. * @returns the newly constructed curve
  70966. */
  70967. continue(curve: DeepImmutable<Curve3>): Curve3;
  70968. private _computeLength;
  70969. }
  70970. }
  70971. declare module BABYLON {
  70972. /**
  70973. * This represents the main contract an easing function should follow.
  70974. * Easing functions are used throughout the animation system.
  70975. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70976. */
  70977. export interface IEasingFunction {
  70978. /**
  70979. * Given an input gradient between 0 and 1, this returns the corrseponding value
  70980. * of the easing function.
  70981. * The link below provides some of the most common examples of easing functions.
  70982. * @see https://easings.net/
  70983. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70984. * @returns the corresponding value on the curve defined by the easing function
  70985. */
  70986. ease(gradient: number): number;
  70987. }
  70988. /**
  70989. * Base class used for every default easing function.
  70990. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70991. */
  70992. export class EasingFunction implements IEasingFunction {
  70993. /**
  70994. * Interpolation follows the mathematical formula associated with the easing function.
  70995. */
  70996. static readonly EASINGMODE_EASEIN: number;
  70997. /**
  70998. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70999. */
  71000. static readonly EASINGMODE_EASEOUT: number;
  71001. /**
  71002. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71003. */
  71004. static readonly EASINGMODE_EASEINOUT: number;
  71005. private _easingMode;
  71006. /**
  71007. * Sets the easing mode of the current function.
  71008. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71009. */
  71010. setEasingMode(easingMode: number): void;
  71011. /**
  71012. * Gets the current easing mode.
  71013. * @returns the easing mode
  71014. */
  71015. getEasingMode(): number;
  71016. /**
  71017. * @hidden
  71018. */
  71019. easeInCore(gradient: number): number;
  71020. /**
  71021. * Given an input gradient between 0 and 1, this returns the corresponding value
  71022. * of the easing function.
  71023. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71024. * @returns the corresponding value on the curve defined by the easing function
  71025. */
  71026. ease(gradient: number): number;
  71027. }
  71028. /**
  71029. * Easing function with a circle shape (see link below).
  71030. * @see https://easings.net/#easeInCirc
  71031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71032. */
  71033. export class CircleEase extends EasingFunction implements IEasingFunction {
  71034. /** @hidden */
  71035. easeInCore(gradient: number): number;
  71036. }
  71037. /**
  71038. * Easing function with a ease back shape (see link below).
  71039. * @see https://easings.net/#easeInBack
  71040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71041. */
  71042. export class BackEase extends EasingFunction implements IEasingFunction {
  71043. /** Defines the amplitude of the function */
  71044. amplitude: number;
  71045. /**
  71046. * Instantiates a back ease easing
  71047. * @see https://easings.net/#easeInBack
  71048. * @param amplitude Defines the amplitude of the function
  71049. */
  71050. constructor(
  71051. /** Defines the amplitude of the function */
  71052. amplitude?: number);
  71053. /** @hidden */
  71054. easeInCore(gradient: number): number;
  71055. }
  71056. /**
  71057. * Easing function with a bouncing shape (see link below).
  71058. * @see https://easings.net/#easeInBounce
  71059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71060. */
  71061. export class BounceEase extends EasingFunction implements IEasingFunction {
  71062. /** Defines the number of bounces */
  71063. bounces: number;
  71064. /** Defines the amplitude of the bounce */
  71065. bounciness: number;
  71066. /**
  71067. * Instantiates a bounce easing
  71068. * @see https://easings.net/#easeInBounce
  71069. * @param bounces Defines the number of bounces
  71070. * @param bounciness Defines the amplitude of the bounce
  71071. */
  71072. constructor(
  71073. /** Defines the number of bounces */
  71074. bounces?: number,
  71075. /** Defines the amplitude of the bounce */
  71076. bounciness?: number);
  71077. /** @hidden */
  71078. easeInCore(gradient: number): number;
  71079. }
  71080. /**
  71081. * Easing function with a power of 3 shape (see link below).
  71082. * @see https://easings.net/#easeInCubic
  71083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71084. */
  71085. export class CubicEase extends EasingFunction implements IEasingFunction {
  71086. /** @hidden */
  71087. easeInCore(gradient: number): number;
  71088. }
  71089. /**
  71090. * Easing function with an elastic shape (see link below).
  71091. * @see https://easings.net/#easeInElastic
  71092. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71093. */
  71094. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71095. /** Defines the number of oscillations*/
  71096. oscillations: number;
  71097. /** Defines the amplitude of the oscillations*/
  71098. springiness: number;
  71099. /**
  71100. * Instantiates an elastic easing function
  71101. * @see https://easings.net/#easeInElastic
  71102. * @param oscillations Defines the number of oscillations
  71103. * @param springiness Defines the amplitude of the oscillations
  71104. */
  71105. constructor(
  71106. /** Defines the number of oscillations*/
  71107. oscillations?: number,
  71108. /** Defines the amplitude of the oscillations*/
  71109. springiness?: number);
  71110. /** @hidden */
  71111. easeInCore(gradient: number): number;
  71112. }
  71113. /**
  71114. * Easing function with an exponential shape (see link below).
  71115. * @see https://easings.net/#easeInExpo
  71116. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71117. */
  71118. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71119. /** Defines the exponent of the function */
  71120. exponent: number;
  71121. /**
  71122. * Instantiates an exponential easing function
  71123. * @see https://easings.net/#easeInExpo
  71124. * @param exponent Defines the exponent of the function
  71125. */
  71126. constructor(
  71127. /** Defines the exponent of the function */
  71128. exponent?: number);
  71129. /** @hidden */
  71130. easeInCore(gradient: number): number;
  71131. }
  71132. /**
  71133. * Easing function with a power shape (see link below).
  71134. * @see https://easings.net/#easeInQuad
  71135. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71136. */
  71137. export class PowerEase extends EasingFunction implements IEasingFunction {
  71138. /** Defines the power of the function */
  71139. power: number;
  71140. /**
  71141. * Instantiates an power base easing function
  71142. * @see https://easings.net/#easeInQuad
  71143. * @param power Defines the power of the function
  71144. */
  71145. constructor(
  71146. /** Defines the power of the function */
  71147. power?: number);
  71148. /** @hidden */
  71149. easeInCore(gradient: number): number;
  71150. }
  71151. /**
  71152. * Easing function with a power of 2 shape (see link below).
  71153. * @see https://easings.net/#easeInQuad
  71154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71155. */
  71156. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71157. /** @hidden */
  71158. easeInCore(gradient: number): number;
  71159. }
  71160. /**
  71161. * Easing function with a power of 4 shape (see link below).
  71162. * @see https://easings.net/#easeInQuart
  71163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71164. */
  71165. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71166. /** @hidden */
  71167. easeInCore(gradient: number): number;
  71168. }
  71169. /**
  71170. * Easing function with a power of 5 shape (see link below).
  71171. * @see https://easings.net/#easeInQuint
  71172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71173. */
  71174. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71175. /** @hidden */
  71176. easeInCore(gradient: number): number;
  71177. }
  71178. /**
  71179. * Easing function with a sin shape (see link below).
  71180. * @see https://easings.net/#easeInSine
  71181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71182. */
  71183. export class SineEase extends EasingFunction implements IEasingFunction {
  71184. /** @hidden */
  71185. easeInCore(gradient: number): number;
  71186. }
  71187. /**
  71188. * Easing function with a bezier shape (see link below).
  71189. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71191. */
  71192. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71193. /** Defines the x component of the start tangent in the bezier curve */
  71194. x1: number;
  71195. /** Defines the y component of the start tangent in the bezier curve */
  71196. y1: number;
  71197. /** Defines the x component of the end tangent in the bezier curve */
  71198. x2: number;
  71199. /** Defines the y component of the end tangent in the bezier curve */
  71200. y2: number;
  71201. /**
  71202. * Instantiates a bezier function
  71203. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71204. * @param x1 Defines the x component of the start tangent in the bezier curve
  71205. * @param y1 Defines the y component of the start tangent in the bezier curve
  71206. * @param x2 Defines the x component of the end tangent in the bezier curve
  71207. * @param y2 Defines the y component of the end tangent in the bezier curve
  71208. */
  71209. constructor(
  71210. /** Defines the x component of the start tangent in the bezier curve */
  71211. x1?: number,
  71212. /** Defines the y component of the start tangent in the bezier curve */
  71213. y1?: number,
  71214. /** Defines the x component of the end tangent in the bezier curve */
  71215. x2?: number,
  71216. /** Defines the y component of the end tangent in the bezier curve */
  71217. y2?: number);
  71218. /** @hidden */
  71219. easeInCore(gradient: number): number;
  71220. }
  71221. }
  71222. declare module BABYLON {
  71223. /**
  71224. * Defines an interface which represents an animation key frame
  71225. */
  71226. export interface IAnimationKey {
  71227. /**
  71228. * Frame of the key frame
  71229. */
  71230. frame: number;
  71231. /**
  71232. * Value at the specifies key frame
  71233. */
  71234. value: any;
  71235. /**
  71236. * The input tangent for the cubic hermite spline
  71237. */
  71238. inTangent?: any;
  71239. /**
  71240. * The output tangent for the cubic hermite spline
  71241. */
  71242. outTangent?: any;
  71243. /**
  71244. * The animation interpolation type
  71245. */
  71246. interpolation?: AnimationKeyInterpolation;
  71247. }
  71248. /**
  71249. * Enum for the animation key frame interpolation type
  71250. */
  71251. export enum AnimationKeyInterpolation {
  71252. /**
  71253. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  71254. */
  71255. STEP = 1
  71256. }
  71257. }
  71258. declare module BABYLON {
  71259. /**
  71260. * Represents the range of an animation
  71261. */
  71262. export class AnimationRange {
  71263. /**The name of the animation range**/
  71264. name: string;
  71265. /**The starting frame of the animation */
  71266. from: number;
  71267. /**The ending frame of the animation*/
  71268. to: number;
  71269. /**
  71270. * Initializes the range of an animation
  71271. * @param name The name of the animation range
  71272. * @param from The starting frame of the animation
  71273. * @param to The ending frame of the animation
  71274. */
  71275. constructor(
  71276. /**The name of the animation range**/
  71277. name: string,
  71278. /**The starting frame of the animation */
  71279. from: number,
  71280. /**The ending frame of the animation*/
  71281. to: number);
  71282. /**
  71283. * Makes a copy of the animation range
  71284. * @returns A copy of the animation range
  71285. */
  71286. clone(): AnimationRange;
  71287. }
  71288. }
  71289. declare module BABYLON {
  71290. /**
  71291. * Composed of a frame, and an action function
  71292. */
  71293. export class AnimationEvent {
  71294. /** The frame for which the event is triggered **/
  71295. frame: number;
  71296. /** The event to perform when triggered **/
  71297. action: (currentFrame: number) => void;
  71298. /** Specifies if the event should be triggered only once**/
  71299. onlyOnce?: boolean | undefined;
  71300. /**
  71301. * Specifies if the animation event is done
  71302. */
  71303. isDone: boolean;
  71304. /**
  71305. * Initializes the animation event
  71306. * @param frame The frame for which the event is triggered
  71307. * @param action The event to perform when triggered
  71308. * @param onlyOnce Specifies if the event should be triggered only once
  71309. */
  71310. constructor(
  71311. /** The frame for which the event is triggered **/
  71312. frame: number,
  71313. /** The event to perform when triggered **/
  71314. action: (currentFrame: number) => void,
  71315. /** Specifies if the event should be triggered only once**/
  71316. onlyOnce?: boolean | undefined);
  71317. /** @hidden */
  71318. _clone(): AnimationEvent;
  71319. }
  71320. }
  71321. declare module BABYLON {
  71322. /**
  71323. * Interface used to define a behavior
  71324. */
  71325. export interface Behavior<T> {
  71326. /** gets or sets behavior's name */
  71327. name: string;
  71328. /**
  71329. * Function called when the behavior needs to be initialized (after attaching it to a target)
  71330. */
  71331. init(): void;
  71332. /**
  71333. * Called when the behavior is attached to a target
  71334. * @param target defines the target where the behavior is attached to
  71335. */
  71336. attach(target: T): void;
  71337. /**
  71338. * Called when the behavior is detached from its target
  71339. */
  71340. detach(): void;
  71341. }
  71342. /**
  71343. * Interface implemented by classes supporting behaviors
  71344. */
  71345. export interface IBehaviorAware<T> {
  71346. /**
  71347. * Attach a behavior
  71348. * @param behavior defines the behavior to attach
  71349. * @returns the current host
  71350. */
  71351. addBehavior(behavior: Behavior<T>): T;
  71352. /**
  71353. * Remove a behavior from the current object
  71354. * @param behavior defines the behavior to detach
  71355. * @returns the current host
  71356. */
  71357. removeBehavior(behavior: Behavior<T>): T;
  71358. /**
  71359. * Gets a behavior using its name to search
  71360. * @param name defines the name to search
  71361. * @returns the behavior or null if not found
  71362. */
  71363. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  71364. }
  71365. }
  71366. declare module BABYLON {
  71367. /**
  71368. * Defines an array and its length.
  71369. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  71370. */
  71371. export interface ISmartArrayLike<T> {
  71372. /**
  71373. * The data of the array.
  71374. */
  71375. data: Array<T>;
  71376. /**
  71377. * The active length of the array.
  71378. */
  71379. length: number;
  71380. }
  71381. /**
  71382. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71383. */
  71384. export class SmartArray<T> implements ISmartArrayLike<T> {
  71385. /**
  71386. * The full set of data from the array.
  71387. */
  71388. data: Array<T>;
  71389. /**
  71390. * The active length of the array.
  71391. */
  71392. length: number;
  71393. protected _id: number;
  71394. /**
  71395. * Instantiates a Smart Array.
  71396. * @param capacity defines the default capacity of the array.
  71397. */
  71398. constructor(capacity: number);
  71399. /**
  71400. * Pushes a value at the end of the active data.
  71401. * @param value defines the object to push in the array.
  71402. */
  71403. push(value: T): void;
  71404. /**
  71405. * Iterates over the active data and apply the lambda to them.
  71406. * @param func defines the action to apply on each value.
  71407. */
  71408. forEach(func: (content: T) => void): void;
  71409. /**
  71410. * Sorts the full sets of data.
  71411. * @param compareFn defines the comparison function to apply.
  71412. */
  71413. sort(compareFn: (a: T, b: T) => number): void;
  71414. /**
  71415. * Resets the active data to an empty array.
  71416. */
  71417. reset(): void;
  71418. /**
  71419. * Releases all the data from the array as well as the array.
  71420. */
  71421. dispose(): void;
  71422. /**
  71423. * Concats the active data with a given array.
  71424. * @param array defines the data to concatenate with.
  71425. */
  71426. concat(array: any): void;
  71427. /**
  71428. * Returns the position of a value in the active data.
  71429. * @param value defines the value to find the index for
  71430. * @returns the index if found in the active data otherwise -1
  71431. */
  71432. indexOf(value: T): number;
  71433. /**
  71434. * Returns whether an element is part of the active data.
  71435. * @param value defines the value to look for
  71436. * @returns true if found in the active data otherwise false
  71437. */
  71438. contains(value: T): boolean;
  71439. private static _GlobalId;
  71440. }
  71441. /**
  71442. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71443. * The data in this array can only be present once
  71444. */
  71445. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  71446. private _duplicateId;
  71447. /**
  71448. * Pushes a value at the end of the active data.
  71449. * THIS DOES NOT PREVENT DUPPLICATE DATA
  71450. * @param value defines the object to push in the array.
  71451. */
  71452. push(value: T): void;
  71453. /**
  71454. * Pushes a value at the end of the active data.
  71455. * If the data is already present, it won t be added again
  71456. * @param value defines the object to push in the array.
  71457. * @returns true if added false if it was already present
  71458. */
  71459. pushNoDuplicate(value: T): boolean;
  71460. /**
  71461. * Resets the active data to an empty array.
  71462. */
  71463. reset(): void;
  71464. /**
  71465. * Concats the active data with a given array.
  71466. * This ensures no dupplicate will be present in the result.
  71467. * @param array defines the data to concatenate with.
  71468. */
  71469. concatWithNoDuplicate(array: any): void;
  71470. }
  71471. }
  71472. declare module BABYLON {
  71473. /**
  71474. * @ignore
  71475. * This is a list of all the different input types that are available in the application.
  71476. * Fo instance: ArcRotateCameraGamepadInput...
  71477. */
  71478. export var CameraInputTypes: {};
  71479. /**
  71480. * This is the contract to implement in order to create a new input class.
  71481. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71482. */
  71483. export interface ICameraInput<TCamera extends Camera> {
  71484. /**
  71485. * Defines the camera the input is attached to.
  71486. */
  71487. camera: Nullable<TCamera>;
  71488. /**
  71489. * Gets the class name of the current intput.
  71490. * @returns the class name
  71491. */
  71492. getClassName(): string;
  71493. /**
  71494. * Get the friendly name associated with the input class.
  71495. * @returns the input friendly name
  71496. */
  71497. getSimpleName(): string;
  71498. /**
  71499. * Attach the input controls to a specific dom element to get the input from.
  71500. * @param element Defines the element the controls should be listened from
  71501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71502. */
  71503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71504. /**
  71505. * Detach the current controls from the specified dom element.
  71506. * @param element Defines the element to stop listening the inputs from
  71507. */
  71508. detachControl(element: Nullable<HTMLElement>): void;
  71509. /**
  71510. * Update the current camera state depending on the inputs that have been used this frame.
  71511. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71512. */
  71513. checkInputs?: () => void;
  71514. }
  71515. /**
  71516. * Represents a map of input types to input instance or input index to input instance.
  71517. */
  71518. export interface CameraInputsMap<TCamera extends Camera> {
  71519. /**
  71520. * Accessor to the input by input type.
  71521. */
  71522. [name: string]: ICameraInput<TCamera>;
  71523. /**
  71524. * Accessor to the input by input index.
  71525. */
  71526. [idx: number]: ICameraInput<TCamera>;
  71527. }
  71528. /**
  71529. * This represents the input manager used within a camera.
  71530. * It helps dealing with all the different kind of input attached to a camera.
  71531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71532. */
  71533. export class CameraInputsManager<TCamera extends Camera> {
  71534. /**
  71535. * Defines the list of inputs attahed to the camera.
  71536. */
  71537. attached: CameraInputsMap<TCamera>;
  71538. /**
  71539. * Defines the dom element the camera is collecting inputs from.
  71540. * This is null if the controls have not been attached.
  71541. */
  71542. attachedElement: Nullable<HTMLElement>;
  71543. /**
  71544. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71545. */
  71546. noPreventDefault: boolean;
  71547. /**
  71548. * Defined the camera the input manager belongs to.
  71549. */
  71550. camera: TCamera;
  71551. /**
  71552. * Update the current camera state depending on the inputs that have been used this frame.
  71553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71554. */
  71555. checkInputs: () => void;
  71556. /**
  71557. * Instantiate a new Camera Input Manager.
  71558. * @param camera Defines the camera the input manager blongs to
  71559. */
  71560. constructor(camera: TCamera);
  71561. /**
  71562. * Add an input method to a camera
  71563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71564. * @param input camera input method
  71565. */
  71566. add(input: ICameraInput<TCamera>): void;
  71567. /**
  71568. * Remove a specific input method from a camera
  71569. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71570. * @param inputToRemove camera input method
  71571. */
  71572. remove(inputToRemove: ICameraInput<TCamera>): void;
  71573. /**
  71574. * Remove a specific input type from a camera
  71575. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71576. * @param inputType the type of the input to remove
  71577. */
  71578. removeByType(inputType: string): void;
  71579. private _addCheckInputs;
  71580. /**
  71581. * Attach the input controls to the currently attached dom element to listen the events from.
  71582. * @param input Defines the input to attach
  71583. */
  71584. attachInput(input: ICameraInput<TCamera>): void;
  71585. /**
  71586. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71587. * @param element Defines the dom element to collect the events from
  71588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71589. */
  71590. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71591. /**
  71592. * Detach the current manager inputs controls from a specific dom element.
  71593. * @param element Defines the dom element to collect the events from
  71594. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71595. */
  71596. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71597. /**
  71598. * Rebuild the dynamic inputCheck function from the current list of
  71599. * defined inputs in the manager.
  71600. */
  71601. rebuildInputCheck(): void;
  71602. /**
  71603. * Remove all attached input methods from a camera
  71604. */
  71605. clear(): void;
  71606. /**
  71607. * Serialize the current input manager attached to a camera.
  71608. * This ensures than once parsed,
  71609. * the input associated to the camera will be identical to the current ones
  71610. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71611. */
  71612. serialize(serializedCamera: any): void;
  71613. /**
  71614. * Parses an input manager serialized JSON to restore the previous list of inputs
  71615. * and states associated to a camera.
  71616. * @param parsedCamera Defines the JSON to parse
  71617. */
  71618. parse(parsedCamera: any): void;
  71619. }
  71620. }
  71621. declare module BABYLON {
  71622. /**
  71623. * @hidden
  71624. */
  71625. export class IntersectionInfo {
  71626. bu: Nullable<number>;
  71627. bv: Nullable<number>;
  71628. distance: number;
  71629. faceId: number;
  71630. subMeshId: number;
  71631. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  71632. }
  71633. }
  71634. declare module BABYLON {
  71635. /**
  71636. * Represens a plane by the equation ax + by + cz + d = 0
  71637. */
  71638. export class Plane {
  71639. private static _TmpMatrix;
  71640. /**
  71641. * Normal of the plane (a,b,c)
  71642. */
  71643. normal: Vector3;
  71644. /**
  71645. * d component of the plane
  71646. */
  71647. d: number;
  71648. /**
  71649. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  71650. * @param a a component of the plane
  71651. * @param b b component of the plane
  71652. * @param c c component of the plane
  71653. * @param d d component of the plane
  71654. */
  71655. constructor(a: number, b: number, c: number, d: number);
  71656. /**
  71657. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  71658. */
  71659. asArray(): number[];
  71660. /**
  71661. * @returns a new plane copied from the current Plane.
  71662. */
  71663. clone(): Plane;
  71664. /**
  71665. * @returns the string "Plane".
  71666. */
  71667. getClassName(): string;
  71668. /**
  71669. * @returns the Plane hash code.
  71670. */
  71671. getHashCode(): number;
  71672. /**
  71673. * Normalize the current Plane in place.
  71674. * @returns the updated Plane.
  71675. */
  71676. normalize(): Plane;
  71677. /**
  71678. * Applies a transformation the plane and returns the result
  71679. * @param transformation the transformation matrix to be applied to the plane
  71680. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  71681. */
  71682. transform(transformation: DeepImmutable<Matrix>): Plane;
  71683. /**
  71684. * Calcualtte the dot product between the point and the plane normal
  71685. * @param point point to calculate the dot product with
  71686. * @returns the dot product (float) of the point coordinates and the plane normal.
  71687. */
  71688. dotCoordinate(point: DeepImmutable<Vector3>): number;
  71689. /**
  71690. * Updates the current Plane from the plane defined by the three given points.
  71691. * @param point1 one of the points used to contruct the plane
  71692. * @param point2 one of the points used to contruct the plane
  71693. * @param point3 one of the points used to contruct the plane
  71694. * @returns the updated Plane.
  71695. */
  71696. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71697. /**
  71698. * Checks if the plane is facing a given direction
  71699. * @param direction the direction to check if the plane is facing
  71700. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  71701. * @returns True is the vector "direction" is the same side than the plane normal.
  71702. */
  71703. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  71704. /**
  71705. * Calculates the distance to a point
  71706. * @param point point to calculate distance to
  71707. * @returns the signed distance (float) from the given point to the Plane.
  71708. */
  71709. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  71710. /**
  71711. * Creates a plane from an array
  71712. * @param array the array to create a plane from
  71713. * @returns a new Plane from the given array.
  71714. */
  71715. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71716. /**
  71717. * Creates a plane from three points
  71718. * @param point1 point used to create the plane
  71719. * @param point2 point used to create the plane
  71720. * @param point3 point used to create the plane
  71721. * @returns a new Plane defined by the three given points.
  71722. */
  71723. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71724. /**
  71725. * Creates a plane from an origin point and a normal
  71726. * @param origin origin of the plane to be constructed
  71727. * @param normal normal of the plane to be constructed
  71728. * @returns a new Plane the normal vector to this plane at the given origin point.
  71729. * Note : the vector "normal" is updated because normalized.
  71730. */
  71731. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71732. /**
  71733. * Calculates the distance from a plane and a point
  71734. * @param origin origin of the plane to be constructed
  71735. * @param normal normal of the plane to be constructed
  71736. * @param point point to calculate distance to
  71737. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71738. */
  71739. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71740. }
  71741. }
  71742. declare module BABYLON {
  71743. /**
  71744. * Class used to store bounding sphere information
  71745. */
  71746. export class BoundingSphere {
  71747. /**
  71748. * Gets the center of the bounding sphere in local space
  71749. */
  71750. readonly center: Vector3;
  71751. /**
  71752. * Radius of the bounding sphere in local space
  71753. */
  71754. radius: number;
  71755. /**
  71756. * Gets the center of the bounding sphere in world space
  71757. */
  71758. readonly centerWorld: Vector3;
  71759. /**
  71760. * Radius of the bounding sphere in world space
  71761. */
  71762. radiusWorld: number;
  71763. /**
  71764. * Gets the minimum vector in local space
  71765. */
  71766. readonly minimum: Vector3;
  71767. /**
  71768. * Gets the maximum vector in local space
  71769. */
  71770. readonly maximum: Vector3;
  71771. private _worldMatrix;
  71772. private static readonly TmpVector3;
  71773. /**
  71774. * Creates a new bounding sphere
  71775. * @param min defines the minimum vector (in local space)
  71776. * @param max defines the maximum vector (in local space)
  71777. * @param worldMatrix defines the new world matrix
  71778. */
  71779. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71780. /**
  71781. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71782. * @param min defines the new minimum vector (in local space)
  71783. * @param max defines the new maximum vector (in local space)
  71784. * @param worldMatrix defines the new world matrix
  71785. */
  71786. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71787. /**
  71788. * Scale the current bounding sphere by applying a scale factor
  71789. * @param factor defines the scale factor to apply
  71790. * @returns the current bounding box
  71791. */
  71792. scale(factor: number): BoundingSphere;
  71793. /**
  71794. * Gets the world matrix of the bounding box
  71795. * @returns a matrix
  71796. */
  71797. getWorldMatrix(): DeepImmutable<Matrix>;
  71798. /** @hidden */
  71799. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71800. /**
  71801. * Tests if the bounding sphere is intersecting the frustum planes
  71802. * @param frustumPlanes defines the frustum planes to test
  71803. * @returns true if there is an intersection
  71804. */
  71805. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71806. /**
  71807. * Tests if the bounding sphere center is in between the frustum planes.
  71808. * Used for optimistic fast inclusion.
  71809. * @param frustumPlanes defines the frustum planes to test
  71810. * @returns true if the sphere center is in between the frustum planes
  71811. */
  71812. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71813. /**
  71814. * Tests if a point is inside the bounding sphere
  71815. * @param point defines the point to test
  71816. * @returns true if the point is inside the bounding sphere
  71817. */
  71818. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71819. /**
  71820. * Checks if two sphere intersct
  71821. * @param sphere0 sphere 0
  71822. * @param sphere1 sphere 1
  71823. * @returns true if the speres intersect
  71824. */
  71825. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71826. }
  71827. }
  71828. declare module BABYLON {
  71829. /**
  71830. * Class used to store bounding box information
  71831. */
  71832. export class BoundingBox implements ICullable {
  71833. /**
  71834. * Gets the 8 vectors representing the bounding box in local space
  71835. */
  71836. readonly vectors: Vector3[];
  71837. /**
  71838. * Gets the center of the bounding box in local space
  71839. */
  71840. readonly center: Vector3;
  71841. /**
  71842. * Gets the center of the bounding box in world space
  71843. */
  71844. readonly centerWorld: Vector3;
  71845. /**
  71846. * Gets the extend size in local space
  71847. */
  71848. readonly extendSize: Vector3;
  71849. /**
  71850. * Gets the extend size in world space
  71851. */
  71852. readonly extendSizeWorld: Vector3;
  71853. /**
  71854. * Gets the OBB (object bounding box) directions
  71855. */
  71856. readonly directions: Vector3[];
  71857. /**
  71858. * Gets the 8 vectors representing the bounding box in world space
  71859. */
  71860. readonly vectorsWorld: Vector3[];
  71861. /**
  71862. * Gets the minimum vector in world space
  71863. */
  71864. readonly minimumWorld: Vector3;
  71865. /**
  71866. * Gets the maximum vector in world space
  71867. */
  71868. readonly maximumWorld: Vector3;
  71869. /**
  71870. * Gets the minimum vector in local space
  71871. */
  71872. readonly minimum: Vector3;
  71873. /**
  71874. * Gets the maximum vector in local space
  71875. */
  71876. readonly maximum: Vector3;
  71877. private _worldMatrix;
  71878. private static readonly TmpVector3;
  71879. /**
  71880. * @hidden
  71881. */
  71882. _tag: number;
  71883. /**
  71884. * Creates a new bounding box
  71885. * @param min defines the minimum vector (in local space)
  71886. * @param max defines the maximum vector (in local space)
  71887. * @param worldMatrix defines the new world matrix
  71888. */
  71889. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71890. /**
  71891. * Recreates the entire bounding box from scratch as if we call the constructor in place
  71892. * @param min defines the new minimum vector (in local space)
  71893. * @param max defines the new maximum vector (in local space)
  71894. * @param worldMatrix defines the new world matrix
  71895. */
  71896. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71897. /**
  71898. * Scale the current bounding box by applying a scale factor
  71899. * @param factor defines the scale factor to apply
  71900. * @returns the current bounding box
  71901. */
  71902. scale(factor: number): BoundingBox;
  71903. /**
  71904. * Gets the world matrix of the bounding box
  71905. * @returns a matrix
  71906. */
  71907. getWorldMatrix(): DeepImmutable<Matrix>;
  71908. /** @hidden */
  71909. _update(world: DeepImmutable<Matrix>): void;
  71910. /**
  71911. * Tests if the bounding box is intersecting the frustum planes
  71912. * @param frustumPlanes defines the frustum planes to test
  71913. * @returns true if there is an intersection
  71914. */
  71915. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71916. /**
  71917. * Tests if the bounding box is entirely inside the frustum planes
  71918. * @param frustumPlanes defines the frustum planes to test
  71919. * @returns true if there is an inclusion
  71920. */
  71921. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71922. /**
  71923. * Tests if a point is inside the bounding box
  71924. * @param point defines the point to test
  71925. * @returns true if the point is inside the bounding box
  71926. */
  71927. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71928. /**
  71929. * Tests if the bounding box intersects with a bounding sphere
  71930. * @param sphere defines the sphere to test
  71931. * @returns true if there is an intersection
  71932. */
  71933. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  71934. /**
  71935. * Tests if the bounding box intersects with a box defined by a min and max vectors
  71936. * @param min defines the min vector to use
  71937. * @param max defines the max vector to use
  71938. * @returns true if there is an intersection
  71939. */
  71940. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  71941. /**
  71942. * Tests if two bounding boxes are intersections
  71943. * @param box0 defines the first box to test
  71944. * @param box1 defines the second box to test
  71945. * @returns true if there is an intersection
  71946. */
  71947. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  71948. /**
  71949. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  71950. * @param minPoint defines the minimum vector of the bounding box
  71951. * @param maxPoint defines the maximum vector of the bounding box
  71952. * @param sphereCenter defines the sphere center
  71953. * @param sphereRadius defines the sphere radius
  71954. * @returns true if there is an intersection
  71955. */
  71956. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  71957. /**
  71958. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  71959. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71960. * @param frustumPlanes defines the frustum planes to test
  71961. * @return true if there is an inclusion
  71962. */
  71963. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71964. /**
  71965. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  71966. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71967. * @param frustumPlanes defines the frustum planes to test
  71968. * @return true if there is an intersection
  71969. */
  71970. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71971. }
  71972. }
  71973. declare module BABYLON {
  71974. /** @hidden */
  71975. export class Collider {
  71976. /** Define if a collision was found */
  71977. collisionFound: boolean;
  71978. /**
  71979. * Define last intersection point in local space
  71980. */
  71981. intersectionPoint: Vector3;
  71982. /**
  71983. * Define last collided mesh
  71984. */
  71985. collidedMesh: Nullable<AbstractMesh>;
  71986. private _collisionPoint;
  71987. private _planeIntersectionPoint;
  71988. private _tempVector;
  71989. private _tempVector2;
  71990. private _tempVector3;
  71991. private _tempVector4;
  71992. private _edge;
  71993. private _baseToVertex;
  71994. private _destinationPoint;
  71995. private _slidePlaneNormal;
  71996. private _displacementVector;
  71997. /** @hidden */
  71998. _radius: Vector3;
  71999. /** @hidden */
  72000. _retry: number;
  72001. private _velocity;
  72002. private _basePoint;
  72003. private _epsilon;
  72004. /** @hidden */
  72005. _velocityWorldLength: number;
  72006. /** @hidden */
  72007. _basePointWorld: Vector3;
  72008. private _velocityWorld;
  72009. private _normalizedVelocity;
  72010. /** @hidden */
  72011. _initialVelocity: Vector3;
  72012. /** @hidden */
  72013. _initialPosition: Vector3;
  72014. private _nearestDistance;
  72015. private _collisionMask;
  72016. collisionMask: number;
  72017. /**
  72018. * Gets the plane normal used to compute the sliding response (in local space)
  72019. */
  72020. readonly slidePlaneNormal: Vector3;
  72021. /** @hidden */
  72022. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72023. /** @hidden */
  72024. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72025. /** @hidden */
  72026. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72027. /** @hidden */
  72028. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72029. /** @hidden */
  72030. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72031. /** @hidden */
  72032. _getResponse(pos: Vector3, vel: Vector3): void;
  72033. }
  72034. }
  72035. declare module BABYLON {
  72036. /**
  72037. * Interface for cullable objects
  72038. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72039. */
  72040. export interface ICullable {
  72041. /**
  72042. * Checks if the object or part of the object is in the frustum
  72043. * @param frustumPlanes Camera near/planes
  72044. * @returns true if the object is in frustum otherwise false
  72045. */
  72046. isInFrustum(frustumPlanes: Plane[]): boolean;
  72047. /**
  72048. * Checks if a cullable object (mesh...) is in the camera frustum
  72049. * Unlike isInFrustum this cheks the full bounding box
  72050. * @param frustumPlanes Camera near/planes
  72051. * @returns true if the object is in frustum otherwise false
  72052. */
  72053. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72054. }
  72055. /**
  72056. * Info for a bounding data of a mesh
  72057. */
  72058. export class BoundingInfo implements ICullable {
  72059. /**
  72060. * Bounding box for the mesh
  72061. */
  72062. readonly boundingBox: BoundingBox;
  72063. /**
  72064. * Bounding sphere for the mesh
  72065. */
  72066. readonly boundingSphere: BoundingSphere;
  72067. private _isLocked;
  72068. private static readonly TmpVector3;
  72069. /**
  72070. * Constructs bounding info
  72071. * @param minimum min vector of the bounding box/sphere
  72072. * @param maximum max vector of the bounding box/sphere
  72073. * @param worldMatrix defines the new world matrix
  72074. */
  72075. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72076. /**
  72077. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72078. * @param min defines the new minimum vector (in local space)
  72079. * @param max defines the new maximum vector (in local space)
  72080. * @param worldMatrix defines the new world matrix
  72081. */
  72082. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72083. /**
  72084. * min vector of the bounding box/sphere
  72085. */
  72086. readonly minimum: Vector3;
  72087. /**
  72088. * max vector of the bounding box/sphere
  72089. */
  72090. readonly maximum: Vector3;
  72091. /**
  72092. * If the info is locked and won't be updated to avoid perf overhead
  72093. */
  72094. isLocked: boolean;
  72095. /**
  72096. * Updates the bounding sphere and box
  72097. * @param world world matrix to be used to update
  72098. */
  72099. update(world: DeepImmutable<Matrix>): void;
  72100. /**
  72101. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72102. * @param center New center of the bounding info
  72103. * @param extend New extend of the bounding info
  72104. * @returns the current bounding info
  72105. */
  72106. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72107. /**
  72108. * Scale the current bounding info by applying a scale factor
  72109. * @param factor defines the scale factor to apply
  72110. * @returns the current bounding info
  72111. */
  72112. scale(factor: number): BoundingInfo;
  72113. /**
  72114. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72115. * @param frustumPlanes defines the frustum to test
  72116. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72117. * @returns true if the bounding info is in the frustum planes
  72118. */
  72119. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  72120. /**
  72121. * Gets the world distance between the min and max points of the bounding box
  72122. */
  72123. readonly diagonalLength: number;
  72124. /**
  72125. * Checks if a cullable object (mesh...) is in the camera frustum
  72126. * Unlike isInFrustum this cheks the full bounding box
  72127. * @param frustumPlanes Camera near/planes
  72128. * @returns true if the object is in frustum otherwise false
  72129. */
  72130. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72131. /** @hidden */
  72132. _checkCollision(collider: Collider): boolean;
  72133. /**
  72134. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  72135. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72136. * @param point the point to check intersection with
  72137. * @returns if the point intersects
  72138. */
  72139. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72140. /**
  72141. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  72142. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72143. * @param boundingInfo the bounding info to check intersection with
  72144. * @param precise if the intersection should be done using OBB
  72145. * @returns if the bounding info intersects
  72146. */
  72147. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  72148. }
  72149. }
  72150. declare module BABYLON {
  72151. /**
  72152. * Extracts minimum and maximum values from a list of indexed positions
  72153. * @param positions defines the positions to use
  72154. * @param indices defines the indices to the positions
  72155. * @param indexStart defines the start index
  72156. * @param indexCount defines the end index
  72157. * @param bias defines bias value to add to the result
  72158. * @return minimum and maximum values
  72159. */
  72160. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  72161. minimum: Vector3;
  72162. maximum: Vector3;
  72163. };
  72164. /**
  72165. * Extracts minimum and maximum values from a list of positions
  72166. * @param positions defines the positions to use
  72167. * @param start defines the start index in the positions array
  72168. * @param count defines the number of positions to handle
  72169. * @param bias defines bias value to add to the result
  72170. * @param stride defines the stride size to use (distance between two positions in the positions array)
  72171. * @return minimum and maximum values
  72172. */
  72173. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  72174. minimum: Vector3;
  72175. maximum: Vector3;
  72176. };
  72177. }
  72178. declare module BABYLON {
  72179. /**
  72180. * Enum that determines the text-wrapping mode to use.
  72181. */
  72182. export enum InspectableType {
  72183. /**
  72184. * Checkbox for booleans
  72185. */
  72186. Checkbox = 0,
  72187. /**
  72188. * Sliders for numbers
  72189. */
  72190. Slider = 1,
  72191. /**
  72192. * Vector3
  72193. */
  72194. Vector3 = 2,
  72195. /**
  72196. * Quaternions
  72197. */
  72198. Quaternion = 3,
  72199. /**
  72200. * Color3
  72201. */
  72202. Color3 = 4,
  72203. /**
  72204. * String
  72205. */
  72206. String = 5
  72207. }
  72208. /**
  72209. * Interface used to define custom inspectable properties.
  72210. * This interface is used by the inspector to display custom property grids
  72211. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72212. */
  72213. export interface IInspectable {
  72214. /**
  72215. * Gets the label to display
  72216. */
  72217. label: string;
  72218. /**
  72219. * Gets the name of the property to edit
  72220. */
  72221. propertyName: string;
  72222. /**
  72223. * Gets the type of the editor to use
  72224. */
  72225. type: InspectableType;
  72226. /**
  72227. * Gets the minimum value of the property when using in "slider" mode
  72228. */
  72229. min?: number;
  72230. /**
  72231. * Gets the maximum value of the property when using in "slider" mode
  72232. */
  72233. max?: number;
  72234. /**
  72235. * Gets the setp to use when using in "slider" mode
  72236. */
  72237. step?: number;
  72238. }
  72239. }
  72240. declare module BABYLON {
  72241. /**
  72242. * Class used to provide helper for timing
  72243. */
  72244. export class TimingTools {
  72245. /**
  72246. * Polyfill for setImmediate
  72247. * @param action defines the action to execute after the current execution block
  72248. */
  72249. static SetImmediate(action: () => void): void;
  72250. }
  72251. }
  72252. declare module BABYLON {
  72253. /**
  72254. * Class used to enable instatition of objects by class name
  72255. */
  72256. export class InstantiationTools {
  72257. /**
  72258. * Use this object to register external classes like custom textures or material
  72259. * to allow the laoders to instantiate them
  72260. */
  72261. static RegisteredExternalClasses: {
  72262. [key: string]: Object;
  72263. };
  72264. /**
  72265. * Tries to instantiate a new object from a given class name
  72266. * @param className defines the class name to instantiate
  72267. * @returns the new object or null if the system was not able to do the instantiation
  72268. */
  72269. static Instantiate(className: string): any;
  72270. }
  72271. }
  72272. declare module BABYLON {
  72273. /**
  72274. * This represents the required contract to create a new type of texture loader.
  72275. */
  72276. export interface IInternalTextureLoader {
  72277. /**
  72278. * Defines wether the loader supports cascade loading the different faces.
  72279. */
  72280. supportCascades: boolean;
  72281. /**
  72282. * This returns if the loader support the current file information.
  72283. * @param extension defines the file extension of the file being loaded
  72284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72285. * @param fallback defines the fallback internal texture if any
  72286. * @param isBase64 defines whether the texture is encoded as a base64
  72287. * @param isBuffer defines whether the texture data are stored as a buffer
  72288. * @returns true if the loader can load the specified file
  72289. */
  72290. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72291. /**
  72292. * Transform the url before loading if required.
  72293. * @param rootUrl the url of the texture
  72294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72295. * @returns the transformed texture
  72296. */
  72297. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72298. /**
  72299. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72300. * @param rootUrl the url of the texture
  72301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72302. * @returns the fallback texture
  72303. */
  72304. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72305. /**
  72306. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72307. * @param data contains the texture data
  72308. * @param texture defines the BabylonJS internal texture
  72309. * @param createPolynomials will be true if polynomials have been requested
  72310. * @param onLoad defines the callback to trigger once the texture is ready
  72311. * @param onError defines the callback to trigger in case of error
  72312. */
  72313. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72314. /**
  72315. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72316. * @param data contains the texture data
  72317. * @param texture defines the BabylonJS internal texture
  72318. * @param callback defines the method to call once ready to upload
  72319. */
  72320. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72321. }
  72322. }
  72323. declare module BABYLON {
  72324. interface Engine {
  72325. /**
  72326. * Creates a depth stencil cube texture.
  72327. * This is only available in WebGL 2.
  72328. * @param size The size of face edge in the cube texture.
  72329. * @param options The options defining the cube texture.
  72330. * @returns The cube texture
  72331. */
  72332. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  72333. /**
  72334. * Creates a cube texture
  72335. * @param rootUrl defines the url where the files to load is located
  72336. * @param scene defines the current scene
  72337. * @param files defines the list of files to load (1 per face)
  72338. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72339. * @param onLoad defines an optional callback raised when the texture is loaded
  72340. * @param onError defines an optional callback raised if there is an issue to load the texture
  72341. * @param format defines the format of the data
  72342. * @param forcedExtension defines the extension to use to pick the right loader
  72343. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72344. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72345. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72346. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  72347. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  72348. * @returns the cube texture as an InternalTexture
  72349. */
  72350. 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;
  72351. /**
  72352. * Creates a cube texture
  72353. * @param rootUrl defines the url where the files to load is located
  72354. * @param scene defines the current scene
  72355. * @param files defines the list of files to load (1 per face)
  72356. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72357. * @param onLoad defines an optional callback raised when the texture is loaded
  72358. * @param onError defines an optional callback raised if there is an issue to load the texture
  72359. * @param format defines the format of the data
  72360. * @param forcedExtension defines the extension to use to pick the right loader
  72361. * @returns the cube texture as an InternalTexture
  72362. */
  72363. 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;
  72364. /**
  72365. * Creates a cube texture
  72366. * @param rootUrl defines the url where the files to load is located
  72367. * @param scene defines the current scene
  72368. * @param files defines the list of files to load (1 per face)
  72369. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72370. * @param onLoad defines an optional callback raised when the texture is loaded
  72371. * @param onError defines an optional callback raised if there is an issue to load the texture
  72372. * @param format defines the format of the data
  72373. * @param forcedExtension defines the extension to use to pick the right loader
  72374. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72375. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72376. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72377. * @returns the cube texture as an InternalTexture
  72378. */
  72379. 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;
  72380. /** @hidden */
  72381. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72382. /** @hidden */
  72383. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72384. /** @hidden */
  72385. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72386. /** @hidden */
  72387. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72388. }
  72389. }
  72390. declare module BABYLON {
  72391. /**
  72392. * Class for creating a cube texture
  72393. */
  72394. export class CubeTexture extends BaseTexture {
  72395. private _delayedOnLoad;
  72396. /**
  72397. * The url of the texture
  72398. */
  72399. url: string;
  72400. /**
  72401. * Gets or sets the center of the bounding box associated with the cube texture.
  72402. * It must define where the camera used to render the texture was set
  72403. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72404. */
  72405. boundingBoxPosition: Vector3;
  72406. private _boundingBoxSize;
  72407. /**
  72408. * Gets or sets the size of the bounding box associated with the cube texture
  72409. * When defined, the cubemap will switch to local mode
  72410. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72411. * @example https://www.babylonjs-playground.com/#RNASML
  72412. */
  72413. /**
  72414. * Returns the bounding box size
  72415. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72416. */
  72417. boundingBoxSize: Vector3;
  72418. protected _rotationY: number;
  72419. /**
  72420. * Sets texture matrix rotation angle around Y axis in radians.
  72421. */
  72422. /**
  72423. * Gets texture matrix rotation angle around Y axis radians.
  72424. */
  72425. rotationY: number;
  72426. /**
  72427. * Are mip maps generated for this texture or not.
  72428. */
  72429. readonly noMipmap: boolean;
  72430. private _noMipmap;
  72431. private _files;
  72432. private _extensions;
  72433. private _textureMatrix;
  72434. private _format;
  72435. private _createPolynomials;
  72436. /** @hidden */
  72437. _prefiltered: boolean;
  72438. /**
  72439. * Creates a cube texture from an array of image urls
  72440. * @param files defines an array of image urls
  72441. * @param scene defines the hosting scene
  72442. * @param noMipmap specifies if mip maps are not used
  72443. * @returns a cube texture
  72444. */
  72445. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  72446. /**
  72447. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  72448. * @param url defines the url of the prefiltered texture
  72449. * @param scene defines the scene the texture is attached to
  72450. * @param forcedExtension defines the extension of the file if different from the url
  72451. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72452. * @return the prefiltered texture
  72453. */
  72454. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  72455. /**
  72456. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  72457. * as prefiltered data.
  72458. * @param rootUrl defines the url of the texture or the root name of the six images
  72459. * @param scene defines the scene the texture is attached to
  72460. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  72461. * @param noMipmap defines if mipmaps should be created or not
  72462. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  72463. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  72464. * @param onError defines a callback triggered in case of error during load
  72465. * @param format defines the internal format to use for the texture once loaded
  72466. * @param prefiltered defines whether or not the texture is created from prefiltered data
  72467. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  72468. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72469. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72470. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72471. * @return the cube texture
  72472. */
  72473. 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);
  72474. /**
  72475. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  72476. */
  72477. readonly isPrefiltered: boolean;
  72478. /**
  72479. * Get the current class name of the texture useful for serialization or dynamic coding.
  72480. * @returns "CubeTexture"
  72481. */
  72482. getClassName(): string;
  72483. /**
  72484. * Update the url (and optional buffer) of this texture if url was null during construction.
  72485. * @param url the url of the texture
  72486. * @param forcedExtension defines the extension to use
  72487. * @param onLoad callback called when the texture is loaded (defaults to null)
  72488. */
  72489. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  72490. /**
  72491. * Delays loading of the cube texture
  72492. * @param forcedExtension defines the extension to use
  72493. */
  72494. delayLoad(forcedExtension?: string): void;
  72495. /**
  72496. * Returns the reflection texture matrix
  72497. * @returns the reflection texture matrix
  72498. */
  72499. getReflectionTextureMatrix(): Matrix;
  72500. /**
  72501. * Sets the reflection texture matrix
  72502. * @param value Reflection texture matrix
  72503. */
  72504. setReflectionTextureMatrix(value: Matrix): void;
  72505. /**
  72506. * Parses text to create a cube texture
  72507. * @param parsedTexture define the serialized text to read from
  72508. * @param scene defines the hosting scene
  72509. * @param rootUrl defines the root url of the cube texture
  72510. * @returns a cube texture
  72511. */
  72512. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  72513. /**
  72514. * Makes a clone, or deep copy, of the cube texture
  72515. * @returns a new cube texture
  72516. */
  72517. clone(): CubeTexture;
  72518. }
  72519. }
  72520. declare module BABYLON {
  72521. /**
  72522. * Manages the defines for the Material
  72523. */
  72524. export class MaterialDefines {
  72525. /** @hidden */
  72526. protected _keys: string[];
  72527. private _isDirty;
  72528. /** @hidden */
  72529. _renderId: number;
  72530. /** @hidden */
  72531. _areLightsDirty: boolean;
  72532. /** @hidden */
  72533. _areLightsDisposed: boolean;
  72534. /** @hidden */
  72535. _areAttributesDirty: boolean;
  72536. /** @hidden */
  72537. _areTexturesDirty: boolean;
  72538. /** @hidden */
  72539. _areFresnelDirty: boolean;
  72540. /** @hidden */
  72541. _areMiscDirty: boolean;
  72542. /** @hidden */
  72543. _areImageProcessingDirty: boolean;
  72544. /** @hidden */
  72545. _normals: boolean;
  72546. /** @hidden */
  72547. _uvs: boolean;
  72548. /** @hidden */
  72549. _needNormals: boolean;
  72550. /** @hidden */
  72551. _needUVs: boolean;
  72552. [id: string]: any;
  72553. /**
  72554. * Specifies if the material needs to be re-calculated
  72555. */
  72556. readonly isDirty: boolean;
  72557. /**
  72558. * Marks the material to indicate that it has been re-calculated
  72559. */
  72560. markAsProcessed(): void;
  72561. /**
  72562. * Marks the material to indicate that it needs to be re-calculated
  72563. */
  72564. markAsUnprocessed(): void;
  72565. /**
  72566. * Marks the material to indicate all of its defines need to be re-calculated
  72567. */
  72568. markAllAsDirty(): void;
  72569. /**
  72570. * Marks the material to indicate that image processing needs to be re-calculated
  72571. */
  72572. markAsImageProcessingDirty(): void;
  72573. /**
  72574. * Marks the material to indicate the lights need to be re-calculated
  72575. * @param disposed Defines whether the light is dirty due to dispose or not
  72576. */
  72577. markAsLightDirty(disposed?: boolean): void;
  72578. /**
  72579. * Marks the attribute state as changed
  72580. */
  72581. markAsAttributesDirty(): void;
  72582. /**
  72583. * Marks the texture state as changed
  72584. */
  72585. markAsTexturesDirty(): void;
  72586. /**
  72587. * Marks the fresnel state as changed
  72588. */
  72589. markAsFresnelDirty(): void;
  72590. /**
  72591. * Marks the misc state as changed
  72592. */
  72593. markAsMiscDirty(): void;
  72594. /**
  72595. * Rebuilds the material defines
  72596. */
  72597. rebuild(): void;
  72598. /**
  72599. * Specifies if two material defines are equal
  72600. * @param other - A material define instance to compare to
  72601. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  72602. */
  72603. isEqual(other: MaterialDefines): boolean;
  72604. /**
  72605. * Clones this instance's defines to another instance
  72606. * @param other - material defines to clone values to
  72607. */
  72608. cloneTo(other: MaterialDefines): void;
  72609. /**
  72610. * Resets the material define values
  72611. */
  72612. reset(): void;
  72613. /**
  72614. * Converts the material define values to a string
  72615. * @returns - String of material define information
  72616. */
  72617. toString(): string;
  72618. }
  72619. }
  72620. declare module BABYLON {
  72621. /**
  72622. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  72623. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  72624. * 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;
  72625. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  72626. */
  72627. export class ColorCurves {
  72628. private _dirty;
  72629. private _tempColor;
  72630. private _globalCurve;
  72631. private _highlightsCurve;
  72632. private _midtonesCurve;
  72633. private _shadowsCurve;
  72634. private _positiveCurve;
  72635. private _negativeCurve;
  72636. private _globalHue;
  72637. private _globalDensity;
  72638. private _globalSaturation;
  72639. private _globalExposure;
  72640. /**
  72641. * Gets the global Hue value.
  72642. * 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).
  72643. */
  72644. /**
  72645. * Sets the global Hue value.
  72646. * 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).
  72647. */
  72648. globalHue: number;
  72649. /**
  72650. * Gets the global Density value.
  72651. * 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.
  72652. * Values less than zero provide a filter of opposite hue.
  72653. */
  72654. /**
  72655. * Sets the global Density value.
  72656. * 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.
  72657. * Values less than zero provide a filter of opposite hue.
  72658. */
  72659. globalDensity: number;
  72660. /**
  72661. * Gets the global Saturation value.
  72662. * 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.
  72663. */
  72664. /**
  72665. * Sets the global Saturation value.
  72666. * 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.
  72667. */
  72668. globalSaturation: number;
  72669. /**
  72670. * Gets the global Exposure value.
  72671. * 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.
  72672. */
  72673. /**
  72674. * Sets the global Exposure value.
  72675. * 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.
  72676. */
  72677. globalExposure: number;
  72678. private _highlightsHue;
  72679. private _highlightsDensity;
  72680. private _highlightsSaturation;
  72681. private _highlightsExposure;
  72682. /**
  72683. * Gets the highlights Hue value.
  72684. * 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).
  72685. */
  72686. /**
  72687. * Sets the highlights Hue value.
  72688. * 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).
  72689. */
  72690. highlightsHue: number;
  72691. /**
  72692. * Gets the highlights Density value.
  72693. * 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.
  72694. * Values less than zero provide a filter of opposite hue.
  72695. */
  72696. /**
  72697. * Sets the highlights Density value.
  72698. * 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.
  72699. * Values less than zero provide a filter of opposite hue.
  72700. */
  72701. highlightsDensity: number;
  72702. /**
  72703. * Gets the highlights Saturation value.
  72704. * 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.
  72705. */
  72706. /**
  72707. * Sets the highlights Saturation value.
  72708. * 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.
  72709. */
  72710. highlightsSaturation: number;
  72711. /**
  72712. * Gets the highlights Exposure value.
  72713. * 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.
  72714. */
  72715. /**
  72716. * Sets the highlights Exposure value.
  72717. * 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.
  72718. */
  72719. highlightsExposure: number;
  72720. private _midtonesHue;
  72721. private _midtonesDensity;
  72722. private _midtonesSaturation;
  72723. private _midtonesExposure;
  72724. /**
  72725. * Gets the midtones Hue value.
  72726. * 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).
  72727. */
  72728. /**
  72729. * Sets the midtones Hue value.
  72730. * 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).
  72731. */
  72732. midtonesHue: number;
  72733. /**
  72734. * Gets the midtones Density value.
  72735. * 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.
  72736. * Values less than zero provide a filter of opposite hue.
  72737. */
  72738. /**
  72739. * Sets the midtones Density value.
  72740. * 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.
  72741. * Values less than zero provide a filter of opposite hue.
  72742. */
  72743. midtonesDensity: number;
  72744. /**
  72745. * Gets the midtones Saturation value.
  72746. * 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.
  72747. */
  72748. /**
  72749. * Sets the midtones Saturation value.
  72750. * 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.
  72751. */
  72752. midtonesSaturation: number;
  72753. /**
  72754. * Gets the midtones Exposure value.
  72755. * 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.
  72756. */
  72757. /**
  72758. * Sets the midtones Exposure value.
  72759. * 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.
  72760. */
  72761. midtonesExposure: number;
  72762. private _shadowsHue;
  72763. private _shadowsDensity;
  72764. private _shadowsSaturation;
  72765. private _shadowsExposure;
  72766. /**
  72767. * Gets the shadows Hue value.
  72768. * 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).
  72769. */
  72770. /**
  72771. * Sets the shadows Hue value.
  72772. * 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).
  72773. */
  72774. shadowsHue: number;
  72775. /**
  72776. * Gets the shadows Density value.
  72777. * 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.
  72778. * Values less than zero provide a filter of opposite hue.
  72779. */
  72780. /**
  72781. * Sets the shadows Density value.
  72782. * 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.
  72783. * Values less than zero provide a filter of opposite hue.
  72784. */
  72785. shadowsDensity: number;
  72786. /**
  72787. * Gets the shadows Saturation value.
  72788. * 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.
  72789. */
  72790. /**
  72791. * Sets the shadows Saturation value.
  72792. * 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.
  72793. */
  72794. shadowsSaturation: number;
  72795. /**
  72796. * Gets the shadows Exposure value.
  72797. * 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.
  72798. */
  72799. /**
  72800. * Sets the shadows Exposure value.
  72801. * 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.
  72802. */
  72803. shadowsExposure: number;
  72804. /**
  72805. * Returns the class name
  72806. * @returns The class name
  72807. */
  72808. getClassName(): string;
  72809. /**
  72810. * Binds the color curves to the shader.
  72811. * @param colorCurves The color curve to bind
  72812. * @param effect The effect to bind to
  72813. * @param positiveUniform The positive uniform shader parameter
  72814. * @param neutralUniform The neutral uniform shader parameter
  72815. * @param negativeUniform The negative uniform shader parameter
  72816. */
  72817. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72818. /**
  72819. * Prepare the list of uniforms associated with the ColorCurves effects.
  72820. * @param uniformsList The list of uniforms used in the effect
  72821. */
  72822. static PrepareUniforms(uniformsList: string[]): void;
  72823. /**
  72824. * Returns color grading data based on a hue, density, saturation and exposure value.
  72825. * @param filterHue The hue of the color filter.
  72826. * @param filterDensity The density of the color filter.
  72827. * @param saturation The saturation.
  72828. * @param exposure The exposure.
  72829. * @param result The result data container.
  72830. */
  72831. private getColorGradingDataToRef;
  72832. /**
  72833. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72834. * @param value The input slider value in range [-100,100].
  72835. * @returns Adjusted value.
  72836. */
  72837. private static applyColorGradingSliderNonlinear;
  72838. /**
  72839. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72840. * @param hue The hue (H) input.
  72841. * @param saturation The saturation (S) input.
  72842. * @param brightness The brightness (B) input.
  72843. * @result An RGBA color represented as Vector4.
  72844. */
  72845. private static fromHSBToRef;
  72846. /**
  72847. * Returns a value clamped between min and max
  72848. * @param value The value to clamp
  72849. * @param min The minimum of value
  72850. * @param max The maximum of value
  72851. * @returns The clamped value.
  72852. */
  72853. private static clamp;
  72854. /**
  72855. * Clones the current color curve instance.
  72856. * @return The cloned curves
  72857. */
  72858. clone(): ColorCurves;
  72859. /**
  72860. * Serializes the current color curve instance to a json representation.
  72861. * @return a JSON representation
  72862. */
  72863. serialize(): any;
  72864. /**
  72865. * Parses the color curve from a json representation.
  72866. * @param source the JSON source to parse
  72867. * @return The parsed curves
  72868. */
  72869. static Parse(source: any): ColorCurves;
  72870. }
  72871. }
  72872. declare module BABYLON {
  72873. /**
  72874. * Interface to follow in your material defines to integrate easily the
  72875. * Image proccessing functions.
  72876. * @hidden
  72877. */
  72878. export interface IImageProcessingConfigurationDefines {
  72879. IMAGEPROCESSING: boolean;
  72880. VIGNETTE: boolean;
  72881. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72882. VIGNETTEBLENDMODEOPAQUE: boolean;
  72883. TONEMAPPING: boolean;
  72884. TONEMAPPING_ACES: boolean;
  72885. CONTRAST: boolean;
  72886. EXPOSURE: boolean;
  72887. COLORCURVES: boolean;
  72888. COLORGRADING: boolean;
  72889. COLORGRADING3D: boolean;
  72890. SAMPLER3DGREENDEPTH: boolean;
  72891. SAMPLER3DBGRMAP: boolean;
  72892. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72893. }
  72894. /**
  72895. * @hidden
  72896. */
  72897. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  72898. IMAGEPROCESSING: boolean;
  72899. VIGNETTE: boolean;
  72900. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72901. VIGNETTEBLENDMODEOPAQUE: boolean;
  72902. TONEMAPPING: boolean;
  72903. TONEMAPPING_ACES: boolean;
  72904. CONTRAST: boolean;
  72905. COLORCURVES: boolean;
  72906. COLORGRADING: boolean;
  72907. COLORGRADING3D: boolean;
  72908. SAMPLER3DGREENDEPTH: boolean;
  72909. SAMPLER3DBGRMAP: boolean;
  72910. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72911. EXPOSURE: boolean;
  72912. constructor();
  72913. }
  72914. /**
  72915. * This groups together the common properties used for image processing either in direct forward pass
  72916. * or through post processing effect depending on the use of the image processing pipeline in your scene
  72917. * or not.
  72918. */
  72919. export class ImageProcessingConfiguration {
  72920. /**
  72921. * Default tone mapping applied in BabylonJS.
  72922. */
  72923. static readonly TONEMAPPING_STANDARD: number;
  72924. /**
  72925. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  72926. * to other engines rendering to increase portability.
  72927. */
  72928. static readonly TONEMAPPING_ACES: number;
  72929. /**
  72930. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  72931. */
  72932. colorCurves: Nullable<ColorCurves>;
  72933. private _colorCurvesEnabled;
  72934. /**
  72935. * Gets wether the color curves effect is enabled.
  72936. */
  72937. /**
  72938. * Sets wether the color curves effect is enabled.
  72939. */
  72940. colorCurvesEnabled: boolean;
  72941. private _colorGradingTexture;
  72942. /**
  72943. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72944. */
  72945. /**
  72946. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72947. */
  72948. colorGradingTexture: Nullable<BaseTexture>;
  72949. private _colorGradingEnabled;
  72950. /**
  72951. * Gets wether the color grading effect is enabled.
  72952. */
  72953. /**
  72954. * Sets wether the color grading effect is enabled.
  72955. */
  72956. colorGradingEnabled: boolean;
  72957. private _colorGradingWithGreenDepth;
  72958. /**
  72959. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  72960. */
  72961. /**
  72962. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  72963. */
  72964. colorGradingWithGreenDepth: boolean;
  72965. private _colorGradingBGR;
  72966. /**
  72967. * Gets wether the color grading texture contains BGR values.
  72968. */
  72969. /**
  72970. * Sets wether the color grading texture contains BGR values.
  72971. */
  72972. colorGradingBGR: boolean;
  72973. /** @hidden */
  72974. _exposure: number;
  72975. /**
  72976. * Gets the Exposure used in the effect.
  72977. */
  72978. /**
  72979. * Sets the Exposure used in the effect.
  72980. */
  72981. exposure: number;
  72982. private _toneMappingEnabled;
  72983. /**
  72984. * Gets wether the tone mapping effect is enabled.
  72985. */
  72986. /**
  72987. * Sets wether the tone mapping effect is enabled.
  72988. */
  72989. toneMappingEnabled: boolean;
  72990. private _toneMappingType;
  72991. /**
  72992. * Gets the type of tone mapping effect.
  72993. */
  72994. /**
  72995. * Sets the type of tone mapping effect used in BabylonJS.
  72996. */
  72997. toneMappingType: number;
  72998. protected _contrast: number;
  72999. /**
  73000. * Gets the contrast used in the effect.
  73001. */
  73002. /**
  73003. * Sets the contrast used in the effect.
  73004. */
  73005. contrast: number;
  73006. /**
  73007. * Vignette stretch size.
  73008. */
  73009. vignetteStretch: number;
  73010. /**
  73011. * Vignette centre X Offset.
  73012. */
  73013. vignetteCentreX: number;
  73014. /**
  73015. * Vignette centre Y Offset.
  73016. */
  73017. vignetteCentreY: number;
  73018. /**
  73019. * Vignette weight or intensity of the vignette effect.
  73020. */
  73021. vignetteWeight: number;
  73022. /**
  73023. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73024. * if vignetteEnabled is set to true.
  73025. */
  73026. vignetteColor: Color4;
  73027. /**
  73028. * Camera field of view used by the Vignette effect.
  73029. */
  73030. vignetteCameraFov: number;
  73031. private _vignetteBlendMode;
  73032. /**
  73033. * Gets the vignette blend mode allowing different kind of effect.
  73034. */
  73035. /**
  73036. * Sets the vignette blend mode allowing different kind of effect.
  73037. */
  73038. vignetteBlendMode: number;
  73039. private _vignetteEnabled;
  73040. /**
  73041. * Gets wether the vignette effect is enabled.
  73042. */
  73043. /**
  73044. * Sets wether the vignette effect is enabled.
  73045. */
  73046. vignetteEnabled: boolean;
  73047. private _applyByPostProcess;
  73048. /**
  73049. * Gets wether the image processing is applied through a post process or not.
  73050. */
  73051. /**
  73052. * Sets wether the image processing is applied through a post process or not.
  73053. */
  73054. applyByPostProcess: boolean;
  73055. private _isEnabled;
  73056. /**
  73057. * Gets wether the image processing is enabled or not.
  73058. */
  73059. /**
  73060. * Sets wether the image processing is enabled or not.
  73061. */
  73062. isEnabled: boolean;
  73063. /**
  73064. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73065. */
  73066. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73067. /**
  73068. * Method called each time the image processing information changes requires to recompile the effect.
  73069. */
  73070. protected _updateParameters(): void;
  73071. /**
  73072. * Gets the current class name.
  73073. * @return "ImageProcessingConfiguration"
  73074. */
  73075. getClassName(): string;
  73076. /**
  73077. * Prepare the list of uniforms associated with the Image Processing effects.
  73078. * @param uniforms The list of uniforms used in the effect
  73079. * @param defines the list of defines currently in use
  73080. */
  73081. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73082. /**
  73083. * Prepare the list of samplers associated with the Image Processing effects.
  73084. * @param samplersList The list of uniforms used in the effect
  73085. * @param defines the list of defines currently in use
  73086. */
  73087. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73088. /**
  73089. * Prepare the list of defines associated to the shader.
  73090. * @param defines the list of defines to complete
  73091. * @param forPostProcess Define if we are currently in post process mode or not
  73092. */
  73093. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73094. /**
  73095. * Returns true if all the image processing information are ready.
  73096. * @returns True if ready, otherwise, false
  73097. */
  73098. isReady(): boolean;
  73099. /**
  73100. * Binds the image processing to the shader.
  73101. * @param effect The effect to bind to
  73102. * @param aspectRatio Define the current aspect ratio of the effect
  73103. */
  73104. bind(effect: Effect, aspectRatio?: number): void;
  73105. /**
  73106. * Clones the current image processing instance.
  73107. * @return The cloned image processing
  73108. */
  73109. clone(): ImageProcessingConfiguration;
  73110. /**
  73111. * Serializes the current image processing instance to a json representation.
  73112. * @return a JSON representation
  73113. */
  73114. serialize(): any;
  73115. /**
  73116. * Parses the image processing from a json representation.
  73117. * @param source the JSON source to parse
  73118. * @return The parsed image processing
  73119. */
  73120. static Parse(source: any): ImageProcessingConfiguration;
  73121. private static _VIGNETTEMODE_MULTIPLY;
  73122. private static _VIGNETTEMODE_OPAQUE;
  73123. /**
  73124. * Used to apply the vignette as a mix with the pixel color.
  73125. */
  73126. static readonly VIGNETTEMODE_MULTIPLY: number;
  73127. /**
  73128. * Used to apply the vignette as a replacement of the pixel color.
  73129. */
  73130. static readonly VIGNETTEMODE_OPAQUE: number;
  73131. }
  73132. }
  73133. declare module BABYLON {
  73134. /** @hidden */
  73135. export var postprocessVertexShader: {
  73136. name: string;
  73137. shader: string;
  73138. };
  73139. }
  73140. declare module BABYLON {
  73141. /** Defines supported spaces */
  73142. export enum Space {
  73143. /** Local (object) space */
  73144. LOCAL = 0,
  73145. /** World space */
  73146. WORLD = 1,
  73147. /** Bone space */
  73148. BONE = 2
  73149. }
  73150. /** Defines the 3 main axes */
  73151. export class Axis {
  73152. /** X axis */
  73153. static X: Vector3;
  73154. /** Y axis */
  73155. static Y: Vector3;
  73156. /** Z axis */
  73157. static Z: Vector3;
  73158. }
  73159. }
  73160. declare module BABYLON {
  73161. /**
  73162. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  73163. * This is the base of the follow, arc rotate cameras and Free camera
  73164. * @see http://doc.babylonjs.com/features/cameras
  73165. */
  73166. export class TargetCamera extends Camera {
  73167. private static _RigCamTransformMatrix;
  73168. private static _TargetTransformMatrix;
  73169. private static _TargetFocalPoint;
  73170. /**
  73171. * Define the current direction the camera is moving to
  73172. */
  73173. cameraDirection: Vector3;
  73174. /**
  73175. * Define the current rotation the camera is rotating to
  73176. */
  73177. cameraRotation: Vector2;
  73178. /**
  73179. * When set, the up vector of the camera will be updated by the rotation of the camera
  73180. */
  73181. updateUpVectorFromRotation: boolean;
  73182. private _tmpQuaternion;
  73183. /**
  73184. * Define the current rotation of the camera
  73185. */
  73186. rotation: Vector3;
  73187. /**
  73188. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  73189. */
  73190. rotationQuaternion: Quaternion;
  73191. /**
  73192. * Define the current speed of the camera
  73193. */
  73194. speed: number;
  73195. /**
  73196. * Add cconstraint to the camera to prevent it to move freely in all directions and
  73197. * around all axis.
  73198. */
  73199. noRotationConstraint: boolean;
  73200. /**
  73201. * Define the current target of the camera as an object or a position.
  73202. */
  73203. lockedTarget: any;
  73204. /** @hidden */
  73205. _currentTarget: Vector3;
  73206. /** @hidden */
  73207. _initialFocalDistance: number;
  73208. /** @hidden */
  73209. _viewMatrix: Matrix;
  73210. /** @hidden */
  73211. _camMatrix: Matrix;
  73212. /** @hidden */
  73213. _cameraTransformMatrix: Matrix;
  73214. /** @hidden */
  73215. _cameraRotationMatrix: Matrix;
  73216. /** @hidden */
  73217. _referencePoint: Vector3;
  73218. /** @hidden */
  73219. _transformedReferencePoint: Vector3;
  73220. protected _globalCurrentTarget: Vector3;
  73221. protected _globalCurrentUpVector: Vector3;
  73222. /** @hidden */
  73223. _reset: () => void;
  73224. private _defaultUp;
  73225. /**
  73226. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  73227. * This is the base of the follow, arc rotate cameras and Free camera
  73228. * @see http://doc.babylonjs.com/features/cameras
  73229. * @param name Defines the name of the camera in the scene
  73230. * @param position Defines the start position of the camera in the scene
  73231. * @param scene Defines the scene the camera belongs to
  73232. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  73233. */
  73234. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  73235. /**
  73236. * Gets the position in front of the camera at a given distance.
  73237. * @param distance The distance from the camera we want the position to be
  73238. * @returns the position
  73239. */
  73240. getFrontPosition(distance: number): Vector3;
  73241. /** @hidden */
  73242. _getLockedTargetPosition(): Nullable<Vector3>;
  73243. private _storedPosition;
  73244. private _storedRotation;
  73245. private _storedRotationQuaternion;
  73246. /**
  73247. * Store current camera state of the camera (fov, position, rotation, etc..)
  73248. * @returns the camera
  73249. */
  73250. storeState(): Camera;
  73251. /**
  73252. * Restored camera state. You must call storeState() first
  73253. * @returns whether it was successful or not
  73254. * @hidden
  73255. */
  73256. _restoreStateValues(): boolean;
  73257. /** @hidden */
  73258. _initCache(): void;
  73259. /** @hidden */
  73260. _updateCache(ignoreParentClass?: boolean): void;
  73261. /** @hidden */
  73262. _isSynchronizedViewMatrix(): boolean;
  73263. /** @hidden */
  73264. _computeLocalCameraSpeed(): number;
  73265. /**
  73266. * Defines the target the camera should look at.
  73267. * @param target Defines the new target as a Vector or a mesh
  73268. */
  73269. setTarget(target: Vector3): void;
  73270. /**
  73271. * Return the current target position of the camera. This value is expressed in local space.
  73272. * @returns the target position
  73273. */
  73274. getTarget(): Vector3;
  73275. /** @hidden */
  73276. _decideIfNeedsToMove(): boolean;
  73277. /** @hidden */
  73278. _updatePosition(): void;
  73279. /** @hidden */
  73280. _checkInputs(): void;
  73281. protected _updateCameraRotationMatrix(): void;
  73282. /**
  73283. * 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)
  73284. * @returns the current camera
  73285. */
  73286. private _rotateUpVectorWithCameraRotationMatrix;
  73287. private _cachedRotationZ;
  73288. private _cachedQuaternionRotationZ;
  73289. /** @hidden */
  73290. _getViewMatrix(): Matrix;
  73291. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  73292. /**
  73293. * @hidden
  73294. */
  73295. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  73296. /**
  73297. * @hidden
  73298. */
  73299. _updateRigCameras(): void;
  73300. private _getRigCamPositionAndTarget;
  73301. /**
  73302. * Gets the current object class name.
  73303. * @return the class name
  73304. */
  73305. getClassName(): string;
  73306. }
  73307. }
  73308. declare module BABYLON {
  73309. /**
  73310. * Gather the list of keyboard event types as constants.
  73311. */
  73312. export class KeyboardEventTypes {
  73313. /**
  73314. * The keydown event is fired when a key becomes active (pressed).
  73315. */
  73316. static readonly KEYDOWN: number;
  73317. /**
  73318. * The keyup event is fired when a key has been released.
  73319. */
  73320. static readonly KEYUP: number;
  73321. }
  73322. /**
  73323. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73324. */
  73325. export class KeyboardInfo {
  73326. /**
  73327. * Defines the type of event (KeyboardEventTypes)
  73328. */
  73329. type: number;
  73330. /**
  73331. * Defines the related dom event
  73332. */
  73333. event: KeyboardEvent;
  73334. /**
  73335. * Instantiates a new keyboard info.
  73336. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73337. * @param type Defines the type of event (KeyboardEventTypes)
  73338. * @param event Defines the related dom event
  73339. */
  73340. constructor(
  73341. /**
  73342. * Defines the type of event (KeyboardEventTypes)
  73343. */
  73344. type: number,
  73345. /**
  73346. * Defines the related dom event
  73347. */
  73348. event: KeyboardEvent);
  73349. }
  73350. /**
  73351. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73352. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  73353. */
  73354. export class KeyboardInfoPre extends KeyboardInfo {
  73355. /**
  73356. * Defines the type of event (KeyboardEventTypes)
  73357. */
  73358. type: number;
  73359. /**
  73360. * Defines the related dom event
  73361. */
  73362. event: KeyboardEvent;
  73363. /**
  73364. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  73365. */
  73366. skipOnPointerObservable: boolean;
  73367. /**
  73368. * Instantiates a new keyboard pre info.
  73369. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73370. * @param type Defines the type of event (KeyboardEventTypes)
  73371. * @param event Defines the related dom event
  73372. */
  73373. constructor(
  73374. /**
  73375. * Defines the type of event (KeyboardEventTypes)
  73376. */
  73377. type: number,
  73378. /**
  73379. * Defines the related dom event
  73380. */
  73381. event: KeyboardEvent);
  73382. }
  73383. }
  73384. declare module BABYLON {
  73385. /**
  73386. * Manage the keyboard inputs to control the movement of a free camera.
  73387. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73388. */
  73389. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  73390. /**
  73391. * Defines the camera the input is attached to.
  73392. */
  73393. camera: FreeCamera;
  73394. /**
  73395. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  73396. */
  73397. keysUp: number[];
  73398. /**
  73399. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  73400. */
  73401. keysDown: number[];
  73402. /**
  73403. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  73404. */
  73405. keysLeft: number[];
  73406. /**
  73407. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73408. */
  73409. keysRight: number[];
  73410. private _keys;
  73411. private _onCanvasBlurObserver;
  73412. private _onKeyboardObserver;
  73413. private _engine;
  73414. private _scene;
  73415. /**
  73416. * Attach the input controls to a specific dom element to get the input from.
  73417. * @param element Defines the element the controls should be listened from
  73418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73419. */
  73420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73421. /**
  73422. * Detach the current controls from the specified dom element.
  73423. * @param element Defines the element to stop listening the inputs from
  73424. */
  73425. detachControl(element: Nullable<HTMLElement>): void;
  73426. /**
  73427. * Update the current camera state depending on the inputs that have been used this frame.
  73428. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73429. */
  73430. checkInputs(): void;
  73431. /**
  73432. * Gets the class name of the current intput.
  73433. * @returns the class name
  73434. */
  73435. getClassName(): string;
  73436. /** @hidden */
  73437. _onLostFocus(): void;
  73438. /**
  73439. * Get the friendly name associated with the input class.
  73440. * @returns the input friendly name
  73441. */
  73442. getSimpleName(): string;
  73443. }
  73444. }
  73445. declare module BABYLON {
  73446. /**
  73447. * Interface describing all the common properties and methods a shadow light needs to implement.
  73448. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73449. * as well as binding the different shadow properties to the effects.
  73450. */
  73451. export interface IShadowLight extends Light {
  73452. /**
  73453. * The light id in the scene (used in scene.findLighById for instance)
  73454. */
  73455. id: string;
  73456. /**
  73457. * The position the shdow will be casted from.
  73458. */
  73459. position: Vector3;
  73460. /**
  73461. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73462. */
  73463. direction: Vector3;
  73464. /**
  73465. * The transformed position. Position of the light in world space taking parenting in account.
  73466. */
  73467. transformedPosition: Vector3;
  73468. /**
  73469. * The transformed direction. Direction of the light in world space taking parenting in account.
  73470. */
  73471. transformedDirection: Vector3;
  73472. /**
  73473. * The friendly name of the light in the scene.
  73474. */
  73475. name: string;
  73476. /**
  73477. * Defines the shadow projection clipping minimum z value.
  73478. */
  73479. shadowMinZ: number;
  73480. /**
  73481. * Defines the shadow projection clipping maximum z value.
  73482. */
  73483. shadowMaxZ: number;
  73484. /**
  73485. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73486. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73487. */
  73488. computeTransformedInformation(): boolean;
  73489. /**
  73490. * Gets the scene the light belongs to.
  73491. * @returns The scene
  73492. */
  73493. getScene(): Scene;
  73494. /**
  73495. * Callback defining a custom Projection Matrix Builder.
  73496. * This can be used to override the default projection matrix computation.
  73497. */
  73498. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73499. /**
  73500. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73501. * @param matrix The materix to updated with the projection information
  73502. * @param viewMatrix The transform matrix of the light
  73503. * @param renderList The list of mesh to render in the map
  73504. * @returns The current light
  73505. */
  73506. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73507. /**
  73508. * Gets the current depth scale used in ESM.
  73509. * @returns The scale
  73510. */
  73511. getDepthScale(): number;
  73512. /**
  73513. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73514. * @returns true if a cube texture needs to be use
  73515. */
  73516. needCube(): boolean;
  73517. /**
  73518. * Detects if the projection matrix requires to be recomputed this frame.
  73519. * @returns true if it requires to be recomputed otherwise, false.
  73520. */
  73521. needProjectionMatrixCompute(): boolean;
  73522. /**
  73523. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73524. */
  73525. forceProjectionMatrixCompute(): void;
  73526. /**
  73527. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73528. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73529. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73530. */
  73531. getShadowDirection(faceIndex?: number): Vector3;
  73532. /**
  73533. * Gets the minZ used for shadow according to both the scene and the light.
  73534. * @param activeCamera The camera we are returning the min for
  73535. * @returns the depth min z
  73536. */
  73537. getDepthMinZ(activeCamera: Camera): number;
  73538. /**
  73539. * Gets the maxZ used for shadow according to both the scene and the light.
  73540. * @param activeCamera The camera we are returning the max for
  73541. * @returns the depth max z
  73542. */
  73543. getDepthMaxZ(activeCamera: Camera): number;
  73544. }
  73545. /**
  73546. * Base implementation IShadowLight
  73547. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73548. */
  73549. export abstract class ShadowLight extends Light implements IShadowLight {
  73550. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73551. protected _position: Vector3;
  73552. protected _setPosition(value: Vector3): void;
  73553. /**
  73554. * Sets the position the shadow will be casted from. Also use as the light position for both
  73555. * point and spot lights.
  73556. */
  73557. /**
  73558. * Sets the position the shadow will be casted from. Also use as the light position for both
  73559. * point and spot lights.
  73560. */
  73561. position: Vector3;
  73562. protected _direction: Vector3;
  73563. protected _setDirection(value: Vector3): void;
  73564. /**
  73565. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73566. * Also use as the light direction on spot and directional lights.
  73567. */
  73568. /**
  73569. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73570. * Also use as the light direction on spot and directional lights.
  73571. */
  73572. direction: Vector3;
  73573. private _shadowMinZ;
  73574. /**
  73575. * Gets the shadow projection clipping minimum z value.
  73576. */
  73577. /**
  73578. * Sets the shadow projection clipping minimum z value.
  73579. */
  73580. shadowMinZ: number;
  73581. private _shadowMaxZ;
  73582. /**
  73583. * Sets the shadow projection clipping maximum z value.
  73584. */
  73585. /**
  73586. * Gets the shadow projection clipping maximum z value.
  73587. */
  73588. shadowMaxZ: number;
  73589. /**
  73590. * Callback defining a custom Projection Matrix Builder.
  73591. * This can be used to override the default projection matrix computation.
  73592. */
  73593. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73594. /**
  73595. * The transformed position. Position of the light in world space taking parenting in account.
  73596. */
  73597. transformedPosition: Vector3;
  73598. /**
  73599. * The transformed direction. Direction of the light in world space taking parenting in account.
  73600. */
  73601. transformedDirection: Vector3;
  73602. private _needProjectionMatrixCompute;
  73603. /**
  73604. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73605. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73606. */
  73607. computeTransformedInformation(): boolean;
  73608. /**
  73609. * Return the depth scale used for the shadow map.
  73610. * @returns the depth scale.
  73611. */
  73612. getDepthScale(): number;
  73613. /**
  73614. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73615. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73616. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73617. */
  73618. getShadowDirection(faceIndex?: number): Vector3;
  73619. /**
  73620. * Returns the ShadowLight absolute position in the World.
  73621. * @returns the position vector in world space
  73622. */
  73623. getAbsolutePosition(): Vector3;
  73624. /**
  73625. * Sets the ShadowLight direction toward the passed target.
  73626. * @param target The point to target in local space
  73627. * @returns the updated ShadowLight direction
  73628. */
  73629. setDirectionToTarget(target: Vector3): Vector3;
  73630. /**
  73631. * Returns the light rotation in euler definition.
  73632. * @returns the x y z rotation in local space.
  73633. */
  73634. getRotation(): Vector3;
  73635. /**
  73636. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73637. * @returns true if a cube texture needs to be use
  73638. */
  73639. needCube(): boolean;
  73640. /**
  73641. * Detects if the projection matrix requires to be recomputed this frame.
  73642. * @returns true if it requires to be recomputed otherwise, false.
  73643. */
  73644. needProjectionMatrixCompute(): boolean;
  73645. /**
  73646. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73647. */
  73648. forceProjectionMatrixCompute(): void;
  73649. /** @hidden */
  73650. _initCache(): void;
  73651. /** @hidden */
  73652. _isSynchronized(): boolean;
  73653. /**
  73654. * Computes the world matrix of the node
  73655. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73656. * @returns the world matrix
  73657. */
  73658. computeWorldMatrix(force?: boolean): Matrix;
  73659. /**
  73660. * Gets the minZ used for shadow according to both the scene and the light.
  73661. * @param activeCamera The camera we are returning the min for
  73662. * @returns the depth min z
  73663. */
  73664. getDepthMinZ(activeCamera: Camera): number;
  73665. /**
  73666. * Gets the maxZ used for shadow according to both the scene and the light.
  73667. * @param activeCamera The camera we are returning the max for
  73668. * @returns the depth max z
  73669. */
  73670. getDepthMaxZ(activeCamera: Camera): number;
  73671. /**
  73672. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73673. * @param matrix The materix to updated with the projection information
  73674. * @param viewMatrix The transform matrix of the light
  73675. * @param renderList The list of mesh to render in the map
  73676. * @returns The current light
  73677. */
  73678. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73679. }
  73680. }
  73681. declare module BABYLON {
  73682. /**
  73683. * "Static Class" containing the most commonly used helper while dealing with material for
  73684. * rendering purpose.
  73685. *
  73686. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73687. *
  73688. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73689. */
  73690. export class MaterialHelper {
  73691. /**
  73692. * Bind the current view position to an effect.
  73693. * @param effect The effect to be bound
  73694. * @param scene The scene the eyes position is used from
  73695. */
  73696. static BindEyePosition(effect: Effect, scene: Scene): void;
  73697. /**
  73698. * Helps preparing the defines values about the UVs in used in the effect.
  73699. * UVs are shared as much as we can accross channels in the shaders.
  73700. * @param texture The texture we are preparing the UVs for
  73701. * @param defines The defines to update
  73702. * @param key The channel key "diffuse", "specular"... used in the shader
  73703. */
  73704. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73705. /**
  73706. * Binds a texture matrix value to its corrsponding uniform
  73707. * @param texture The texture to bind the matrix for
  73708. * @param uniformBuffer The uniform buffer receivin the data
  73709. * @param key The channel key "diffuse", "specular"... used in the shader
  73710. */
  73711. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73712. /**
  73713. * Gets the current status of the fog (should it be enabled?)
  73714. * @param mesh defines the mesh to evaluate for fog support
  73715. * @param scene defines the hosting scene
  73716. * @returns true if fog must be enabled
  73717. */
  73718. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73719. /**
  73720. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73721. * @param mesh defines the current mesh
  73722. * @param scene defines the current scene
  73723. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73724. * @param pointsCloud defines if point cloud rendering has to be turned on
  73725. * @param fogEnabled defines if fog has to be turned on
  73726. * @param alphaTest defines if alpha testing has to be turned on
  73727. * @param defines defines the current list of defines
  73728. */
  73729. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73730. /**
  73731. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73732. * @param scene defines the current scene
  73733. * @param engine defines the current engine
  73734. * @param defines specifies the list of active defines
  73735. * @param useInstances defines if instances have to be turned on
  73736. * @param useClipPlane defines if clip plane have to be turned on
  73737. */
  73738. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73739. /**
  73740. * Prepares the defines for bones
  73741. * @param mesh The mesh containing the geometry data we will draw
  73742. * @param defines The defines to update
  73743. */
  73744. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73745. /**
  73746. * Prepares the defines for morph targets
  73747. * @param mesh The mesh containing the geometry data we will draw
  73748. * @param defines The defines to update
  73749. */
  73750. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73751. /**
  73752. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73753. * @param mesh The mesh containing the geometry data we will draw
  73754. * @param defines The defines to update
  73755. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73756. * @param useBones Precise whether bones should be used or not (override mesh info)
  73757. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73758. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73759. * @returns false if defines are considered not dirty and have not been checked
  73760. */
  73761. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73762. /**
  73763. * Prepares the defines related to multiview
  73764. * @param scene The scene we are intending to draw
  73765. * @param defines The defines to update
  73766. */
  73767. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73768. /**
  73769. * Prepares the defines related to the light information passed in parameter
  73770. * @param scene The scene we are intending to draw
  73771. * @param mesh The mesh the effect is compiling for
  73772. * @param light The light the effect is compiling for
  73773. * @param lightIndex The index of the light
  73774. * @param defines The defines to update
  73775. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73776. * @param state Defines the current state regarding what is needed (normals, etc...)
  73777. */
  73778. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73779. needNormals: boolean;
  73780. needRebuild: boolean;
  73781. shadowEnabled: boolean;
  73782. specularEnabled: boolean;
  73783. lightmapMode: boolean;
  73784. }): void;
  73785. /**
  73786. * Prepares the defines related to the light information passed in parameter
  73787. * @param scene The scene we are intending to draw
  73788. * @param mesh The mesh the effect is compiling for
  73789. * @param defines The defines to update
  73790. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73791. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73792. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73793. * @returns true if normals will be required for the rest of the effect
  73794. */
  73795. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73796. /**
  73797. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73798. * @param lightIndex defines the light index
  73799. * @param uniformsList The uniform list
  73800. * @param samplersList The sampler list
  73801. * @param projectedLightTexture defines if projected texture must be used
  73802. * @param uniformBuffersList defines an optional list of uniform buffers
  73803. */
  73804. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73805. /**
  73806. * Prepares the uniforms and samplers list to be used in the effect
  73807. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73808. * @param samplersList The sampler list
  73809. * @param defines The defines helping in the list generation
  73810. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73811. */
  73812. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73813. /**
  73814. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73815. * @param defines The defines to update while falling back
  73816. * @param fallbacks The authorized effect fallbacks
  73817. * @param maxSimultaneousLights The maximum number of lights allowed
  73818. * @param rank the current rank of the Effect
  73819. * @returns The newly affected rank
  73820. */
  73821. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73822. private static _TmpMorphInfluencers;
  73823. /**
  73824. * Prepares the list of attributes required for morph targets according to the effect defines.
  73825. * @param attribs The current list of supported attribs
  73826. * @param mesh The mesh to prepare the morph targets attributes for
  73827. * @param influencers The number of influencers
  73828. */
  73829. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73830. /**
  73831. * Prepares the list of attributes required for morph targets according to the effect defines.
  73832. * @param attribs The current list of supported attribs
  73833. * @param mesh The mesh to prepare the morph targets attributes for
  73834. * @param defines The current Defines of the effect
  73835. */
  73836. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73837. /**
  73838. * Prepares the list of attributes required for bones according to the effect defines.
  73839. * @param attribs The current list of supported attribs
  73840. * @param mesh The mesh to prepare the bones attributes for
  73841. * @param defines The current Defines of the effect
  73842. * @param fallbacks The current efffect fallback strategy
  73843. */
  73844. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73845. /**
  73846. * Check and prepare the list of attributes required for instances according to the effect defines.
  73847. * @param attribs The current list of supported attribs
  73848. * @param defines The current MaterialDefines of the effect
  73849. */
  73850. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73851. /**
  73852. * Add the list of attributes required for instances to the attribs array.
  73853. * @param attribs The current list of supported attribs
  73854. */
  73855. static PushAttributesForInstances(attribs: string[]): void;
  73856. /**
  73857. * Binds the light shadow information to the effect for the given mesh.
  73858. * @param light The light containing the generator
  73859. * @param scene The scene the lights belongs to
  73860. * @param mesh The mesh we are binding the information to render
  73861. * @param lightIndex The light index in the effect used to render the mesh
  73862. * @param effect The effect we are binding the data to
  73863. */
  73864. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73865. /**
  73866. * Binds the light information to the effect.
  73867. * @param light The light containing the generator
  73868. * @param effect The effect we are binding the data to
  73869. * @param lightIndex The light index in the effect used to render
  73870. */
  73871. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73872. /**
  73873. * Binds the lights information from the scene to the effect for the given mesh.
  73874. * @param light Light to bind
  73875. * @param lightIndex Light index
  73876. * @param scene The scene where the light belongs to
  73877. * @param mesh The mesh we are binding the information to render
  73878. * @param effect The effect we are binding the data to
  73879. * @param useSpecular Defines if specular is supported
  73880. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73881. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  73882. */
  73883. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  73884. /**
  73885. * Binds the lights information from the scene to the effect for the given mesh.
  73886. * @param scene The scene the lights belongs to
  73887. * @param mesh The mesh we are binding the information to render
  73888. * @param effect The effect we are binding the data to
  73889. * @param defines The generated defines for the effect
  73890. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73891. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73892. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  73893. */
  73894. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  73895. private static _tempFogColor;
  73896. /**
  73897. * Binds the fog information from the scene to the effect for the given mesh.
  73898. * @param scene The scene the lights belongs to
  73899. * @param mesh The mesh we are binding the information to render
  73900. * @param effect The effect we are binding the data to
  73901. * @param linearSpace Defines if the fog effect is applied in linear space
  73902. */
  73903. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73904. /**
  73905. * Binds the bones information from the mesh to the effect.
  73906. * @param mesh The mesh we are binding the information to render
  73907. * @param effect The effect we are binding the data to
  73908. */
  73909. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73910. /**
  73911. * Binds the morph targets information from the mesh to the effect.
  73912. * @param abstractMesh The mesh we are binding the information to render
  73913. * @param effect The effect we are binding the data to
  73914. */
  73915. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73916. /**
  73917. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73918. * @param defines The generated defines used in the effect
  73919. * @param effect The effect we are binding the data to
  73920. * @param scene The scene we are willing to render with logarithmic scale for
  73921. */
  73922. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73923. /**
  73924. * Binds the clip plane information from the scene to the effect.
  73925. * @param scene The scene the clip plane information are extracted from
  73926. * @param effect The effect we are binding the data to
  73927. */
  73928. static BindClipPlane(effect: Effect, scene: Scene): void;
  73929. }
  73930. }
  73931. declare module BABYLON {
  73932. /** @hidden */
  73933. export var packingFunctions: {
  73934. name: string;
  73935. shader: string;
  73936. };
  73937. }
  73938. declare module BABYLON {
  73939. /** @hidden */
  73940. export var shadowMapPixelShader: {
  73941. name: string;
  73942. shader: string;
  73943. };
  73944. }
  73945. declare module BABYLON {
  73946. /** @hidden */
  73947. export var bonesDeclaration: {
  73948. name: string;
  73949. shader: string;
  73950. };
  73951. }
  73952. declare module BABYLON {
  73953. /** @hidden */
  73954. export var morphTargetsVertexGlobalDeclaration: {
  73955. name: string;
  73956. shader: string;
  73957. };
  73958. }
  73959. declare module BABYLON {
  73960. /** @hidden */
  73961. export var morphTargetsVertexDeclaration: {
  73962. name: string;
  73963. shader: string;
  73964. };
  73965. }
  73966. declare module BABYLON {
  73967. /** @hidden */
  73968. export var instancesDeclaration: {
  73969. name: string;
  73970. shader: string;
  73971. };
  73972. }
  73973. declare module BABYLON {
  73974. /** @hidden */
  73975. export var helperFunctions: {
  73976. name: string;
  73977. shader: string;
  73978. };
  73979. }
  73980. declare module BABYLON {
  73981. /** @hidden */
  73982. export var morphTargetsVertex: {
  73983. name: string;
  73984. shader: string;
  73985. };
  73986. }
  73987. declare module BABYLON {
  73988. /** @hidden */
  73989. export var instancesVertex: {
  73990. name: string;
  73991. shader: string;
  73992. };
  73993. }
  73994. declare module BABYLON {
  73995. /** @hidden */
  73996. export var bonesVertex: {
  73997. name: string;
  73998. shader: string;
  73999. };
  74000. }
  74001. declare module BABYLON {
  74002. /** @hidden */
  74003. export var shadowMapVertexShader: {
  74004. name: string;
  74005. shader: string;
  74006. };
  74007. }
  74008. declare module BABYLON {
  74009. /** @hidden */
  74010. export var depthBoxBlurPixelShader: {
  74011. name: string;
  74012. shader: string;
  74013. };
  74014. }
  74015. declare module BABYLON {
  74016. /**
  74017. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74018. */
  74019. export interface ICustomShaderOptions {
  74020. /**
  74021. * Gets or sets the custom shader name to use
  74022. */
  74023. shaderName: string;
  74024. /**
  74025. * The list of attribute names used in the shader
  74026. */
  74027. attributes?: string[];
  74028. /**
  74029. * The list of unifrom names used in the shader
  74030. */
  74031. uniforms?: string[];
  74032. /**
  74033. * The list of sampler names used in the shader
  74034. */
  74035. samplers?: string[];
  74036. /**
  74037. * The list of defines used in the shader
  74038. */
  74039. defines?: string[];
  74040. }
  74041. /**
  74042. * Interface to implement to create a shadow generator compatible with BJS.
  74043. */
  74044. export interface IShadowGenerator {
  74045. /**
  74046. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74047. * @returns The render target texture if present otherwise, null
  74048. */
  74049. getShadowMap(): Nullable<RenderTargetTexture>;
  74050. /**
  74051. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74052. * @returns The render target texture if the shadow map is present otherwise, null
  74053. */
  74054. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74055. /**
  74056. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74057. * @param subMesh The submesh we want to render in the shadow map
  74058. * @param useInstances Defines wether will draw in the map using instances
  74059. * @returns true if ready otherwise, false
  74060. */
  74061. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74062. /**
  74063. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74064. * @param defines Defines of the material we want to update
  74065. * @param lightIndex Index of the light in the enabled light list of the material
  74066. */
  74067. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74068. /**
  74069. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74070. * defined in the generator but impacting the effect).
  74071. * It implies the unifroms available on the materials are the standard BJS ones.
  74072. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74073. * @param effect The effect we are binfing the information for
  74074. */
  74075. bindShadowLight(lightIndex: string, effect: Effect): void;
  74076. /**
  74077. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74078. * (eq to shadow prjection matrix * light transform matrix)
  74079. * @returns The transform matrix used to create the shadow map
  74080. */
  74081. getTransformMatrix(): Matrix;
  74082. /**
  74083. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74084. * Cube and 2D textures for instance.
  74085. */
  74086. recreateShadowMap(): void;
  74087. /**
  74088. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74089. * @param onCompiled Callback triggered at the and of the effects compilation
  74090. * @param options Sets of optional options forcing the compilation with different modes
  74091. */
  74092. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74093. useInstances: boolean;
  74094. }>): void;
  74095. /**
  74096. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74097. * @param options Sets of optional options forcing the compilation with different modes
  74098. * @returns A promise that resolves when the compilation completes
  74099. */
  74100. forceCompilationAsync(options?: Partial<{
  74101. useInstances: boolean;
  74102. }>): Promise<void>;
  74103. /**
  74104. * Serializes the shadow generator setup to a json object.
  74105. * @returns The serialized JSON object
  74106. */
  74107. serialize(): any;
  74108. /**
  74109. * Disposes the Shadow map and related Textures and effects.
  74110. */
  74111. dispose(): void;
  74112. }
  74113. /**
  74114. * Default implementation IShadowGenerator.
  74115. * This is the main object responsible of generating shadows in the framework.
  74116. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74117. */
  74118. export class ShadowGenerator implements IShadowGenerator {
  74119. /**
  74120. * Shadow generator mode None: no filtering applied.
  74121. */
  74122. static readonly FILTER_NONE: number;
  74123. /**
  74124. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74125. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74126. */
  74127. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74128. /**
  74129. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74130. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74131. */
  74132. static readonly FILTER_POISSONSAMPLING: number;
  74133. /**
  74134. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74135. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74136. */
  74137. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74138. /**
  74139. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74140. * edge artifacts on steep falloff.
  74141. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74142. */
  74143. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74144. /**
  74145. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74146. * edge artifacts on steep falloff.
  74147. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74148. */
  74149. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74150. /**
  74151. * Shadow generator mode PCF: Percentage Closer Filtering
  74152. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74153. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74154. */
  74155. static readonly FILTER_PCF: number;
  74156. /**
  74157. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74158. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74159. * Contact Hardening
  74160. */
  74161. static readonly FILTER_PCSS: number;
  74162. /**
  74163. * Reserved for PCF and PCSS
  74164. * Highest Quality.
  74165. *
  74166. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74167. *
  74168. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74169. */
  74170. static readonly QUALITY_HIGH: number;
  74171. /**
  74172. * Reserved for PCF and PCSS
  74173. * Good tradeoff for quality/perf cross devices
  74174. *
  74175. * Execute PCF on a 3*3 kernel.
  74176. *
  74177. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74178. */
  74179. static readonly QUALITY_MEDIUM: number;
  74180. /**
  74181. * Reserved for PCF and PCSS
  74182. * The lowest quality but the fastest.
  74183. *
  74184. * Execute PCF on a 1*1 kernel.
  74185. *
  74186. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74187. */
  74188. static readonly QUALITY_LOW: number;
  74189. /** Gets or sets the custom shader name to use */
  74190. customShaderOptions: ICustomShaderOptions;
  74191. /**
  74192. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74193. */
  74194. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74195. /**
  74196. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74197. */
  74198. onAfterShadowMapRenderObservable: Observable<Effect>;
  74199. /**
  74200. * Observable triggered before a mesh is rendered in the shadow map.
  74201. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74202. */
  74203. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74204. /**
  74205. * Observable triggered after a mesh is rendered in the shadow map.
  74206. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74207. */
  74208. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74209. private _bias;
  74210. /**
  74211. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74212. */
  74213. /**
  74214. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74215. */
  74216. bias: number;
  74217. private _normalBias;
  74218. /**
  74219. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74220. */
  74221. /**
  74222. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74223. */
  74224. normalBias: number;
  74225. private _blurBoxOffset;
  74226. /**
  74227. * Gets the blur box offset: offset applied during the blur pass.
  74228. * Only useful if useKernelBlur = false
  74229. */
  74230. /**
  74231. * Sets the blur box offset: offset applied during the blur pass.
  74232. * Only useful if useKernelBlur = false
  74233. */
  74234. blurBoxOffset: number;
  74235. private _blurScale;
  74236. /**
  74237. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74238. * 2 means half of the size.
  74239. */
  74240. /**
  74241. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74242. * 2 means half of the size.
  74243. */
  74244. blurScale: number;
  74245. private _blurKernel;
  74246. /**
  74247. * Gets the blur kernel: kernel size of the blur pass.
  74248. * Only useful if useKernelBlur = true
  74249. */
  74250. /**
  74251. * Sets the blur kernel: kernel size of the blur pass.
  74252. * Only useful if useKernelBlur = true
  74253. */
  74254. blurKernel: number;
  74255. private _useKernelBlur;
  74256. /**
  74257. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74258. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74259. */
  74260. /**
  74261. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74262. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74263. */
  74264. useKernelBlur: boolean;
  74265. private _depthScale;
  74266. /**
  74267. * Gets the depth scale used in ESM mode.
  74268. */
  74269. /**
  74270. * Sets the depth scale used in ESM mode.
  74271. * This can override the scale stored on the light.
  74272. */
  74273. depthScale: number;
  74274. private _filter;
  74275. /**
  74276. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74277. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74278. */
  74279. /**
  74280. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74281. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74282. */
  74283. filter: number;
  74284. /**
  74285. * Gets if the current filter is set to Poisson Sampling.
  74286. */
  74287. /**
  74288. * Sets the current filter to Poisson Sampling.
  74289. */
  74290. usePoissonSampling: boolean;
  74291. /**
  74292. * Gets if the current filter is set to ESM.
  74293. */
  74294. /**
  74295. * Sets the current filter is to ESM.
  74296. */
  74297. useExponentialShadowMap: boolean;
  74298. /**
  74299. * Gets if the current filter is set to filtered ESM.
  74300. */
  74301. /**
  74302. * Gets if the current filter is set to filtered ESM.
  74303. */
  74304. useBlurExponentialShadowMap: boolean;
  74305. /**
  74306. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74307. * exponential to prevent steep falloff artifacts).
  74308. */
  74309. /**
  74310. * Sets the current filter to "close ESM" (using the inverse of the
  74311. * exponential to prevent steep falloff artifacts).
  74312. */
  74313. useCloseExponentialShadowMap: boolean;
  74314. /**
  74315. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74316. * exponential to prevent steep falloff artifacts).
  74317. */
  74318. /**
  74319. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74320. * exponential to prevent steep falloff artifacts).
  74321. */
  74322. useBlurCloseExponentialShadowMap: boolean;
  74323. /**
  74324. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74325. */
  74326. /**
  74327. * Sets the current filter to "PCF" (percentage closer filtering).
  74328. */
  74329. usePercentageCloserFiltering: boolean;
  74330. private _filteringQuality;
  74331. /**
  74332. * Gets the PCF or PCSS Quality.
  74333. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74334. */
  74335. /**
  74336. * Sets the PCF or PCSS Quality.
  74337. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74338. */
  74339. filteringQuality: number;
  74340. /**
  74341. * Gets if the current filter is set to "PCSS" (contact hardening).
  74342. */
  74343. /**
  74344. * Sets the current filter to "PCSS" (contact hardening).
  74345. */
  74346. useContactHardeningShadow: boolean;
  74347. private _contactHardeningLightSizeUVRatio;
  74348. /**
  74349. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74350. * Using a ratio helps keeping shape stability independently of the map size.
  74351. *
  74352. * It does not account for the light projection as it was having too much
  74353. * instability during the light setup or during light position changes.
  74354. *
  74355. * Only valid if useContactHardeningShadow is true.
  74356. */
  74357. /**
  74358. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74359. * Using a ratio helps keeping shape stability independently of the map size.
  74360. *
  74361. * It does not account for the light projection as it was having too much
  74362. * instability during the light setup or during light position changes.
  74363. *
  74364. * Only valid if useContactHardeningShadow is true.
  74365. */
  74366. contactHardeningLightSizeUVRatio: number;
  74367. private _darkness;
  74368. /** Gets or sets the actual darkness of a shadow */
  74369. darkness: number;
  74370. /**
  74371. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74372. * 0 means strongest and 1 would means no shadow.
  74373. * @returns the darkness.
  74374. */
  74375. getDarkness(): number;
  74376. /**
  74377. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74378. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74379. * @returns the shadow generator allowing fluent coding.
  74380. */
  74381. setDarkness(darkness: number): ShadowGenerator;
  74382. private _transparencyShadow;
  74383. /** Gets or sets the ability to have transparent shadow */
  74384. transparencyShadow: boolean;
  74385. /**
  74386. * Sets the ability to have transparent shadow (boolean).
  74387. * @param transparent True if transparent else False
  74388. * @returns the shadow generator allowing fluent coding
  74389. */
  74390. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74391. private _shadowMap;
  74392. private _shadowMap2;
  74393. /**
  74394. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74395. * @returns The render target texture if present otherwise, null
  74396. */
  74397. getShadowMap(): Nullable<RenderTargetTexture>;
  74398. /**
  74399. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74400. * @returns The render target texture if the shadow map is present otherwise, null
  74401. */
  74402. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74403. /**
  74404. * Gets the class name of that object
  74405. * @returns "ShadowGenerator"
  74406. */
  74407. getClassName(): string;
  74408. /**
  74409. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74410. * @param mesh Mesh to add
  74411. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74412. * @returns the Shadow Generator itself
  74413. */
  74414. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74415. /**
  74416. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74417. * @param mesh Mesh to remove
  74418. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74419. * @returns the Shadow Generator itself
  74420. */
  74421. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74422. /**
  74423. * Controls the extent to which the shadows fade out at the edge of the frustum
  74424. * Used only by directionals and spots
  74425. */
  74426. frustumEdgeFalloff: number;
  74427. private _light;
  74428. /**
  74429. * Returns the associated light object.
  74430. * @returns the light generating the shadow
  74431. */
  74432. getLight(): IShadowLight;
  74433. /**
  74434. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74435. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74436. * It might on the other hand introduce peter panning.
  74437. */
  74438. forceBackFacesOnly: boolean;
  74439. private _scene;
  74440. private _lightDirection;
  74441. private _effect;
  74442. private _viewMatrix;
  74443. private _projectionMatrix;
  74444. private _transformMatrix;
  74445. private _cachedPosition;
  74446. private _cachedDirection;
  74447. private _cachedDefines;
  74448. private _currentRenderID;
  74449. private _boxBlurPostprocess;
  74450. private _kernelBlurXPostprocess;
  74451. private _kernelBlurYPostprocess;
  74452. private _blurPostProcesses;
  74453. private _mapSize;
  74454. private _currentFaceIndex;
  74455. private _currentFaceIndexCache;
  74456. private _textureType;
  74457. private _defaultTextureMatrix;
  74458. /** @hidden */
  74459. static _SceneComponentInitialization: (scene: Scene) => void;
  74460. /**
  74461. * Creates a ShadowGenerator object.
  74462. * A ShadowGenerator is the required tool to use the shadows.
  74463. * Each light casting shadows needs to use its own ShadowGenerator.
  74464. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74465. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74466. * @param light The light object generating the shadows.
  74467. * @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.
  74468. */
  74469. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74470. private _initializeGenerator;
  74471. private _initializeShadowMap;
  74472. private _initializeBlurRTTAndPostProcesses;
  74473. private _renderForShadowMap;
  74474. private _renderSubMeshForShadowMap;
  74475. private _applyFilterValues;
  74476. /**
  74477. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74478. * @param onCompiled Callback triggered at the and of the effects compilation
  74479. * @param options Sets of optional options forcing the compilation with different modes
  74480. */
  74481. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74482. useInstances: boolean;
  74483. }>): void;
  74484. /**
  74485. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74486. * @param options Sets of optional options forcing the compilation with different modes
  74487. * @returns A promise that resolves when the compilation completes
  74488. */
  74489. forceCompilationAsync(options?: Partial<{
  74490. useInstances: boolean;
  74491. }>): Promise<void>;
  74492. /**
  74493. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74494. * @param subMesh The submesh we want to render in the shadow map
  74495. * @param useInstances Defines wether will draw in the map using instances
  74496. * @returns true if ready otherwise, false
  74497. */
  74498. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74499. /**
  74500. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74501. * @param defines Defines of the material we want to update
  74502. * @param lightIndex Index of the light in the enabled light list of the material
  74503. */
  74504. prepareDefines(defines: any, lightIndex: number): void;
  74505. /**
  74506. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74507. * defined in the generator but impacting the effect).
  74508. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74509. * @param effect The effect we are binfing the information for
  74510. */
  74511. bindShadowLight(lightIndex: string, effect: Effect): void;
  74512. /**
  74513. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74514. * (eq to shadow prjection matrix * light transform matrix)
  74515. * @returns The transform matrix used to create the shadow map
  74516. */
  74517. getTransformMatrix(): Matrix;
  74518. /**
  74519. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74520. * Cube and 2D textures for instance.
  74521. */
  74522. recreateShadowMap(): void;
  74523. private _disposeBlurPostProcesses;
  74524. private _disposeRTTandPostProcesses;
  74525. /**
  74526. * Disposes the ShadowGenerator.
  74527. * Returns nothing.
  74528. */
  74529. dispose(): void;
  74530. /**
  74531. * Serializes the shadow generator setup to a json object.
  74532. * @returns The serialized JSON object
  74533. */
  74534. serialize(): any;
  74535. /**
  74536. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74537. * @param parsedShadowGenerator The JSON object to parse
  74538. * @param scene The scene to create the shadow map for
  74539. * @returns The parsed shadow generator
  74540. */
  74541. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74542. }
  74543. }
  74544. declare module BABYLON {
  74545. /**
  74546. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74547. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74548. * 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.
  74549. */
  74550. export abstract class Light extends Node {
  74551. /**
  74552. * Falloff Default: light is falling off following the material specification:
  74553. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74554. */
  74555. static readonly FALLOFF_DEFAULT: number;
  74556. /**
  74557. * Falloff Physical: light is falling off following the inverse squared distance law.
  74558. */
  74559. static readonly FALLOFF_PHYSICAL: number;
  74560. /**
  74561. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74562. * to enhance interoperability with other engines.
  74563. */
  74564. static readonly FALLOFF_GLTF: number;
  74565. /**
  74566. * Falloff Standard: light is falling off like in the standard material
  74567. * to enhance interoperability with other materials.
  74568. */
  74569. static readonly FALLOFF_STANDARD: number;
  74570. /**
  74571. * If every light affecting the material is in this lightmapMode,
  74572. * material.lightmapTexture adds or multiplies
  74573. * (depends on material.useLightmapAsShadowmap)
  74574. * after every other light calculations.
  74575. */
  74576. static readonly LIGHTMAP_DEFAULT: number;
  74577. /**
  74578. * material.lightmapTexture as only diffuse lighting from this light
  74579. * adds only specular lighting from this light
  74580. * adds dynamic shadows
  74581. */
  74582. static readonly LIGHTMAP_SPECULAR: number;
  74583. /**
  74584. * material.lightmapTexture as only lighting
  74585. * no light calculation from this light
  74586. * only adds dynamic shadows from this light
  74587. */
  74588. static readonly LIGHTMAP_SHADOWSONLY: number;
  74589. /**
  74590. * Each light type uses the default quantity according to its type:
  74591. * point/spot lights use luminous intensity
  74592. * directional lights use illuminance
  74593. */
  74594. static readonly INTENSITYMODE_AUTOMATIC: number;
  74595. /**
  74596. * lumen (lm)
  74597. */
  74598. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74599. /**
  74600. * candela (lm/sr)
  74601. */
  74602. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74603. /**
  74604. * lux (lm/m^2)
  74605. */
  74606. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74607. /**
  74608. * nit (cd/m^2)
  74609. */
  74610. static readonly INTENSITYMODE_LUMINANCE: number;
  74611. /**
  74612. * Light type const id of the point light.
  74613. */
  74614. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74615. /**
  74616. * Light type const id of the directional light.
  74617. */
  74618. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74619. /**
  74620. * Light type const id of the spot light.
  74621. */
  74622. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74623. /**
  74624. * Light type const id of the hemispheric light.
  74625. */
  74626. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74627. /**
  74628. * Diffuse gives the basic color to an object.
  74629. */
  74630. diffuse: Color3;
  74631. /**
  74632. * Specular produces a highlight color on an object.
  74633. * Note: This is note affecting PBR materials.
  74634. */
  74635. specular: Color3;
  74636. /**
  74637. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74638. * falling off base on range or angle.
  74639. * This can be set to any values in Light.FALLOFF_x.
  74640. *
  74641. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74642. * other types of materials.
  74643. */
  74644. falloffType: number;
  74645. /**
  74646. * Strength of the light.
  74647. * Note: By default it is define in the framework own unit.
  74648. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74649. */
  74650. intensity: number;
  74651. private _range;
  74652. protected _inverseSquaredRange: number;
  74653. /**
  74654. * Defines how far from the source the light is impacting in scene units.
  74655. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74656. */
  74657. /**
  74658. * Defines how far from the source the light is impacting in scene units.
  74659. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74660. */
  74661. range: number;
  74662. /**
  74663. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74664. * of light.
  74665. */
  74666. private _photometricScale;
  74667. private _intensityMode;
  74668. /**
  74669. * Gets the photometric scale used to interpret the intensity.
  74670. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74671. */
  74672. /**
  74673. * Sets the photometric scale used to interpret the intensity.
  74674. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74675. */
  74676. intensityMode: number;
  74677. private _radius;
  74678. /**
  74679. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74680. */
  74681. /**
  74682. * sets the light radius used by PBR Materials to simulate soft area lights.
  74683. */
  74684. radius: number;
  74685. private _renderPriority;
  74686. /**
  74687. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74688. * exceeding the number allowed of the materials.
  74689. */
  74690. renderPriority: number;
  74691. private _shadowEnabled;
  74692. /**
  74693. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74694. * the current shadow generator.
  74695. */
  74696. /**
  74697. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74698. * the current shadow generator.
  74699. */
  74700. shadowEnabled: boolean;
  74701. private _includedOnlyMeshes;
  74702. /**
  74703. * Gets the only meshes impacted by this light.
  74704. */
  74705. /**
  74706. * Sets the only meshes impacted by this light.
  74707. */
  74708. includedOnlyMeshes: AbstractMesh[];
  74709. private _excludedMeshes;
  74710. /**
  74711. * Gets the meshes not impacted by this light.
  74712. */
  74713. /**
  74714. * Sets the meshes not impacted by this light.
  74715. */
  74716. excludedMeshes: AbstractMesh[];
  74717. private _excludeWithLayerMask;
  74718. /**
  74719. * Gets the layer id use to find what meshes are not impacted by the light.
  74720. * Inactive if 0
  74721. */
  74722. /**
  74723. * Sets the layer id use to find what meshes are not impacted by the light.
  74724. * Inactive if 0
  74725. */
  74726. excludeWithLayerMask: number;
  74727. private _includeOnlyWithLayerMask;
  74728. /**
  74729. * Gets the layer id use to find what meshes are impacted by the light.
  74730. * Inactive if 0
  74731. */
  74732. /**
  74733. * Sets the layer id use to find what meshes are impacted by the light.
  74734. * Inactive if 0
  74735. */
  74736. includeOnlyWithLayerMask: number;
  74737. private _lightmapMode;
  74738. /**
  74739. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74740. */
  74741. /**
  74742. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74743. */
  74744. lightmapMode: number;
  74745. /**
  74746. * Shadow generator associted to the light.
  74747. * @hidden Internal use only.
  74748. */
  74749. _shadowGenerator: Nullable<IShadowGenerator>;
  74750. /**
  74751. * @hidden Internal use only.
  74752. */
  74753. _excludedMeshesIds: string[];
  74754. /**
  74755. * @hidden Internal use only.
  74756. */
  74757. _includedOnlyMeshesIds: string[];
  74758. /**
  74759. * The current light unifom buffer.
  74760. * @hidden Internal use only.
  74761. */
  74762. _uniformBuffer: UniformBuffer;
  74763. /**
  74764. * Creates a Light object in the scene.
  74765. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74766. * @param name The firendly name of the light
  74767. * @param scene The scene the light belongs too
  74768. */
  74769. constructor(name: string, scene: Scene);
  74770. protected abstract _buildUniformLayout(): void;
  74771. /**
  74772. * Sets the passed Effect "effect" with the Light information.
  74773. * @param effect The effect to update
  74774. * @param lightIndex The index of the light in the effect to update
  74775. * @returns The light
  74776. */
  74777. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74778. /**
  74779. * Returns the string "Light".
  74780. * @returns the class name
  74781. */
  74782. getClassName(): string;
  74783. /** @hidden */
  74784. readonly _isLight: boolean;
  74785. /**
  74786. * Converts the light information to a readable string for debug purpose.
  74787. * @param fullDetails Supports for multiple levels of logging within scene loading
  74788. * @returns the human readable light info
  74789. */
  74790. toString(fullDetails?: boolean): string;
  74791. /** @hidden */
  74792. protected _syncParentEnabledState(): void;
  74793. /**
  74794. * Set the enabled state of this node.
  74795. * @param value - the new enabled state
  74796. */
  74797. setEnabled(value: boolean): void;
  74798. /**
  74799. * Returns the Light associated shadow generator if any.
  74800. * @return the associated shadow generator.
  74801. */
  74802. getShadowGenerator(): Nullable<IShadowGenerator>;
  74803. /**
  74804. * Returns a Vector3, the absolute light position in the World.
  74805. * @returns the world space position of the light
  74806. */
  74807. getAbsolutePosition(): Vector3;
  74808. /**
  74809. * Specifies if the light will affect the passed mesh.
  74810. * @param mesh The mesh to test against the light
  74811. * @return true the mesh is affected otherwise, false.
  74812. */
  74813. canAffectMesh(mesh: AbstractMesh): boolean;
  74814. /**
  74815. * Sort function to order lights for rendering.
  74816. * @param a First Light object to compare to second.
  74817. * @param b Second Light object to compare first.
  74818. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74819. */
  74820. static CompareLightsPriority(a: Light, b: Light): number;
  74821. /**
  74822. * Releases resources associated with this node.
  74823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74825. */
  74826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74827. /**
  74828. * Returns the light type ID (integer).
  74829. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74830. */
  74831. getTypeID(): number;
  74832. /**
  74833. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74834. * @returns the scaled intensity in intensity mode unit
  74835. */
  74836. getScaledIntensity(): number;
  74837. /**
  74838. * Returns a new Light object, named "name", from the current one.
  74839. * @param name The name of the cloned light
  74840. * @returns the new created light
  74841. */
  74842. clone(name: string): Nullable<Light>;
  74843. /**
  74844. * Serializes the current light into a Serialization object.
  74845. * @returns the serialized object.
  74846. */
  74847. serialize(): any;
  74848. /**
  74849. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74850. * This new light is named "name" and added to the passed scene.
  74851. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74852. * @param name The friendly name of the light
  74853. * @param scene The scene the new light will belong to
  74854. * @returns the constructor function
  74855. */
  74856. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74857. /**
  74858. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74859. * @param parsedLight The JSON representation of the light
  74860. * @param scene The scene to create the parsed light in
  74861. * @returns the created light after parsing
  74862. */
  74863. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74864. private _hookArrayForExcluded;
  74865. private _hookArrayForIncludedOnly;
  74866. private _resyncMeshes;
  74867. /**
  74868. * Forces the meshes to update their light related information in their rendering used effects
  74869. * @hidden Internal Use Only
  74870. */
  74871. _markMeshesAsLightDirty(): void;
  74872. /**
  74873. * Recomputes the cached photometric scale if needed.
  74874. */
  74875. private _computePhotometricScale;
  74876. /**
  74877. * Returns the Photometric Scale according to the light type and intensity mode.
  74878. */
  74879. private _getPhotometricScale;
  74880. /**
  74881. * Reorder the light in the scene according to their defined priority.
  74882. * @hidden Internal Use Only
  74883. */
  74884. _reorderLightsInScene(): void;
  74885. /**
  74886. * Prepares the list of defines specific to the light type.
  74887. * @param defines the list of defines
  74888. * @param lightIndex defines the index of the light for the effect
  74889. */
  74890. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74891. }
  74892. }
  74893. declare module BABYLON {
  74894. /**
  74895. * Interface used to define Action
  74896. */
  74897. export interface IAction {
  74898. /**
  74899. * Trigger for the action
  74900. */
  74901. trigger: number;
  74902. /** Options of the trigger */
  74903. triggerOptions: any;
  74904. /**
  74905. * Gets the trigger parameters
  74906. * @returns the trigger parameters
  74907. */
  74908. getTriggerParameter(): any;
  74909. /**
  74910. * Internal only - executes current action event
  74911. * @hidden
  74912. */
  74913. _executeCurrent(evt?: ActionEvent): void;
  74914. /**
  74915. * Serialize placeholder for child classes
  74916. * @param parent of child
  74917. * @returns the serialized object
  74918. */
  74919. serialize(parent: any): any;
  74920. /**
  74921. * Internal only
  74922. * @hidden
  74923. */
  74924. _prepare(): void;
  74925. /**
  74926. * Internal only - manager for action
  74927. * @hidden
  74928. */
  74929. _actionManager: AbstractActionManager;
  74930. /**
  74931. * Adds action to chain of actions, may be a DoNothingAction
  74932. * @param action defines the next action to execute
  74933. * @returns The action passed in
  74934. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74935. */
  74936. then(action: IAction): IAction;
  74937. }
  74938. /**
  74939. * The action to be carried out following a trigger
  74940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  74941. */
  74942. export class Action implements IAction {
  74943. /** the trigger, with or without parameters, for the action */
  74944. triggerOptions: any;
  74945. /**
  74946. * Trigger for the action
  74947. */
  74948. trigger: number;
  74949. /**
  74950. * Internal only - manager for action
  74951. * @hidden
  74952. */
  74953. _actionManager: ActionManager;
  74954. private _nextActiveAction;
  74955. private _child;
  74956. private _condition?;
  74957. private _triggerParameter;
  74958. /**
  74959. * An event triggered prior to action being executed.
  74960. */
  74961. onBeforeExecuteObservable: Observable<Action>;
  74962. /**
  74963. * Creates a new Action
  74964. * @param triggerOptions the trigger, with or without parameters, for the action
  74965. * @param condition an optional determinant of action
  74966. */
  74967. constructor(
  74968. /** the trigger, with or without parameters, for the action */
  74969. triggerOptions: any, condition?: Condition);
  74970. /**
  74971. * Internal only
  74972. * @hidden
  74973. */
  74974. _prepare(): void;
  74975. /**
  74976. * Gets the trigger parameters
  74977. * @returns the trigger parameters
  74978. */
  74979. getTriggerParameter(): any;
  74980. /**
  74981. * Internal only - executes current action event
  74982. * @hidden
  74983. */
  74984. _executeCurrent(evt?: ActionEvent): void;
  74985. /**
  74986. * Execute placeholder for child classes
  74987. * @param evt optional action event
  74988. */
  74989. execute(evt?: ActionEvent): void;
  74990. /**
  74991. * Skips to next active action
  74992. */
  74993. skipToNextActiveAction(): void;
  74994. /**
  74995. * Adds action to chain of actions, may be a DoNothingAction
  74996. * @param action defines the next action to execute
  74997. * @returns The action passed in
  74998. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74999. */
  75000. then(action: Action): Action;
  75001. /**
  75002. * Internal only
  75003. * @hidden
  75004. */
  75005. _getProperty(propertyPath: string): string;
  75006. /**
  75007. * Internal only
  75008. * @hidden
  75009. */
  75010. _getEffectiveTarget(target: any, propertyPath: string): any;
  75011. /**
  75012. * Serialize placeholder for child classes
  75013. * @param parent of child
  75014. * @returns the serialized object
  75015. */
  75016. serialize(parent: any): any;
  75017. /**
  75018. * Internal only called by serialize
  75019. * @hidden
  75020. */
  75021. protected _serialize(serializedAction: any, parent?: any): any;
  75022. /**
  75023. * Internal only
  75024. * @hidden
  75025. */
  75026. static _SerializeValueAsString: (value: any) => string;
  75027. /**
  75028. * Internal only
  75029. * @hidden
  75030. */
  75031. static _GetTargetProperty: (target: Node | Scene) => {
  75032. name: string;
  75033. targetType: string;
  75034. value: string;
  75035. };
  75036. }
  75037. }
  75038. declare module BABYLON {
  75039. /**
  75040. * A Condition applied to an Action
  75041. */
  75042. export class Condition {
  75043. /**
  75044. * Internal only - manager for action
  75045. * @hidden
  75046. */
  75047. _actionManager: ActionManager;
  75048. /**
  75049. * Internal only
  75050. * @hidden
  75051. */
  75052. _evaluationId: number;
  75053. /**
  75054. * Internal only
  75055. * @hidden
  75056. */
  75057. _currentResult: boolean;
  75058. /**
  75059. * Creates a new Condition
  75060. * @param actionManager the manager of the action the condition is applied to
  75061. */
  75062. constructor(actionManager: ActionManager);
  75063. /**
  75064. * Check if the current condition is valid
  75065. * @returns a boolean
  75066. */
  75067. isValid(): boolean;
  75068. /**
  75069. * Internal only
  75070. * @hidden
  75071. */
  75072. _getProperty(propertyPath: string): string;
  75073. /**
  75074. * Internal only
  75075. * @hidden
  75076. */
  75077. _getEffectiveTarget(target: any, propertyPath: string): any;
  75078. /**
  75079. * Serialize placeholder for child classes
  75080. * @returns the serialized object
  75081. */
  75082. serialize(): any;
  75083. /**
  75084. * Internal only
  75085. * @hidden
  75086. */
  75087. protected _serialize(serializedCondition: any): any;
  75088. }
  75089. /**
  75090. * Defines specific conditional operators as extensions of Condition
  75091. */
  75092. export class ValueCondition extends Condition {
  75093. /** path to specify the property of the target the conditional operator uses */
  75094. propertyPath: string;
  75095. /** the value compared by the conditional operator against the current value of the property */
  75096. value: any;
  75097. /** the conditional operator, default ValueCondition.IsEqual */
  75098. operator: number;
  75099. /**
  75100. * Internal only
  75101. * @hidden
  75102. */
  75103. private static _IsEqual;
  75104. /**
  75105. * Internal only
  75106. * @hidden
  75107. */
  75108. private static _IsDifferent;
  75109. /**
  75110. * Internal only
  75111. * @hidden
  75112. */
  75113. private static _IsGreater;
  75114. /**
  75115. * Internal only
  75116. * @hidden
  75117. */
  75118. private static _IsLesser;
  75119. /**
  75120. * returns the number for IsEqual
  75121. */
  75122. static readonly IsEqual: number;
  75123. /**
  75124. * Returns the number for IsDifferent
  75125. */
  75126. static readonly IsDifferent: number;
  75127. /**
  75128. * Returns the number for IsGreater
  75129. */
  75130. static readonly IsGreater: number;
  75131. /**
  75132. * Returns the number for IsLesser
  75133. */
  75134. static readonly IsLesser: number;
  75135. /**
  75136. * Internal only The action manager for the condition
  75137. * @hidden
  75138. */
  75139. _actionManager: ActionManager;
  75140. /**
  75141. * Internal only
  75142. * @hidden
  75143. */
  75144. private _target;
  75145. /**
  75146. * Internal only
  75147. * @hidden
  75148. */
  75149. private _effectiveTarget;
  75150. /**
  75151. * Internal only
  75152. * @hidden
  75153. */
  75154. private _property;
  75155. /**
  75156. * Creates a new ValueCondition
  75157. * @param actionManager manager for the action the condition applies to
  75158. * @param target for the action
  75159. * @param propertyPath path to specify the property of the target the conditional operator uses
  75160. * @param value the value compared by the conditional operator against the current value of the property
  75161. * @param operator the conditional operator, default ValueCondition.IsEqual
  75162. */
  75163. constructor(actionManager: ActionManager, target: any,
  75164. /** path to specify the property of the target the conditional operator uses */
  75165. propertyPath: string,
  75166. /** the value compared by the conditional operator against the current value of the property */
  75167. value: any,
  75168. /** the conditional operator, default ValueCondition.IsEqual */
  75169. operator?: number);
  75170. /**
  75171. * Compares the given value with the property value for the specified conditional operator
  75172. * @returns the result of the comparison
  75173. */
  75174. isValid(): boolean;
  75175. /**
  75176. * Serialize the ValueCondition into a JSON compatible object
  75177. * @returns serialization object
  75178. */
  75179. serialize(): any;
  75180. /**
  75181. * Gets the name of the conditional operator for the ValueCondition
  75182. * @param operator the conditional operator
  75183. * @returns the name
  75184. */
  75185. static GetOperatorName(operator: number): string;
  75186. }
  75187. /**
  75188. * Defines a predicate condition as an extension of Condition
  75189. */
  75190. export class PredicateCondition extends Condition {
  75191. /** defines the predicate function used to validate the condition */
  75192. predicate: () => boolean;
  75193. /**
  75194. * Internal only - manager for action
  75195. * @hidden
  75196. */
  75197. _actionManager: ActionManager;
  75198. /**
  75199. * Creates a new PredicateCondition
  75200. * @param actionManager manager for the action the condition applies to
  75201. * @param predicate defines the predicate function used to validate the condition
  75202. */
  75203. constructor(actionManager: ActionManager,
  75204. /** defines the predicate function used to validate the condition */
  75205. predicate: () => boolean);
  75206. /**
  75207. * @returns the validity of the predicate condition
  75208. */
  75209. isValid(): boolean;
  75210. }
  75211. /**
  75212. * Defines a state condition as an extension of Condition
  75213. */
  75214. export class StateCondition extends Condition {
  75215. /** Value to compare with target state */
  75216. value: string;
  75217. /**
  75218. * Internal only - manager for action
  75219. * @hidden
  75220. */
  75221. _actionManager: ActionManager;
  75222. /**
  75223. * Internal only
  75224. * @hidden
  75225. */
  75226. private _target;
  75227. /**
  75228. * Creates a new StateCondition
  75229. * @param actionManager manager for the action the condition applies to
  75230. * @param target of the condition
  75231. * @param value to compare with target state
  75232. */
  75233. constructor(actionManager: ActionManager, target: any,
  75234. /** Value to compare with target state */
  75235. value: string);
  75236. /**
  75237. * Gets a boolean indicating if the current condition is met
  75238. * @returns the validity of the state
  75239. */
  75240. isValid(): boolean;
  75241. /**
  75242. * Serialize the StateCondition into a JSON compatible object
  75243. * @returns serialization object
  75244. */
  75245. serialize(): any;
  75246. }
  75247. }
  75248. declare module BABYLON {
  75249. /**
  75250. * This defines an action responsible to toggle a boolean once triggered.
  75251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75252. */
  75253. export class SwitchBooleanAction extends Action {
  75254. /**
  75255. * The path to the boolean property in the target object
  75256. */
  75257. propertyPath: string;
  75258. private _target;
  75259. private _effectiveTarget;
  75260. private _property;
  75261. /**
  75262. * Instantiate the action
  75263. * @param triggerOptions defines the trigger options
  75264. * @param target defines the object containing the boolean
  75265. * @param propertyPath defines the path to the boolean property in the target object
  75266. * @param condition defines the trigger related conditions
  75267. */
  75268. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  75269. /** @hidden */
  75270. _prepare(): void;
  75271. /**
  75272. * Execute the action toggle the boolean value.
  75273. */
  75274. execute(): void;
  75275. /**
  75276. * Serializes the actions and its related information.
  75277. * @param parent defines the object to serialize in
  75278. * @returns the serialized object
  75279. */
  75280. serialize(parent: any): any;
  75281. }
  75282. /**
  75283. * This defines an action responsible to set a the state field of the target
  75284. * to a desired value once triggered.
  75285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75286. */
  75287. export class SetStateAction extends Action {
  75288. /**
  75289. * The value to store in the state field.
  75290. */
  75291. value: string;
  75292. private _target;
  75293. /**
  75294. * Instantiate the action
  75295. * @param triggerOptions defines the trigger options
  75296. * @param target defines the object containing the state property
  75297. * @param value defines the value to store in the state field
  75298. * @param condition defines the trigger related conditions
  75299. */
  75300. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  75301. /**
  75302. * Execute the action and store the value on the target state property.
  75303. */
  75304. execute(): void;
  75305. /**
  75306. * Serializes the actions and its related information.
  75307. * @param parent defines the object to serialize in
  75308. * @returns the serialized object
  75309. */
  75310. serialize(parent: any): any;
  75311. }
  75312. /**
  75313. * This defines an action responsible to set a property of the target
  75314. * to a desired value once triggered.
  75315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75316. */
  75317. export class SetValueAction extends Action {
  75318. /**
  75319. * The path of the property to set in the target.
  75320. */
  75321. propertyPath: string;
  75322. /**
  75323. * The value to set in the property
  75324. */
  75325. value: any;
  75326. private _target;
  75327. private _effectiveTarget;
  75328. private _property;
  75329. /**
  75330. * Instantiate the action
  75331. * @param triggerOptions defines the trigger options
  75332. * @param target defines the object containing the property
  75333. * @param propertyPath defines the path of the property to set in the target
  75334. * @param value defines the value to set in the property
  75335. * @param condition defines the trigger related conditions
  75336. */
  75337. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75338. /** @hidden */
  75339. _prepare(): void;
  75340. /**
  75341. * Execute the action and set the targetted property to the desired value.
  75342. */
  75343. execute(): void;
  75344. /**
  75345. * Serializes the actions and its related information.
  75346. * @param parent defines the object to serialize in
  75347. * @returns the serialized object
  75348. */
  75349. serialize(parent: any): any;
  75350. }
  75351. /**
  75352. * This defines an action responsible to increment the target value
  75353. * to a desired value once triggered.
  75354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75355. */
  75356. export class IncrementValueAction extends Action {
  75357. /**
  75358. * The path of the property to increment in the target.
  75359. */
  75360. propertyPath: string;
  75361. /**
  75362. * The value we should increment the property by.
  75363. */
  75364. value: any;
  75365. private _target;
  75366. private _effectiveTarget;
  75367. private _property;
  75368. /**
  75369. * Instantiate the action
  75370. * @param triggerOptions defines the trigger options
  75371. * @param target defines the object containing the property
  75372. * @param propertyPath defines the path of the property to increment in the target
  75373. * @param value defines the value value we should increment the property by
  75374. * @param condition defines the trigger related conditions
  75375. */
  75376. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75377. /** @hidden */
  75378. _prepare(): void;
  75379. /**
  75380. * Execute the action and increment the target of the value amount.
  75381. */
  75382. execute(): void;
  75383. /**
  75384. * Serializes the actions and its related information.
  75385. * @param parent defines the object to serialize in
  75386. * @returns the serialized object
  75387. */
  75388. serialize(parent: any): any;
  75389. }
  75390. /**
  75391. * This defines an action responsible to start an animation once triggered.
  75392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75393. */
  75394. export class PlayAnimationAction extends Action {
  75395. /**
  75396. * Where the animation should start (animation frame)
  75397. */
  75398. from: number;
  75399. /**
  75400. * Where the animation should stop (animation frame)
  75401. */
  75402. to: number;
  75403. /**
  75404. * Define if the animation should loop or stop after the first play.
  75405. */
  75406. loop?: boolean;
  75407. private _target;
  75408. /**
  75409. * Instantiate the action
  75410. * @param triggerOptions defines the trigger options
  75411. * @param target defines the target animation or animation name
  75412. * @param from defines from where the animation should start (animation frame)
  75413. * @param end defines where the animation should stop (animation frame)
  75414. * @param loop defines if the animation should loop or stop after the first play
  75415. * @param condition defines the trigger related conditions
  75416. */
  75417. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  75418. /** @hidden */
  75419. _prepare(): void;
  75420. /**
  75421. * Execute the action and play the animation.
  75422. */
  75423. execute(): void;
  75424. /**
  75425. * Serializes the actions and its related information.
  75426. * @param parent defines the object to serialize in
  75427. * @returns the serialized object
  75428. */
  75429. serialize(parent: any): any;
  75430. }
  75431. /**
  75432. * This defines an action responsible to stop an animation once triggered.
  75433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75434. */
  75435. export class StopAnimationAction extends Action {
  75436. private _target;
  75437. /**
  75438. * Instantiate the action
  75439. * @param triggerOptions defines the trigger options
  75440. * @param target defines the target animation or animation name
  75441. * @param condition defines the trigger related conditions
  75442. */
  75443. constructor(triggerOptions: any, target: any, condition?: Condition);
  75444. /** @hidden */
  75445. _prepare(): void;
  75446. /**
  75447. * Execute the action and stop the animation.
  75448. */
  75449. execute(): void;
  75450. /**
  75451. * Serializes the actions and its related information.
  75452. * @param parent defines the object to serialize in
  75453. * @returns the serialized object
  75454. */
  75455. serialize(parent: any): any;
  75456. }
  75457. /**
  75458. * This defines an action responsible that does nothing once triggered.
  75459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75460. */
  75461. export class DoNothingAction extends Action {
  75462. /**
  75463. * Instantiate the action
  75464. * @param triggerOptions defines the trigger options
  75465. * @param condition defines the trigger related conditions
  75466. */
  75467. constructor(triggerOptions?: any, condition?: Condition);
  75468. /**
  75469. * Execute the action and do nothing.
  75470. */
  75471. execute(): void;
  75472. /**
  75473. * Serializes the actions and its related information.
  75474. * @param parent defines the object to serialize in
  75475. * @returns the serialized object
  75476. */
  75477. serialize(parent: any): any;
  75478. }
  75479. /**
  75480. * This defines an action responsible to trigger several actions once triggered.
  75481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75482. */
  75483. export class CombineAction extends Action {
  75484. /**
  75485. * The list of aggregated animations to run.
  75486. */
  75487. children: Action[];
  75488. /**
  75489. * Instantiate the action
  75490. * @param triggerOptions defines the trigger options
  75491. * @param children defines the list of aggregated animations to run
  75492. * @param condition defines the trigger related conditions
  75493. */
  75494. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  75495. /** @hidden */
  75496. _prepare(): void;
  75497. /**
  75498. * Execute the action and executes all the aggregated actions.
  75499. */
  75500. execute(evt: ActionEvent): void;
  75501. /**
  75502. * Serializes the actions and its related information.
  75503. * @param parent defines the object to serialize in
  75504. * @returns the serialized object
  75505. */
  75506. serialize(parent: any): any;
  75507. }
  75508. /**
  75509. * This defines an action responsible to run code (external event) once triggered.
  75510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75511. */
  75512. export class ExecuteCodeAction extends Action {
  75513. /**
  75514. * The callback function to run.
  75515. */
  75516. func: (evt: ActionEvent) => void;
  75517. /**
  75518. * Instantiate the action
  75519. * @param triggerOptions defines the trigger options
  75520. * @param func defines the callback function to run
  75521. * @param condition defines the trigger related conditions
  75522. */
  75523. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  75524. /**
  75525. * Execute the action and run the attached code.
  75526. */
  75527. execute(evt: ActionEvent): void;
  75528. }
  75529. /**
  75530. * This defines an action responsible to set the parent property of the target once triggered.
  75531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75532. */
  75533. export class SetParentAction extends Action {
  75534. private _parent;
  75535. private _target;
  75536. /**
  75537. * Instantiate the action
  75538. * @param triggerOptions defines the trigger options
  75539. * @param target defines the target containing the parent property
  75540. * @param parent defines from where the animation should start (animation frame)
  75541. * @param condition defines the trigger related conditions
  75542. */
  75543. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  75544. /** @hidden */
  75545. _prepare(): void;
  75546. /**
  75547. * Execute the action and set the parent property.
  75548. */
  75549. execute(): void;
  75550. /**
  75551. * Serializes the actions and its related information.
  75552. * @param parent defines the object to serialize in
  75553. * @returns the serialized object
  75554. */
  75555. serialize(parent: any): any;
  75556. }
  75557. }
  75558. declare module BABYLON {
  75559. /**
  75560. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  75561. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  75562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75563. */
  75564. export class ActionManager extends AbstractActionManager {
  75565. /**
  75566. * Nothing
  75567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75568. */
  75569. static readonly NothingTrigger: number;
  75570. /**
  75571. * On pick
  75572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75573. */
  75574. static readonly OnPickTrigger: number;
  75575. /**
  75576. * On left pick
  75577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75578. */
  75579. static readonly OnLeftPickTrigger: number;
  75580. /**
  75581. * On right pick
  75582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75583. */
  75584. static readonly OnRightPickTrigger: number;
  75585. /**
  75586. * On center pick
  75587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75588. */
  75589. static readonly OnCenterPickTrigger: number;
  75590. /**
  75591. * On pick down
  75592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75593. */
  75594. static readonly OnPickDownTrigger: number;
  75595. /**
  75596. * On double pick
  75597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75598. */
  75599. static readonly OnDoublePickTrigger: number;
  75600. /**
  75601. * On pick up
  75602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75603. */
  75604. static readonly OnPickUpTrigger: number;
  75605. /**
  75606. * On pick out.
  75607. * This trigger will only be raised if you also declared a OnPickDown
  75608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75609. */
  75610. static readonly OnPickOutTrigger: number;
  75611. /**
  75612. * On long press
  75613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75614. */
  75615. static readonly OnLongPressTrigger: number;
  75616. /**
  75617. * On pointer over
  75618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75619. */
  75620. static readonly OnPointerOverTrigger: number;
  75621. /**
  75622. * On pointer out
  75623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75624. */
  75625. static readonly OnPointerOutTrigger: number;
  75626. /**
  75627. * On every frame
  75628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75629. */
  75630. static readonly OnEveryFrameTrigger: number;
  75631. /**
  75632. * On intersection enter
  75633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75634. */
  75635. static readonly OnIntersectionEnterTrigger: number;
  75636. /**
  75637. * On intersection exit
  75638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75639. */
  75640. static readonly OnIntersectionExitTrigger: number;
  75641. /**
  75642. * On key down
  75643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75644. */
  75645. static readonly OnKeyDownTrigger: number;
  75646. /**
  75647. * On key up
  75648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75649. */
  75650. static readonly OnKeyUpTrigger: number;
  75651. private _scene;
  75652. /**
  75653. * Creates a new action manager
  75654. * @param scene defines the hosting scene
  75655. */
  75656. constructor(scene: Scene);
  75657. /**
  75658. * Releases all associated resources
  75659. */
  75660. dispose(): void;
  75661. /**
  75662. * Gets hosting scene
  75663. * @returns the hosting scene
  75664. */
  75665. getScene(): Scene;
  75666. /**
  75667. * Does this action manager handles actions of any of the given triggers
  75668. * @param triggers defines the triggers to be tested
  75669. * @return a boolean indicating whether one (or more) of the triggers is handled
  75670. */
  75671. hasSpecificTriggers(triggers: number[]): boolean;
  75672. /**
  75673. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  75674. * speed.
  75675. * @param triggerA defines the trigger to be tested
  75676. * @param triggerB defines the trigger to be tested
  75677. * @return a boolean indicating whether one (or more) of the triggers is handled
  75678. */
  75679. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  75680. /**
  75681. * Does this action manager handles actions of a given trigger
  75682. * @param trigger defines the trigger to be tested
  75683. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  75684. * @return whether the trigger is handled
  75685. */
  75686. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  75687. /**
  75688. * Does this action manager has pointer triggers
  75689. */
  75690. readonly hasPointerTriggers: boolean;
  75691. /**
  75692. * Does this action manager has pick triggers
  75693. */
  75694. readonly hasPickTriggers: boolean;
  75695. /**
  75696. * Registers an action to this action manager
  75697. * @param action defines the action to be registered
  75698. * @return the action amended (prepared) after registration
  75699. */
  75700. registerAction(action: IAction): Nullable<IAction>;
  75701. /**
  75702. * Unregisters an action to this action manager
  75703. * @param action defines the action to be unregistered
  75704. * @return a boolean indicating whether the action has been unregistered
  75705. */
  75706. unregisterAction(action: IAction): Boolean;
  75707. /**
  75708. * Process a specific trigger
  75709. * @param trigger defines the trigger to process
  75710. * @param evt defines the event details to be processed
  75711. */
  75712. processTrigger(trigger: number, evt?: IActionEvent): void;
  75713. /** @hidden */
  75714. _getEffectiveTarget(target: any, propertyPath: string): any;
  75715. /** @hidden */
  75716. _getProperty(propertyPath: string): string;
  75717. /**
  75718. * Serialize this manager to a JSON object
  75719. * @param name defines the property name to store this manager
  75720. * @returns a JSON representation of this manager
  75721. */
  75722. serialize(name: string): any;
  75723. /**
  75724. * Creates a new ActionManager from a JSON data
  75725. * @param parsedActions defines the JSON data to read from
  75726. * @param object defines the hosting mesh
  75727. * @param scene defines the hosting scene
  75728. */
  75729. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75730. /**
  75731. * Get a trigger name by index
  75732. * @param trigger defines the trigger index
  75733. * @returns a trigger name
  75734. */
  75735. static GetTriggerName(trigger: number): string;
  75736. }
  75737. }
  75738. declare module BABYLON {
  75739. /**
  75740. * Class representing a ray with position and direction
  75741. */
  75742. export class Ray {
  75743. /** origin point */
  75744. origin: Vector3;
  75745. /** direction */
  75746. direction: Vector3;
  75747. /** length of the ray */
  75748. length: number;
  75749. private static readonly TmpVector3;
  75750. private _tmpRay;
  75751. /**
  75752. * Creates a new ray
  75753. * @param origin origin point
  75754. * @param direction direction
  75755. * @param length length of the ray
  75756. */
  75757. constructor(
  75758. /** origin point */
  75759. origin: Vector3,
  75760. /** direction */
  75761. direction: Vector3,
  75762. /** length of the ray */
  75763. length?: number);
  75764. /**
  75765. * Checks if the ray intersects a box
  75766. * @param minimum bound of the box
  75767. * @param maximum bound of the box
  75768. * @param intersectionTreshold extra extend to be added to the box in all direction
  75769. * @returns if the box was hit
  75770. */
  75771. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75772. /**
  75773. * Checks if the ray intersects a box
  75774. * @param box the bounding box to check
  75775. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75776. * @returns if the box was hit
  75777. */
  75778. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75779. /**
  75780. * If the ray hits a sphere
  75781. * @param sphere the bounding sphere to check
  75782. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75783. * @returns true if it hits the sphere
  75784. */
  75785. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75786. /**
  75787. * If the ray hits a triange
  75788. * @param vertex0 triangle vertex
  75789. * @param vertex1 triangle vertex
  75790. * @param vertex2 triangle vertex
  75791. * @returns intersection information if hit
  75792. */
  75793. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75794. /**
  75795. * Checks if ray intersects a plane
  75796. * @param plane the plane to check
  75797. * @returns the distance away it was hit
  75798. */
  75799. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75800. /**
  75801. * Calculate the intercept of a ray on a given axis
  75802. * @param axis to check 'x' | 'y' | 'z'
  75803. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75804. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75805. */
  75806. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75807. /**
  75808. * Checks if ray intersects a mesh
  75809. * @param mesh the mesh to check
  75810. * @param fastCheck if only the bounding box should checked
  75811. * @returns picking info of the intersecton
  75812. */
  75813. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75814. /**
  75815. * Checks if ray intersects a mesh
  75816. * @param meshes the meshes to check
  75817. * @param fastCheck if only the bounding box should checked
  75818. * @param results array to store result in
  75819. * @returns Array of picking infos
  75820. */
  75821. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75822. private _comparePickingInfo;
  75823. private static smallnum;
  75824. private static rayl;
  75825. /**
  75826. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75827. * @param sega the first point of the segment to test the intersection against
  75828. * @param segb the second point of the segment to test the intersection against
  75829. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75830. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75831. */
  75832. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75833. /**
  75834. * Update the ray from viewport position
  75835. * @param x position
  75836. * @param y y position
  75837. * @param viewportWidth viewport width
  75838. * @param viewportHeight viewport height
  75839. * @param world world matrix
  75840. * @param view view matrix
  75841. * @param projection projection matrix
  75842. * @returns this ray updated
  75843. */
  75844. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75845. /**
  75846. * Creates a ray with origin and direction of 0,0,0
  75847. * @returns the new ray
  75848. */
  75849. static Zero(): Ray;
  75850. /**
  75851. * Creates a new ray from screen space and viewport
  75852. * @param x position
  75853. * @param y y position
  75854. * @param viewportWidth viewport width
  75855. * @param viewportHeight viewport height
  75856. * @param world world matrix
  75857. * @param view view matrix
  75858. * @param projection projection matrix
  75859. * @returns new ray
  75860. */
  75861. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75862. /**
  75863. * 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
  75864. * transformed to the given world matrix.
  75865. * @param origin The origin point
  75866. * @param end The end point
  75867. * @param world a matrix to transform the ray to. Default is the identity matrix.
  75868. * @returns the new ray
  75869. */
  75870. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  75871. /**
  75872. * Transforms a ray by a matrix
  75873. * @param ray ray to transform
  75874. * @param matrix matrix to apply
  75875. * @returns the resulting new ray
  75876. */
  75877. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  75878. /**
  75879. * Transforms a ray by a matrix
  75880. * @param ray ray to transform
  75881. * @param matrix matrix to apply
  75882. * @param result ray to store result in
  75883. */
  75884. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  75885. /**
  75886. * Unproject a ray from screen space to object space
  75887. * @param sourceX defines the screen space x coordinate to use
  75888. * @param sourceY defines the screen space y coordinate to use
  75889. * @param viewportWidth defines the current width of the viewport
  75890. * @param viewportHeight defines the current height of the viewport
  75891. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75892. * @param view defines the view matrix to use
  75893. * @param projection defines the projection matrix to use
  75894. */
  75895. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  75896. }
  75897. /**
  75898. * Type used to define predicate used to select faces when a mesh intersection is detected
  75899. */
  75900. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  75901. interface Scene {
  75902. /** @hidden */
  75903. _tempPickingRay: Nullable<Ray>;
  75904. /** @hidden */
  75905. _cachedRayForTransform: Ray;
  75906. /** @hidden */
  75907. _pickWithRayInverseMatrix: Matrix;
  75908. /** @hidden */
  75909. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  75910. /** @hidden */
  75911. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  75912. }
  75913. }
  75914. declare module BABYLON {
  75915. /**
  75916. * Groups all the scene component constants in one place to ease maintenance.
  75917. * @hidden
  75918. */
  75919. export class SceneComponentConstants {
  75920. static readonly NAME_EFFECTLAYER: string;
  75921. static readonly NAME_LAYER: string;
  75922. static readonly NAME_LENSFLARESYSTEM: string;
  75923. static readonly NAME_BOUNDINGBOXRENDERER: string;
  75924. static readonly NAME_PARTICLESYSTEM: string;
  75925. static readonly NAME_GAMEPAD: string;
  75926. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  75927. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  75928. static readonly NAME_DEPTHRENDERER: string;
  75929. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  75930. static readonly NAME_SPRITE: string;
  75931. static readonly NAME_OUTLINERENDERER: string;
  75932. static readonly NAME_PROCEDURALTEXTURE: string;
  75933. static readonly NAME_SHADOWGENERATOR: string;
  75934. static readonly NAME_OCTREE: string;
  75935. static readonly NAME_PHYSICSENGINE: string;
  75936. static readonly NAME_AUDIO: string;
  75937. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  75938. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75939. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  75940. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75941. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  75942. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  75943. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  75944. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  75945. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  75946. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  75947. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  75948. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  75949. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  75950. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  75951. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  75952. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  75953. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  75954. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  75955. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  75956. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  75957. static readonly STEP_AFTERRENDER_AUDIO: number;
  75958. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  75959. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  75960. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  75961. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  75962. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  75963. static readonly STEP_POINTERMOVE_SPRITE: number;
  75964. static readonly STEP_POINTERDOWN_SPRITE: number;
  75965. static readonly STEP_POINTERUP_SPRITE: number;
  75966. }
  75967. /**
  75968. * This represents a scene component.
  75969. *
  75970. * This is used to decouple the dependency the scene is having on the different workloads like
  75971. * layers, post processes...
  75972. */
  75973. export interface ISceneComponent {
  75974. /**
  75975. * The name of the component. Each component must have a unique name.
  75976. */
  75977. name: string;
  75978. /**
  75979. * The scene the component belongs to.
  75980. */
  75981. scene: Scene;
  75982. /**
  75983. * Register the component to one instance of a scene.
  75984. */
  75985. register(): void;
  75986. /**
  75987. * Rebuilds the elements related to this component in case of
  75988. * context lost for instance.
  75989. */
  75990. rebuild(): void;
  75991. /**
  75992. * Disposes the component and the associated ressources.
  75993. */
  75994. dispose(): void;
  75995. }
  75996. /**
  75997. * This represents a SERIALIZABLE scene component.
  75998. *
  75999. * This extends Scene Component to add Serialization methods on top.
  76000. */
  76001. export interface ISceneSerializableComponent extends ISceneComponent {
  76002. /**
  76003. * Adds all the elements from the container to the scene
  76004. * @param container the container holding the elements
  76005. */
  76006. addFromContainer(container: AbstractScene): void;
  76007. /**
  76008. * Removes all the elements in the container from the scene
  76009. * @param container contains the elements to remove
  76010. * @param dispose if the removed element should be disposed (default: false)
  76011. */
  76012. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76013. /**
  76014. * Serializes the component data to the specified json object
  76015. * @param serializationObject The object to serialize to
  76016. */
  76017. serialize(serializationObject: any): void;
  76018. }
  76019. /**
  76020. * Strong typing of a Mesh related stage step action
  76021. */
  76022. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76023. /**
  76024. * Strong typing of a Evaluate Sub Mesh related stage step action
  76025. */
  76026. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76027. /**
  76028. * Strong typing of a Active Mesh related stage step action
  76029. */
  76030. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76031. /**
  76032. * Strong typing of a Camera related stage step action
  76033. */
  76034. export type CameraStageAction = (camera: Camera) => void;
  76035. /**
  76036. * Strong typing of a Camera Frame buffer related stage step action
  76037. */
  76038. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76039. /**
  76040. * Strong typing of a Render Target related stage step action
  76041. */
  76042. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76043. /**
  76044. * Strong typing of a RenderingGroup related stage step action
  76045. */
  76046. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76047. /**
  76048. * Strong typing of a Mesh Render related stage step action
  76049. */
  76050. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76051. /**
  76052. * Strong typing of a simple stage step action
  76053. */
  76054. export type SimpleStageAction = () => void;
  76055. /**
  76056. * Strong typing of a render target action.
  76057. */
  76058. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76059. /**
  76060. * Strong typing of a pointer move action.
  76061. */
  76062. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76063. /**
  76064. * Strong typing of a pointer up/down action.
  76065. */
  76066. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76067. /**
  76068. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76069. * @hidden
  76070. */
  76071. export class Stage<T extends Function> extends Array<{
  76072. index: number;
  76073. component: ISceneComponent;
  76074. action: T;
  76075. }> {
  76076. /**
  76077. * Hide ctor from the rest of the world.
  76078. * @param items The items to add.
  76079. */
  76080. private constructor();
  76081. /**
  76082. * Creates a new Stage.
  76083. * @returns A new instance of a Stage
  76084. */
  76085. static Create<T extends Function>(): Stage<T>;
  76086. /**
  76087. * Registers a step in an ordered way in the targeted stage.
  76088. * @param index Defines the position to register the step in
  76089. * @param component Defines the component attached to the step
  76090. * @param action Defines the action to launch during the step
  76091. */
  76092. registerStep(index: number, component: ISceneComponent, action: T): void;
  76093. /**
  76094. * Clears all the steps from the stage.
  76095. */
  76096. clear(): void;
  76097. }
  76098. }
  76099. declare module BABYLON {
  76100. interface Scene {
  76101. /** @hidden */
  76102. _pointerOverSprite: Nullable<Sprite>;
  76103. /** @hidden */
  76104. _pickedDownSprite: Nullable<Sprite>;
  76105. /** @hidden */
  76106. _tempSpritePickingRay: Nullable<Ray>;
  76107. /**
  76108. * All of the sprite managers added to this scene
  76109. * @see http://doc.babylonjs.com/babylon101/sprites
  76110. */
  76111. spriteManagers: Array<ISpriteManager>;
  76112. /**
  76113. * An event triggered when sprites rendering is about to start
  76114. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76115. */
  76116. onBeforeSpritesRenderingObservable: Observable<Scene>;
  76117. /**
  76118. * An event triggered when sprites rendering is done
  76119. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76120. */
  76121. onAfterSpritesRenderingObservable: Observable<Scene>;
  76122. /** @hidden */
  76123. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76124. /** Launch a ray to try to pick a sprite in the scene
  76125. * @param x position on screen
  76126. * @param y position on screen
  76127. * @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
  76128. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76129. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76130. * @returns a PickingInfo
  76131. */
  76132. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76133. /** Use the given ray to pick a sprite in the scene
  76134. * @param ray The ray (in world space) to use to pick meshes
  76135. * @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
  76136. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76137. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76138. * @returns a PickingInfo
  76139. */
  76140. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76141. /** @hidden */
  76142. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76143. /** Launch a ray to try to pick sprites in the scene
  76144. * @param x position on screen
  76145. * @param y position on screen
  76146. * @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
  76147. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76148. * @returns a PickingInfo array
  76149. */
  76150. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76151. /** Use the given ray to pick sprites in the scene
  76152. * @param ray The ray (in world space) to use to pick meshes
  76153. * @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
  76154. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76155. * @returns a PickingInfo array
  76156. */
  76157. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76158. /**
  76159. * Force the sprite under the pointer
  76160. * @param sprite defines the sprite to use
  76161. */
  76162. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  76163. /**
  76164. * Gets the sprite under the pointer
  76165. * @returns a Sprite or null if no sprite is under the pointer
  76166. */
  76167. getPointerOverSprite(): Nullable<Sprite>;
  76168. }
  76169. /**
  76170. * Defines the sprite scene component responsible to manage sprites
  76171. * in a given scene.
  76172. */
  76173. export class SpriteSceneComponent implements ISceneComponent {
  76174. /**
  76175. * The component name helpfull to identify the component in the list of scene components.
  76176. */
  76177. readonly name: string;
  76178. /**
  76179. * The scene the component belongs to.
  76180. */
  76181. scene: Scene;
  76182. /** @hidden */
  76183. private _spritePredicate;
  76184. /**
  76185. * Creates a new instance of the component for the given scene
  76186. * @param scene Defines the scene to register the component in
  76187. */
  76188. constructor(scene: Scene);
  76189. /**
  76190. * Registers the component in a given scene
  76191. */
  76192. register(): void;
  76193. /**
  76194. * Rebuilds the elements related to this component in case of
  76195. * context lost for instance.
  76196. */
  76197. rebuild(): void;
  76198. /**
  76199. * Disposes the component and the associated ressources.
  76200. */
  76201. dispose(): void;
  76202. private _pickSpriteButKeepRay;
  76203. private _pointerMove;
  76204. private _pointerDown;
  76205. private _pointerUp;
  76206. }
  76207. }
  76208. declare module BABYLON {
  76209. /** @hidden */
  76210. export var fogFragmentDeclaration: {
  76211. name: string;
  76212. shader: string;
  76213. };
  76214. }
  76215. declare module BABYLON {
  76216. /** @hidden */
  76217. export var fogFragment: {
  76218. name: string;
  76219. shader: string;
  76220. };
  76221. }
  76222. declare module BABYLON {
  76223. /** @hidden */
  76224. export var spritesPixelShader: {
  76225. name: string;
  76226. shader: string;
  76227. };
  76228. }
  76229. declare module BABYLON {
  76230. /** @hidden */
  76231. export var fogVertexDeclaration: {
  76232. name: string;
  76233. shader: string;
  76234. };
  76235. }
  76236. declare module BABYLON {
  76237. /** @hidden */
  76238. export var spritesVertexShader: {
  76239. name: string;
  76240. shader: string;
  76241. };
  76242. }
  76243. declare module BABYLON {
  76244. /**
  76245. * Defines the minimum interface to fullfil in order to be a sprite manager.
  76246. */
  76247. export interface ISpriteManager extends IDisposable {
  76248. /**
  76249. * Restricts the camera to viewing objects with the same layerMask.
  76250. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  76251. */
  76252. layerMask: number;
  76253. /**
  76254. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  76255. */
  76256. isPickable: boolean;
  76257. /**
  76258. * Specifies the rendering group id for this mesh (0 by default)
  76259. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  76260. */
  76261. renderingGroupId: number;
  76262. /**
  76263. * Defines the list of sprites managed by the manager.
  76264. */
  76265. sprites: Array<Sprite>;
  76266. /**
  76267. * Tests the intersection of a sprite with a specific ray.
  76268. * @param ray The ray we are sending to test the collision
  76269. * @param camera The camera space we are sending rays in
  76270. * @param predicate A predicate allowing excluding sprites from the list of object to test
  76271. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  76272. * @returns picking info or null.
  76273. */
  76274. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76275. /**
  76276. * Intersects the sprites with a ray
  76277. * @param ray defines the ray to intersect with
  76278. * @param camera defines the current active camera
  76279. * @param predicate defines a predicate used to select candidate sprites
  76280. * @returns null if no hit or a PickingInfo array
  76281. */
  76282. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76283. /**
  76284. * Renders the list of sprites on screen.
  76285. */
  76286. render(): void;
  76287. }
  76288. /**
  76289. * Class used to manage multiple sprites on the same spritesheet
  76290. * @see http://doc.babylonjs.com/babylon101/sprites
  76291. */
  76292. export class SpriteManager implements ISpriteManager {
  76293. /** defines the manager's name */
  76294. name: string;
  76295. /** Gets the list of sprites */
  76296. sprites: Sprite[];
  76297. /** Gets or sets the rendering group id (0 by default) */
  76298. renderingGroupId: number;
  76299. /** Gets or sets camera layer mask */
  76300. layerMask: number;
  76301. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  76302. fogEnabled: boolean;
  76303. /** Gets or sets a boolean indicating if the sprites are pickable */
  76304. isPickable: boolean;
  76305. /** Defines the default width of a cell in the spritesheet */
  76306. cellWidth: number;
  76307. /** Defines the default height of a cell in the spritesheet */
  76308. cellHeight: number;
  76309. /** Associative array from JSON sprite data file */
  76310. private _cellData;
  76311. /** Array of sprite names from JSON sprite data file */
  76312. private _spriteMap;
  76313. /** True when packed cell data from JSON file is ready*/
  76314. private _packedAndReady;
  76315. /**
  76316. * An event triggered when the manager is disposed.
  76317. */
  76318. onDisposeObservable: Observable<SpriteManager>;
  76319. private _onDisposeObserver;
  76320. /**
  76321. * Callback called when the manager is disposed
  76322. */
  76323. onDispose: () => void;
  76324. private _capacity;
  76325. private _fromPacked;
  76326. private _spriteTexture;
  76327. private _epsilon;
  76328. private _scene;
  76329. private _vertexData;
  76330. private _buffer;
  76331. private _vertexBuffers;
  76332. private _indexBuffer;
  76333. private _effectBase;
  76334. private _effectFog;
  76335. /**
  76336. * Gets or sets the spritesheet texture
  76337. */
  76338. texture: Texture;
  76339. /**
  76340. * Creates a new sprite manager
  76341. * @param name defines the manager's name
  76342. * @param imgUrl defines the sprite sheet url
  76343. * @param capacity defines the maximum allowed number of sprites
  76344. * @param cellSize defines the size of a sprite cell
  76345. * @param scene defines the hosting scene
  76346. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76347. * @param samplingMode defines the smapling mode to use with spritesheet
  76348. * @param fromPacked set to false; do not alter
  76349. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  76350. */
  76351. constructor(
  76352. /** defines the manager's name */
  76353. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  76354. private _makePacked;
  76355. private _appendSpriteVertex;
  76356. /**
  76357. * Intersects the sprites with a ray
  76358. * @param ray defines the ray to intersect with
  76359. * @param camera defines the current active camera
  76360. * @param predicate defines a predicate used to select candidate sprites
  76361. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  76362. * @returns null if no hit or a PickingInfo
  76363. */
  76364. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76365. /**
  76366. * Intersects the sprites with a ray
  76367. * @param ray defines the ray to intersect with
  76368. * @param camera defines the current active camera
  76369. * @param predicate defines a predicate used to select candidate sprites
  76370. * @returns null if no hit or a PickingInfo array
  76371. */
  76372. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76373. /**
  76374. * Render all child sprites
  76375. */
  76376. render(): void;
  76377. /**
  76378. * Release associated resources
  76379. */
  76380. dispose(): void;
  76381. }
  76382. }
  76383. declare module BABYLON {
  76384. /**
  76385. * Class used to represent a sprite
  76386. * @see http://doc.babylonjs.com/babylon101/sprites
  76387. */
  76388. export class Sprite {
  76389. /** defines the name */
  76390. name: string;
  76391. /** Gets or sets the current world position */
  76392. position: Vector3;
  76393. /** Gets or sets the main color */
  76394. color: Color4;
  76395. /** Gets or sets the width */
  76396. width: number;
  76397. /** Gets or sets the height */
  76398. height: number;
  76399. /** Gets or sets rotation angle */
  76400. angle: number;
  76401. /** Gets or sets the cell index in the sprite sheet */
  76402. cellIndex: number;
  76403. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  76404. cellRef: string;
  76405. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76406. invertU: number;
  76407. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76408. invertV: number;
  76409. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  76410. disposeWhenFinishedAnimating: boolean;
  76411. /** Gets the list of attached animations */
  76412. animations: Animation[];
  76413. /** Gets or sets a boolean indicating if the sprite can be picked */
  76414. isPickable: boolean;
  76415. /**
  76416. * Gets or sets the associated action manager
  76417. */
  76418. actionManager: Nullable<ActionManager>;
  76419. private _animationStarted;
  76420. private _loopAnimation;
  76421. private _fromIndex;
  76422. private _toIndex;
  76423. private _delay;
  76424. private _direction;
  76425. private _manager;
  76426. private _time;
  76427. private _onAnimationEnd;
  76428. /**
  76429. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  76430. */
  76431. isVisible: boolean;
  76432. /**
  76433. * Gets or sets the sprite size
  76434. */
  76435. size: number;
  76436. /**
  76437. * Creates a new Sprite
  76438. * @param name defines the name
  76439. * @param manager defines the manager
  76440. */
  76441. constructor(
  76442. /** defines the name */
  76443. name: string, manager: ISpriteManager);
  76444. /**
  76445. * Starts an animation
  76446. * @param from defines the initial key
  76447. * @param to defines the end key
  76448. * @param loop defines if the animation must loop
  76449. * @param delay defines the start delay (in ms)
  76450. * @param onAnimationEnd defines a callback to call when animation ends
  76451. */
  76452. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  76453. /** Stops current animation (if any) */
  76454. stopAnimation(): void;
  76455. /** @hidden */
  76456. _animate(deltaTime: number): void;
  76457. /** Release associated resources */
  76458. dispose(): void;
  76459. }
  76460. }
  76461. declare module BABYLON {
  76462. /**
  76463. * Information about the result of picking within a scene
  76464. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  76465. */
  76466. export class PickingInfo {
  76467. /** @hidden */
  76468. _pickingUnavailable: boolean;
  76469. /**
  76470. * If the pick collided with an object
  76471. */
  76472. hit: boolean;
  76473. /**
  76474. * Distance away where the pick collided
  76475. */
  76476. distance: number;
  76477. /**
  76478. * The location of pick collision
  76479. */
  76480. pickedPoint: Nullable<Vector3>;
  76481. /**
  76482. * The mesh corresponding the the pick collision
  76483. */
  76484. pickedMesh: Nullable<AbstractMesh>;
  76485. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  76486. bu: number;
  76487. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  76488. bv: number;
  76489. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  76490. faceId: number;
  76491. /** Id of the the submesh that was picked */
  76492. subMeshId: number;
  76493. /** If a sprite was picked, this will be the sprite the pick collided with */
  76494. pickedSprite: Nullable<Sprite>;
  76495. /**
  76496. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  76497. */
  76498. originMesh: Nullable<AbstractMesh>;
  76499. /**
  76500. * The ray that was used to perform the picking.
  76501. */
  76502. ray: Nullable<Ray>;
  76503. /**
  76504. * Gets the normal correspodning to the face the pick collided with
  76505. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  76506. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  76507. * @returns The normal correspodning to the face the pick collided with
  76508. */
  76509. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  76510. /**
  76511. * Gets the texture coordinates of where the pick occured
  76512. * @returns the vector containing the coordnates of the texture
  76513. */
  76514. getTextureCoordinates(): Nullable<Vector2>;
  76515. }
  76516. }
  76517. declare module BABYLON {
  76518. /**
  76519. * Gather the list of pointer event types as constants.
  76520. */
  76521. export class PointerEventTypes {
  76522. /**
  76523. * 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.
  76524. */
  76525. static readonly POINTERDOWN: number;
  76526. /**
  76527. * The pointerup event is fired when a pointer is no longer active.
  76528. */
  76529. static readonly POINTERUP: number;
  76530. /**
  76531. * The pointermove event is fired when a pointer changes coordinates.
  76532. */
  76533. static readonly POINTERMOVE: number;
  76534. /**
  76535. * The pointerwheel event is fired when a mouse wheel has been rotated.
  76536. */
  76537. static readonly POINTERWHEEL: number;
  76538. /**
  76539. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  76540. */
  76541. static readonly POINTERPICK: number;
  76542. /**
  76543. * The pointertap event is fired when a the object has been touched and released without drag.
  76544. */
  76545. static readonly POINTERTAP: number;
  76546. /**
  76547. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  76548. */
  76549. static readonly POINTERDOUBLETAP: number;
  76550. }
  76551. /**
  76552. * Base class of pointer info types.
  76553. */
  76554. export class PointerInfoBase {
  76555. /**
  76556. * Defines the type of event (PointerEventTypes)
  76557. */
  76558. type: number;
  76559. /**
  76560. * Defines the related dom event
  76561. */
  76562. event: PointerEvent | MouseWheelEvent;
  76563. /**
  76564. * Instantiates the base class of pointers info.
  76565. * @param type Defines the type of event (PointerEventTypes)
  76566. * @param event Defines the related dom event
  76567. */
  76568. constructor(
  76569. /**
  76570. * Defines the type of event (PointerEventTypes)
  76571. */
  76572. type: number,
  76573. /**
  76574. * Defines the related dom event
  76575. */
  76576. event: PointerEvent | MouseWheelEvent);
  76577. }
  76578. /**
  76579. * This class is used to store pointer related info for the onPrePointerObservable event.
  76580. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  76581. */
  76582. export class PointerInfoPre extends PointerInfoBase {
  76583. /**
  76584. * Ray from a pointer if availible (eg. 6dof controller)
  76585. */
  76586. ray: Nullable<Ray>;
  76587. /**
  76588. * Defines the local position of the pointer on the canvas.
  76589. */
  76590. localPosition: Vector2;
  76591. /**
  76592. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  76593. */
  76594. skipOnPointerObservable: boolean;
  76595. /**
  76596. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  76597. * @param type Defines the type of event (PointerEventTypes)
  76598. * @param event Defines the related dom event
  76599. * @param localX Defines the local x coordinates of the pointer when the event occured
  76600. * @param localY Defines the local y coordinates of the pointer when the event occured
  76601. */
  76602. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  76603. }
  76604. /**
  76605. * This type contains all the data related to a pointer event in Babylon.js.
  76606. * 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.
  76607. */
  76608. export class PointerInfo extends PointerInfoBase {
  76609. /**
  76610. * Defines the picking info associated to the info (if any)\
  76611. */
  76612. pickInfo: Nullable<PickingInfo>;
  76613. /**
  76614. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  76615. * @param type Defines the type of event (PointerEventTypes)
  76616. * @param event Defines the related dom event
  76617. * @param pickInfo Defines the picking info associated to the info (if any)\
  76618. */
  76619. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  76620. /**
  76621. * Defines the picking info associated to the info (if any)\
  76622. */
  76623. pickInfo: Nullable<PickingInfo>);
  76624. }
  76625. /**
  76626. * Data relating to a touch event on the screen.
  76627. */
  76628. export interface PointerTouch {
  76629. /**
  76630. * X coordinate of touch.
  76631. */
  76632. x: number;
  76633. /**
  76634. * Y coordinate of touch.
  76635. */
  76636. y: number;
  76637. /**
  76638. * Id of touch. Unique for each finger.
  76639. */
  76640. pointerId: number;
  76641. /**
  76642. * Event type passed from DOM.
  76643. */
  76644. type: any;
  76645. }
  76646. }
  76647. declare module BABYLON {
  76648. /**
  76649. * Manage the mouse inputs to control the movement of a free camera.
  76650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76651. */
  76652. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  76653. /**
  76654. * Define if touch is enabled in the mouse input
  76655. */
  76656. touchEnabled: boolean;
  76657. /**
  76658. * Defines the camera the input is attached to.
  76659. */
  76660. camera: FreeCamera;
  76661. /**
  76662. * Defines the buttons associated with the input to handle camera move.
  76663. */
  76664. buttons: number[];
  76665. /**
  76666. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  76667. */
  76668. angularSensibility: number;
  76669. private _pointerInput;
  76670. private _onMouseMove;
  76671. private _observer;
  76672. private previousPosition;
  76673. /**
  76674. * Observable for when a pointer move event occurs containing the move offset
  76675. */
  76676. onPointerMovedObservable: Observable<{
  76677. offsetX: number;
  76678. offsetY: number;
  76679. }>;
  76680. /**
  76681. * @hidden
  76682. * If the camera should be rotated automatically based on pointer movement
  76683. */
  76684. _allowCameraRotation: boolean;
  76685. /**
  76686. * Manage the mouse inputs to control the movement of a free camera.
  76687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76688. * @param touchEnabled Defines if touch is enabled or not
  76689. */
  76690. constructor(
  76691. /**
  76692. * Define if touch is enabled in the mouse input
  76693. */
  76694. touchEnabled?: boolean);
  76695. /**
  76696. * Attach the input controls to a specific dom element to get the input from.
  76697. * @param element Defines the element the controls should be listened from
  76698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76699. */
  76700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76701. /**
  76702. * Called on JS contextmenu event.
  76703. * Override this method to provide functionality.
  76704. */
  76705. protected onContextMenu(evt: PointerEvent): void;
  76706. /**
  76707. * Detach the current controls from the specified dom element.
  76708. * @param element Defines the element to stop listening the inputs from
  76709. */
  76710. detachControl(element: Nullable<HTMLElement>): void;
  76711. /**
  76712. * Gets the class name of the current intput.
  76713. * @returns the class name
  76714. */
  76715. getClassName(): string;
  76716. /**
  76717. * Get the friendly name associated with the input class.
  76718. * @returns the input friendly name
  76719. */
  76720. getSimpleName(): string;
  76721. }
  76722. }
  76723. declare module BABYLON {
  76724. /**
  76725. * Manage the touch inputs to control the movement of a free camera.
  76726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76727. */
  76728. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  76729. /**
  76730. * Defines the camera the input is attached to.
  76731. */
  76732. camera: FreeCamera;
  76733. /**
  76734. * Defines the touch sensibility for rotation.
  76735. * The higher the faster.
  76736. */
  76737. touchAngularSensibility: number;
  76738. /**
  76739. * Defines the touch sensibility for move.
  76740. * The higher the faster.
  76741. */
  76742. touchMoveSensibility: number;
  76743. private _offsetX;
  76744. private _offsetY;
  76745. private _pointerPressed;
  76746. private _pointerInput;
  76747. private _observer;
  76748. private _onLostFocus;
  76749. /**
  76750. * Attach the input controls to a specific dom element to get the input from.
  76751. * @param element Defines the element the controls should be listened from
  76752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76753. */
  76754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76755. /**
  76756. * Detach the current controls from the specified dom element.
  76757. * @param element Defines the element to stop listening the inputs from
  76758. */
  76759. detachControl(element: Nullable<HTMLElement>): void;
  76760. /**
  76761. * Update the current camera state depending on the inputs that have been used this frame.
  76762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76763. */
  76764. checkInputs(): void;
  76765. /**
  76766. * Gets the class name of the current intput.
  76767. * @returns the class name
  76768. */
  76769. getClassName(): string;
  76770. /**
  76771. * Get the friendly name associated with the input class.
  76772. * @returns the input friendly name
  76773. */
  76774. getSimpleName(): string;
  76775. }
  76776. }
  76777. declare module BABYLON {
  76778. /**
  76779. * Default Inputs manager for the FreeCamera.
  76780. * It groups all the default supported inputs for ease of use.
  76781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76782. */
  76783. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76784. /**
  76785. * @hidden
  76786. */
  76787. _mouseInput: Nullable<FreeCameraMouseInput>;
  76788. /**
  76789. * Instantiates a new FreeCameraInputsManager.
  76790. * @param camera Defines the camera the inputs belong to
  76791. */
  76792. constructor(camera: FreeCamera);
  76793. /**
  76794. * Add keyboard input support to the input manager.
  76795. * @returns the current input manager
  76796. */
  76797. addKeyboard(): FreeCameraInputsManager;
  76798. /**
  76799. * Add mouse input support to the input manager.
  76800. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76801. * @returns the current input manager
  76802. */
  76803. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76804. /**
  76805. * Removes the mouse input support from the manager
  76806. * @returns the current input manager
  76807. */
  76808. removeMouse(): FreeCameraInputsManager;
  76809. /**
  76810. * Add touch input support to the input manager.
  76811. * @returns the current input manager
  76812. */
  76813. addTouch(): FreeCameraInputsManager;
  76814. /**
  76815. * Remove all attached input methods from a camera
  76816. */
  76817. clear(): void;
  76818. }
  76819. }
  76820. declare module BABYLON {
  76821. /**
  76822. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76823. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76824. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76825. */
  76826. export class FreeCamera extends TargetCamera {
  76827. /**
  76828. * Define the collision ellipsoid of the camera.
  76829. * This is helpful to simulate a camera body like the player body around the camera
  76830. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76831. */
  76832. ellipsoid: Vector3;
  76833. /**
  76834. * Define an offset for the position of the ellipsoid around the camera.
  76835. * This can be helpful to determine the center of the body near the gravity center of the body
  76836. * instead of its head.
  76837. */
  76838. ellipsoidOffset: Vector3;
  76839. /**
  76840. * Enable or disable collisions of the camera with the rest of the scene objects.
  76841. */
  76842. checkCollisions: boolean;
  76843. /**
  76844. * Enable or disable gravity on the camera.
  76845. */
  76846. applyGravity: boolean;
  76847. /**
  76848. * Define the input manager associated to the camera.
  76849. */
  76850. inputs: FreeCameraInputsManager;
  76851. /**
  76852. * Gets the input sensibility for a mouse input. (default is 2000.0)
  76853. * Higher values reduce sensitivity.
  76854. */
  76855. /**
  76856. * Sets the input sensibility for a mouse input. (default is 2000.0)
  76857. * Higher values reduce sensitivity.
  76858. */
  76859. angularSensibility: number;
  76860. /**
  76861. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76862. */
  76863. keysUp: number[];
  76864. /**
  76865. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76866. */
  76867. keysDown: number[];
  76868. /**
  76869. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76870. */
  76871. keysLeft: number[];
  76872. /**
  76873. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76874. */
  76875. keysRight: number[];
  76876. /**
  76877. * Event raised when the camera collide with a mesh in the scene.
  76878. */
  76879. onCollide: (collidedMesh: AbstractMesh) => void;
  76880. private _collider;
  76881. private _needMoveForGravity;
  76882. private _oldPosition;
  76883. private _diffPosition;
  76884. private _newPosition;
  76885. /** @hidden */
  76886. _localDirection: Vector3;
  76887. /** @hidden */
  76888. _transformedDirection: Vector3;
  76889. /**
  76890. * Instantiates a Free Camera.
  76891. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76892. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  76893. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76894. * @param name Define the name of the camera in the scene
  76895. * @param position Define the start position of the camera in the scene
  76896. * @param scene Define the scene the camera belongs to
  76897. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76898. */
  76899. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76900. /**
  76901. * Attached controls to the current camera.
  76902. * @param element Defines the element the controls should be listened from
  76903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76904. */
  76905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76906. /**
  76907. * Detach the current controls from the camera.
  76908. * The camera will stop reacting to inputs.
  76909. * @param element Defines the element to stop listening the inputs from
  76910. */
  76911. detachControl(element: HTMLElement): void;
  76912. private _collisionMask;
  76913. /**
  76914. * Define a collision mask to limit the list of object the camera can collide with
  76915. */
  76916. collisionMask: number;
  76917. /** @hidden */
  76918. _collideWithWorld(displacement: Vector3): void;
  76919. private _onCollisionPositionChange;
  76920. /** @hidden */
  76921. _checkInputs(): void;
  76922. /** @hidden */
  76923. _decideIfNeedsToMove(): boolean;
  76924. /** @hidden */
  76925. _updatePosition(): void;
  76926. /**
  76927. * Destroy the camera and release the current resources hold by it.
  76928. */
  76929. dispose(): void;
  76930. /**
  76931. * Gets the current object class name.
  76932. * @return the class name
  76933. */
  76934. getClassName(): string;
  76935. }
  76936. }
  76937. declare module BABYLON {
  76938. /**
  76939. * Represents a gamepad control stick position
  76940. */
  76941. export class StickValues {
  76942. /**
  76943. * The x component of the control stick
  76944. */
  76945. x: number;
  76946. /**
  76947. * The y component of the control stick
  76948. */
  76949. y: number;
  76950. /**
  76951. * Initializes the gamepad x and y control stick values
  76952. * @param x The x component of the gamepad control stick value
  76953. * @param y The y component of the gamepad control stick value
  76954. */
  76955. constructor(
  76956. /**
  76957. * The x component of the control stick
  76958. */
  76959. x: number,
  76960. /**
  76961. * The y component of the control stick
  76962. */
  76963. y: number);
  76964. }
  76965. /**
  76966. * An interface which manages callbacks for gamepad button changes
  76967. */
  76968. export interface GamepadButtonChanges {
  76969. /**
  76970. * Called when a gamepad has been changed
  76971. */
  76972. changed: boolean;
  76973. /**
  76974. * Called when a gamepad press event has been triggered
  76975. */
  76976. pressChanged: boolean;
  76977. /**
  76978. * Called when a touch event has been triggered
  76979. */
  76980. touchChanged: boolean;
  76981. /**
  76982. * Called when a value has changed
  76983. */
  76984. valueChanged: boolean;
  76985. }
  76986. /**
  76987. * Represents a gamepad
  76988. */
  76989. export class Gamepad {
  76990. /**
  76991. * The id of the gamepad
  76992. */
  76993. id: string;
  76994. /**
  76995. * The index of the gamepad
  76996. */
  76997. index: number;
  76998. /**
  76999. * The browser gamepad
  77000. */
  77001. browserGamepad: any;
  77002. /**
  77003. * Specifies what type of gamepad this represents
  77004. */
  77005. type: number;
  77006. private _leftStick;
  77007. private _rightStick;
  77008. /** @hidden */
  77009. _isConnected: boolean;
  77010. private _leftStickAxisX;
  77011. private _leftStickAxisY;
  77012. private _rightStickAxisX;
  77013. private _rightStickAxisY;
  77014. /**
  77015. * Triggered when the left control stick has been changed
  77016. */
  77017. private _onleftstickchanged;
  77018. /**
  77019. * Triggered when the right control stick has been changed
  77020. */
  77021. private _onrightstickchanged;
  77022. /**
  77023. * Represents a gamepad controller
  77024. */
  77025. static GAMEPAD: number;
  77026. /**
  77027. * Represents a generic controller
  77028. */
  77029. static GENERIC: number;
  77030. /**
  77031. * Represents an XBox controller
  77032. */
  77033. static XBOX: number;
  77034. /**
  77035. * Represents a pose-enabled controller
  77036. */
  77037. static POSE_ENABLED: number;
  77038. /**
  77039. * Represents an Dual Shock controller
  77040. */
  77041. static DUALSHOCK: number;
  77042. /**
  77043. * Specifies whether the left control stick should be Y-inverted
  77044. */
  77045. protected _invertLeftStickY: boolean;
  77046. /**
  77047. * Specifies if the gamepad has been connected
  77048. */
  77049. readonly isConnected: boolean;
  77050. /**
  77051. * Initializes the gamepad
  77052. * @param id The id of the gamepad
  77053. * @param index The index of the gamepad
  77054. * @param browserGamepad The browser gamepad
  77055. * @param leftStickX The x component of the left joystick
  77056. * @param leftStickY The y component of the left joystick
  77057. * @param rightStickX The x component of the right joystick
  77058. * @param rightStickY The y component of the right joystick
  77059. */
  77060. constructor(
  77061. /**
  77062. * The id of the gamepad
  77063. */
  77064. id: string,
  77065. /**
  77066. * The index of the gamepad
  77067. */
  77068. index: number,
  77069. /**
  77070. * The browser gamepad
  77071. */
  77072. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77073. /**
  77074. * Callback triggered when the left joystick has changed
  77075. * @param callback
  77076. */
  77077. onleftstickchanged(callback: (values: StickValues) => void): void;
  77078. /**
  77079. * Callback triggered when the right joystick has changed
  77080. * @param callback
  77081. */
  77082. onrightstickchanged(callback: (values: StickValues) => void): void;
  77083. /**
  77084. * Gets the left joystick
  77085. */
  77086. /**
  77087. * Sets the left joystick values
  77088. */
  77089. leftStick: StickValues;
  77090. /**
  77091. * Gets the right joystick
  77092. */
  77093. /**
  77094. * Sets the right joystick value
  77095. */
  77096. rightStick: StickValues;
  77097. /**
  77098. * Updates the gamepad joystick positions
  77099. */
  77100. update(): void;
  77101. /**
  77102. * Disposes the gamepad
  77103. */
  77104. dispose(): void;
  77105. }
  77106. /**
  77107. * Represents a generic gamepad
  77108. */
  77109. export class GenericPad extends Gamepad {
  77110. private _buttons;
  77111. private _onbuttondown;
  77112. private _onbuttonup;
  77113. /**
  77114. * Observable triggered when a button has been pressed
  77115. */
  77116. onButtonDownObservable: Observable<number>;
  77117. /**
  77118. * Observable triggered when a button has been released
  77119. */
  77120. onButtonUpObservable: Observable<number>;
  77121. /**
  77122. * Callback triggered when a button has been pressed
  77123. * @param callback Called when a button has been pressed
  77124. */
  77125. onbuttondown(callback: (buttonPressed: number) => void): void;
  77126. /**
  77127. * Callback triggered when a button has been released
  77128. * @param callback Called when a button has been released
  77129. */
  77130. onbuttonup(callback: (buttonReleased: number) => void): void;
  77131. /**
  77132. * Initializes the generic gamepad
  77133. * @param id The id of the generic gamepad
  77134. * @param index The index of the generic gamepad
  77135. * @param browserGamepad The browser gamepad
  77136. */
  77137. constructor(id: string, index: number, browserGamepad: any);
  77138. private _setButtonValue;
  77139. /**
  77140. * Updates the generic gamepad
  77141. */
  77142. update(): void;
  77143. /**
  77144. * Disposes the generic gamepad
  77145. */
  77146. dispose(): void;
  77147. }
  77148. }
  77149. declare module BABYLON {
  77150. interface Engine {
  77151. /**
  77152. * Creates a raw texture
  77153. * @param data defines the data to store in the texture
  77154. * @param width defines the width of the texture
  77155. * @param height defines the height of the texture
  77156. * @param format defines the format of the data
  77157. * @param generateMipMaps defines if the engine should generate the mip levels
  77158. * @param invertY defines if data must be stored with Y axis inverted
  77159. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77160. * @param compression defines the compression used (null by default)
  77161. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77162. * @returns the raw texture inside an InternalTexture
  77163. */
  77164. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77165. /**
  77166. * Update a raw texture
  77167. * @param texture defines the texture to update
  77168. * @param data defines the data to store in the texture
  77169. * @param format defines the format of the data
  77170. * @param invertY defines if data must be stored with Y axis inverted
  77171. */
  77172. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77173. /**
  77174. * Update a raw texture
  77175. * @param texture defines the texture to update
  77176. * @param data defines the data to store in the texture
  77177. * @param format defines the format of the data
  77178. * @param invertY defines if data must be stored with Y axis inverted
  77179. * @param compression defines the compression used (null by default)
  77180. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77181. */
  77182. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77183. /**
  77184. * Creates a new raw cube texture
  77185. * @param data defines the array of data to use to create each face
  77186. * @param size defines the size of the textures
  77187. * @param format defines the format of the data
  77188. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77189. * @param generateMipMaps defines if the engine should generate the mip levels
  77190. * @param invertY defines if data must be stored with Y axis inverted
  77191. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77192. * @param compression defines the compression used (null by default)
  77193. * @returns the cube texture as an InternalTexture
  77194. */
  77195. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77196. /**
  77197. * Update a raw cube texture
  77198. * @param texture defines the texture to udpdate
  77199. * @param data defines the data to store
  77200. * @param format defines the data format
  77201. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77202. * @param invertY defines if data must be stored with Y axis inverted
  77203. */
  77204. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  77205. /**
  77206. * Update a raw cube texture
  77207. * @param texture defines the texture to udpdate
  77208. * @param data defines the data to store
  77209. * @param format defines the data format
  77210. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77211. * @param invertY defines if data must be stored with Y axis inverted
  77212. * @param compression defines the compression used (null by default)
  77213. */
  77214. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  77215. /**
  77216. * Update a raw cube texture
  77217. * @param texture defines the texture to udpdate
  77218. * @param data defines the data to store
  77219. * @param format defines the data format
  77220. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77221. * @param invertY defines if data must be stored with Y axis inverted
  77222. * @param compression defines the compression used (null by default)
  77223. * @param level defines which level of the texture to update
  77224. */
  77225. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  77226. /**
  77227. * Creates a new raw cube texture from a specified url
  77228. * @param url defines the url where the data is located
  77229. * @param scene defines the current scene
  77230. * @param size defines the size of the textures
  77231. * @param format defines the format of the data
  77232. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77233. * @param noMipmap defines if the engine should avoid generating the mip levels
  77234. * @param callback defines a callback used to extract texture data from loaded data
  77235. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77236. * @param onLoad defines a callback called when texture is loaded
  77237. * @param onError defines a callback called if there is an error
  77238. * @returns the cube texture as an InternalTexture
  77239. */
  77240. 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;
  77241. /**
  77242. * Creates a new raw cube texture from a specified url
  77243. * @param url defines the url where the data is located
  77244. * @param scene defines the current scene
  77245. * @param size defines the size of the textures
  77246. * @param format defines the format of the data
  77247. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77248. * @param noMipmap defines if the engine should avoid generating the mip levels
  77249. * @param callback defines a callback used to extract texture data from loaded data
  77250. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77251. * @param onLoad defines a callback called when texture is loaded
  77252. * @param onError defines a callback called if there is an error
  77253. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77254. * @param invertY defines if data must be stored with Y axis inverted
  77255. * @returns the cube texture as an InternalTexture
  77256. */
  77257. 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;
  77258. /**
  77259. * Creates a new raw 3D texture
  77260. * @param data defines the data used to create the texture
  77261. * @param width defines the width of the texture
  77262. * @param height defines the height of the texture
  77263. * @param depth defines the depth of the texture
  77264. * @param format defines the format of the texture
  77265. * @param generateMipMaps defines if the engine must generate mip levels
  77266. * @param invertY defines if data must be stored with Y axis inverted
  77267. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77268. * @param compression defines the compressed used (can be null)
  77269. * @param textureType defines the compressed used (can be null)
  77270. * @returns a new raw 3D texture (stored in an InternalTexture)
  77271. */
  77272. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  77273. /**
  77274. * Update a raw 3D texture
  77275. * @param texture defines the texture to update
  77276. * @param data defines the data to store
  77277. * @param format defines the data format
  77278. * @param invertY defines if data must be stored with Y axis inverted
  77279. */
  77280. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77281. /**
  77282. * Update a raw 3D texture
  77283. * @param texture defines the texture to update
  77284. * @param data defines the data to store
  77285. * @param format defines the data format
  77286. * @param invertY defines if data must be stored with Y axis inverted
  77287. * @param compression defines the used compression (can be null)
  77288. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  77289. */
  77290. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  77291. }
  77292. }
  77293. declare module BABYLON {
  77294. /**
  77295. * Raw texture can help creating a texture directly from an array of data.
  77296. * This can be super useful if you either get the data from an uncompressed source or
  77297. * if you wish to create your texture pixel by pixel.
  77298. */
  77299. export class RawTexture extends Texture {
  77300. /**
  77301. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77302. */
  77303. format: number;
  77304. private _engine;
  77305. /**
  77306. * Instantiates a new RawTexture.
  77307. * Raw texture can help creating a texture directly from an array of data.
  77308. * This can be super useful if you either get the data from an uncompressed source or
  77309. * if you wish to create your texture pixel by pixel.
  77310. * @param data define the array of data to use to create the texture
  77311. * @param width define the width of the texture
  77312. * @param height define the height of the texture
  77313. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77314. * @param scene define the scene the texture belongs to
  77315. * @param generateMipMaps define whether mip maps should be generated or not
  77316. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77317. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77318. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77319. */
  77320. constructor(data: ArrayBufferView, width: number, height: number,
  77321. /**
  77322. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77323. */
  77324. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77325. /**
  77326. * Updates the texture underlying data.
  77327. * @param data Define the new data of the texture
  77328. */
  77329. update(data: ArrayBufferView): void;
  77330. /**
  77331. * Creates a luminance texture from some data.
  77332. * @param data Define the texture data
  77333. * @param width Define the width of the texture
  77334. * @param height Define the height of the texture
  77335. * @param scene Define the scene the texture belongs to
  77336. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77337. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77338. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77339. * @returns the luminance texture
  77340. */
  77341. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77342. /**
  77343. * Creates a luminance alpha texture from some data.
  77344. * @param data Define the texture data
  77345. * @param width Define the width of the texture
  77346. * @param height Define the height of the texture
  77347. * @param scene Define the scene the texture belongs to
  77348. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77349. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77350. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77351. * @returns the luminance alpha texture
  77352. */
  77353. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77354. /**
  77355. * Creates an alpha texture from some data.
  77356. * @param data Define the texture data
  77357. * @param width Define the width of the texture
  77358. * @param height Define the height of the texture
  77359. * @param scene Define the scene the texture belongs to
  77360. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77361. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77362. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77363. * @returns the alpha texture
  77364. */
  77365. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77366. /**
  77367. * Creates a RGB texture from some data.
  77368. * @param data Define the texture data
  77369. * @param width Define the width of the texture
  77370. * @param height Define the height of the texture
  77371. * @param scene Define the scene the texture belongs to
  77372. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77373. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77374. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77375. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77376. * @returns the RGB alpha texture
  77377. */
  77378. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77379. /**
  77380. * Creates a RGBA texture from some data.
  77381. * @param data Define the texture data
  77382. * @param width Define the width of the texture
  77383. * @param height Define the height of the texture
  77384. * @param scene Define the scene the texture belongs to
  77385. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77386. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77387. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77388. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77389. * @returns the RGBA texture
  77390. */
  77391. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77392. /**
  77393. * Creates a R texture from some data.
  77394. * @param data Define the texture data
  77395. * @param width Define the width of the texture
  77396. * @param height Define the height of the texture
  77397. * @param scene Define the scene the texture belongs to
  77398. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77399. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77400. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77401. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77402. * @returns the R texture
  77403. */
  77404. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77405. }
  77406. }
  77407. declare module BABYLON {
  77408. /**
  77409. * Interface for the size containing width and height
  77410. */
  77411. export interface ISize {
  77412. /**
  77413. * Width
  77414. */
  77415. width: number;
  77416. /**
  77417. * Heighht
  77418. */
  77419. height: number;
  77420. }
  77421. /**
  77422. * Size containing widht and height
  77423. */
  77424. export class Size implements ISize {
  77425. /**
  77426. * Width
  77427. */
  77428. width: number;
  77429. /**
  77430. * Height
  77431. */
  77432. height: number;
  77433. /**
  77434. * Creates a Size object from the given width and height (floats).
  77435. * @param width width of the new size
  77436. * @param height height of the new size
  77437. */
  77438. constructor(width: number, height: number);
  77439. /**
  77440. * Returns a string with the Size width and height
  77441. * @returns a string with the Size width and height
  77442. */
  77443. toString(): string;
  77444. /**
  77445. * "Size"
  77446. * @returns the string "Size"
  77447. */
  77448. getClassName(): string;
  77449. /**
  77450. * Returns the Size hash code.
  77451. * @returns a hash code for a unique width and height
  77452. */
  77453. getHashCode(): number;
  77454. /**
  77455. * Updates the current size from the given one.
  77456. * @param src the given size
  77457. */
  77458. copyFrom(src: Size): void;
  77459. /**
  77460. * Updates in place the current Size from the given floats.
  77461. * @param width width of the new size
  77462. * @param height height of the new size
  77463. * @returns the updated Size.
  77464. */
  77465. copyFromFloats(width: number, height: number): Size;
  77466. /**
  77467. * Updates in place the current Size from the given floats.
  77468. * @param width width to set
  77469. * @param height height to set
  77470. * @returns the updated Size.
  77471. */
  77472. set(width: number, height: number): Size;
  77473. /**
  77474. * Multiplies the width and height by numbers
  77475. * @param w factor to multiple the width by
  77476. * @param h factor to multiple the height by
  77477. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  77478. */
  77479. multiplyByFloats(w: number, h: number): Size;
  77480. /**
  77481. * Clones the size
  77482. * @returns a new Size copied from the given one.
  77483. */
  77484. clone(): Size;
  77485. /**
  77486. * True if the current Size and the given one width and height are strictly equal.
  77487. * @param other the other size to compare against
  77488. * @returns True if the current Size and the given one width and height are strictly equal.
  77489. */
  77490. equals(other: Size): boolean;
  77491. /**
  77492. * The surface of the Size : width * height (float).
  77493. */
  77494. readonly surface: number;
  77495. /**
  77496. * Create a new size of zero
  77497. * @returns a new Size set to (0.0, 0.0)
  77498. */
  77499. static Zero(): Size;
  77500. /**
  77501. * Sums the width and height of two sizes
  77502. * @param otherSize size to add to this size
  77503. * @returns a new Size set as the addition result of the current Size and the given one.
  77504. */
  77505. add(otherSize: Size): Size;
  77506. /**
  77507. * Subtracts the width and height of two
  77508. * @param otherSize size to subtract to this size
  77509. * @returns a new Size set as the subtraction result of the given one from the current Size.
  77510. */
  77511. subtract(otherSize: Size): Size;
  77512. /**
  77513. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  77514. * @param start starting size to lerp between
  77515. * @param end end size to lerp between
  77516. * @param amount amount to lerp between the start and end values
  77517. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  77518. */
  77519. static Lerp(start: Size, end: Size, amount: number): Size;
  77520. }
  77521. }
  77522. declare module BABYLON {
  77523. /**
  77524. * Defines a runtime animation
  77525. */
  77526. export class RuntimeAnimation {
  77527. private _events;
  77528. /**
  77529. * The current frame of the runtime animation
  77530. */
  77531. private _currentFrame;
  77532. /**
  77533. * The animation used by the runtime animation
  77534. */
  77535. private _animation;
  77536. /**
  77537. * The target of the runtime animation
  77538. */
  77539. private _target;
  77540. /**
  77541. * The initiating animatable
  77542. */
  77543. private _host;
  77544. /**
  77545. * The original value of the runtime animation
  77546. */
  77547. private _originalValue;
  77548. /**
  77549. * The original blend value of the runtime animation
  77550. */
  77551. private _originalBlendValue;
  77552. /**
  77553. * The offsets cache of the runtime animation
  77554. */
  77555. private _offsetsCache;
  77556. /**
  77557. * The high limits cache of the runtime animation
  77558. */
  77559. private _highLimitsCache;
  77560. /**
  77561. * Specifies if the runtime animation has been stopped
  77562. */
  77563. private _stopped;
  77564. /**
  77565. * The blending factor of the runtime animation
  77566. */
  77567. private _blendingFactor;
  77568. /**
  77569. * The BabylonJS scene
  77570. */
  77571. private _scene;
  77572. /**
  77573. * The current value of the runtime animation
  77574. */
  77575. private _currentValue;
  77576. /** @hidden */
  77577. _animationState: _IAnimationState;
  77578. /**
  77579. * The active target of the runtime animation
  77580. */
  77581. private _activeTargets;
  77582. private _currentActiveTarget;
  77583. private _directTarget;
  77584. /**
  77585. * The target path of the runtime animation
  77586. */
  77587. private _targetPath;
  77588. /**
  77589. * The weight of the runtime animation
  77590. */
  77591. private _weight;
  77592. /**
  77593. * The ratio offset of the runtime animation
  77594. */
  77595. private _ratioOffset;
  77596. /**
  77597. * The previous delay of the runtime animation
  77598. */
  77599. private _previousDelay;
  77600. /**
  77601. * The previous ratio of the runtime animation
  77602. */
  77603. private _previousRatio;
  77604. private _enableBlending;
  77605. private _keys;
  77606. private _minFrame;
  77607. private _maxFrame;
  77608. private _minValue;
  77609. private _maxValue;
  77610. private _targetIsArray;
  77611. /**
  77612. * Gets the current frame of the runtime animation
  77613. */
  77614. readonly currentFrame: number;
  77615. /**
  77616. * Gets the weight of the runtime animation
  77617. */
  77618. readonly weight: number;
  77619. /**
  77620. * Gets the current value of the runtime animation
  77621. */
  77622. readonly currentValue: any;
  77623. /**
  77624. * Gets the target path of the runtime animation
  77625. */
  77626. readonly targetPath: string;
  77627. /**
  77628. * Gets the actual target of the runtime animation
  77629. */
  77630. readonly target: any;
  77631. /** @hidden */
  77632. _onLoop: () => void;
  77633. /**
  77634. * Create a new RuntimeAnimation object
  77635. * @param target defines the target of the animation
  77636. * @param animation defines the source animation object
  77637. * @param scene defines the hosting scene
  77638. * @param host defines the initiating Animatable
  77639. */
  77640. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77641. private _preparePath;
  77642. /**
  77643. * Gets the animation from the runtime animation
  77644. */
  77645. readonly animation: Animation;
  77646. /**
  77647. * Resets the runtime animation to the beginning
  77648. * @param restoreOriginal defines whether to restore the target property to the original value
  77649. */
  77650. reset(restoreOriginal?: boolean): void;
  77651. /**
  77652. * Specifies if the runtime animation is stopped
  77653. * @returns Boolean specifying if the runtime animation is stopped
  77654. */
  77655. isStopped(): boolean;
  77656. /**
  77657. * Disposes of the runtime animation
  77658. */
  77659. dispose(): void;
  77660. /**
  77661. * Apply the interpolated value to the target
  77662. * @param currentValue defines the value computed by the animation
  77663. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77664. */
  77665. setValue(currentValue: any, weight: number): void;
  77666. private _getOriginalValues;
  77667. private _setValue;
  77668. /**
  77669. * Gets the loop pmode of the runtime animation
  77670. * @returns Loop Mode
  77671. */
  77672. private _getCorrectLoopMode;
  77673. /**
  77674. * Move the current animation to a given frame
  77675. * @param frame defines the frame to move to
  77676. */
  77677. goToFrame(frame: number): void;
  77678. /**
  77679. * @hidden Internal use only
  77680. */
  77681. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77682. /**
  77683. * Execute the current animation
  77684. * @param delay defines the delay to add to the current frame
  77685. * @param from defines the lower bound of the animation range
  77686. * @param to defines the upper bound of the animation range
  77687. * @param loop defines if the current animation must loop
  77688. * @param speedRatio defines the current speed ratio
  77689. * @param weight defines the weight of the animation (default is -1 so no weight)
  77690. * @param onLoop optional callback called when animation loops
  77691. * @returns a boolean indicating if the animation is running
  77692. */
  77693. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77694. }
  77695. }
  77696. declare module BABYLON {
  77697. /**
  77698. * Class used to store an actual running animation
  77699. */
  77700. export class Animatable {
  77701. /** defines the target object */
  77702. target: any;
  77703. /** defines the starting frame number (default is 0) */
  77704. fromFrame: number;
  77705. /** defines the ending frame number (default is 100) */
  77706. toFrame: number;
  77707. /** defines if the animation must loop (default is false) */
  77708. loopAnimation: boolean;
  77709. /** defines a callback to call when animation ends if it is not looping */
  77710. onAnimationEnd?: (() => void) | null | undefined;
  77711. /** defines a callback to call when animation loops */
  77712. onAnimationLoop?: (() => void) | null | undefined;
  77713. private _localDelayOffset;
  77714. private _pausedDelay;
  77715. private _runtimeAnimations;
  77716. private _paused;
  77717. private _scene;
  77718. private _speedRatio;
  77719. private _weight;
  77720. private _syncRoot;
  77721. /**
  77722. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77723. * This will only apply for non looping animation (default is true)
  77724. */
  77725. disposeOnEnd: boolean;
  77726. /**
  77727. * Gets a boolean indicating if the animation has started
  77728. */
  77729. animationStarted: boolean;
  77730. /**
  77731. * Observer raised when the animation ends
  77732. */
  77733. onAnimationEndObservable: Observable<Animatable>;
  77734. /**
  77735. * Observer raised when the animation loops
  77736. */
  77737. onAnimationLoopObservable: Observable<Animatable>;
  77738. /**
  77739. * Gets the root Animatable used to synchronize and normalize animations
  77740. */
  77741. readonly syncRoot: Nullable<Animatable>;
  77742. /**
  77743. * Gets the current frame of the first RuntimeAnimation
  77744. * Used to synchronize Animatables
  77745. */
  77746. readonly masterFrame: number;
  77747. /**
  77748. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77749. */
  77750. weight: number;
  77751. /**
  77752. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77753. */
  77754. speedRatio: number;
  77755. /**
  77756. * Creates a new Animatable
  77757. * @param scene defines the hosting scene
  77758. * @param target defines the target object
  77759. * @param fromFrame defines the starting frame number (default is 0)
  77760. * @param toFrame defines the ending frame number (default is 100)
  77761. * @param loopAnimation defines if the animation must loop (default is false)
  77762. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77763. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77764. * @param animations defines a group of animation to add to the new Animatable
  77765. * @param onAnimationLoop defines a callback to call when animation loops
  77766. */
  77767. constructor(scene: Scene,
  77768. /** defines the target object */
  77769. target: any,
  77770. /** defines the starting frame number (default is 0) */
  77771. fromFrame?: number,
  77772. /** defines the ending frame number (default is 100) */
  77773. toFrame?: number,
  77774. /** defines if the animation must loop (default is false) */
  77775. loopAnimation?: boolean, speedRatio?: number,
  77776. /** defines a callback to call when animation ends if it is not looping */
  77777. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77778. /** defines a callback to call when animation loops */
  77779. onAnimationLoop?: (() => void) | null | undefined);
  77780. /**
  77781. * Synchronize and normalize current Animatable with a source Animatable
  77782. * This is useful when using animation weights and when animations are not of the same length
  77783. * @param root defines the root Animatable to synchronize with
  77784. * @returns the current Animatable
  77785. */
  77786. syncWith(root: Animatable): Animatable;
  77787. /**
  77788. * Gets the list of runtime animations
  77789. * @returns an array of RuntimeAnimation
  77790. */
  77791. getAnimations(): RuntimeAnimation[];
  77792. /**
  77793. * Adds more animations to the current animatable
  77794. * @param target defines the target of the animations
  77795. * @param animations defines the new animations to add
  77796. */
  77797. appendAnimations(target: any, animations: Animation[]): void;
  77798. /**
  77799. * Gets the source animation for a specific property
  77800. * @param property defines the propertyu to look for
  77801. * @returns null or the source animation for the given property
  77802. */
  77803. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77804. /**
  77805. * Gets the runtime animation for a specific property
  77806. * @param property defines the propertyu to look for
  77807. * @returns null or the runtime animation for the given property
  77808. */
  77809. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77810. /**
  77811. * Resets the animatable to its original state
  77812. */
  77813. reset(): void;
  77814. /**
  77815. * Allows the animatable to blend with current running animations
  77816. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77817. * @param blendingSpeed defines the blending speed to use
  77818. */
  77819. enableBlending(blendingSpeed: number): void;
  77820. /**
  77821. * Disable animation blending
  77822. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77823. */
  77824. disableBlending(): void;
  77825. /**
  77826. * Jump directly to a given frame
  77827. * @param frame defines the frame to jump to
  77828. */
  77829. goToFrame(frame: number): void;
  77830. /**
  77831. * Pause the animation
  77832. */
  77833. pause(): void;
  77834. /**
  77835. * Restart the animation
  77836. */
  77837. restart(): void;
  77838. private _raiseOnAnimationEnd;
  77839. /**
  77840. * Stop and delete the current animation
  77841. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77842. * @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)
  77843. */
  77844. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77845. /**
  77846. * Wait asynchronously for the animation to end
  77847. * @returns a promise which will be fullfilled when the animation ends
  77848. */
  77849. waitAsync(): Promise<Animatable>;
  77850. /** @hidden */
  77851. _animate(delay: number): boolean;
  77852. }
  77853. interface Scene {
  77854. /** @hidden */
  77855. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77856. /** @hidden */
  77857. _processLateAnimationBindingsForMatrices(holder: {
  77858. totalWeight: number;
  77859. animations: RuntimeAnimation[];
  77860. originalValue: Matrix;
  77861. }): any;
  77862. /** @hidden */
  77863. _processLateAnimationBindingsForQuaternions(holder: {
  77864. totalWeight: number;
  77865. animations: RuntimeAnimation[];
  77866. originalValue: Quaternion;
  77867. }, refQuaternion: Quaternion): Quaternion;
  77868. /** @hidden */
  77869. _processLateAnimationBindings(): void;
  77870. /**
  77871. * Will start the animation sequence of a given target
  77872. * @param target defines the target
  77873. * @param from defines from which frame should animation start
  77874. * @param to defines until which frame should animation run.
  77875. * @param weight defines the weight to apply to the animation (1.0 by default)
  77876. * @param loop defines if the animation loops
  77877. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77878. * @param onAnimationEnd defines the function to be executed when the animation ends
  77879. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77880. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77881. * @param onAnimationLoop defines the callback to call when an animation loops
  77882. * @returns the animatable object created for this animation
  77883. */
  77884. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77885. /**
  77886. * Will start the animation sequence of a given target
  77887. * @param target defines the target
  77888. * @param from defines from which frame should animation start
  77889. * @param to defines until which frame should animation run.
  77890. * @param loop defines if the animation loops
  77891. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77892. * @param onAnimationEnd defines the function to be executed when the animation ends
  77893. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77894. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77895. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77896. * @param onAnimationLoop defines the callback to call when an animation loops
  77897. * @returns the animatable object created for this animation
  77898. */
  77899. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77900. /**
  77901. * Will start the animation sequence of a given target and its hierarchy
  77902. * @param target defines the target
  77903. * @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.
  77904. * @param from defines from which frame should animation start
  77905. * @param to defines until which frame should animation run.
  77906. * @param loop defines if the animation loops
  77907. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77908. * @param onAnimationEnd defines the function to be executed when the animation ends
  77909. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77910. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77911. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77912. * @param onAnimationLoop defines the callback to call when an animation loops
  77913. * @returns the list of created animatables
  77914. */
  77915. 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[];
  77916. /**
  77917. * Begin a new animation on a given node
  77918. * @param target defines the target where the animation will take place
  77919. * @param animations defines the list of animations to start
  77920. * @param from defines the initial value
  77921. * @param to defines the final value
  77922. * @param loop defines if you want animation to loop (off by default)
  77923. * @param speedRatio defines the speed ratio to apply to all animations
  77924. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77925. * @param onAnimationLoop defines the callback to call when an animation loops
  77926. * @returns the list of created animatables
  77927. */
  77928. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77929. /**
  77930. * Begin a new animation on a given node and its hierarchy
  77931. * @param target defines the root node where the animation will take place
  77932. * @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.
  77933. * @param animations defines the list of animations to start
  77934. * @param from defines the initial value
  77935. * @param to defines the final value
  77936. * @param loop defines if you want animation to loop (off by default)
  77937. * @param speedRatio defines the speed ratio to apply to all animations
  77938. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77939. * @param onAnimationLoop defines the callback to call when an animation loops
  77940. * @returns the list of animatables created for all nodes
  77941. */
  77942. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77943. /**
  77944. * Gets the animatable associated with a specific target
  77945. * @param target defines the target of the animatable
  77946. * @returns the required animatable if found
  77947. */
  77948. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77949. /**
  77950. * Gets all animatables associated with a given target
  77951. * @param target defines the target to look animatables for
  77952. * @returns an array of Animatables
  77953. */
  77954. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77955. /**
  77956. * Stops and removes all animations that have been applied to the scene
  77957. */
  77958. stopAllAnimations(): void;
  77959. }
  77960. interface Bone {
  77961. /**
  77962. * Copy an animation range from another bone
  77963. * @param source defines the source bone
  77964. * @param rangeName defines the range name to copy
  77965. * @param frameOffset defines the frame offset
  77966. * @param rescaleAsRequired defines if rescaling must be applied if required
  77967. * @param skelDimensionsRatio defines the scaling ratio
  77968. * @returns true if operation was successful
  77969. */
  77970. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77971. }
  77972. }
  77973. declare module BABYLON {
  77974. /**
  77975. * Class used to override all child animations of a given target
  77976. */
  77977. export class AnimationPropertiesOverride {
  77978. /**
  77979. * Gets or sets a value indicating if animation blending must be used
  77980. */
  77981. enableBlending: boolean;
  77982. /**
  77983. * Gets or sets the blending speed to use when enableBlending is true
  77984. */
  77985. blendingSpeed: number;
  77986. /**
  77987. * Gets or sets the default loop mode to use
  77988. */
  77989. loopMode: number;
  77990. }
  77991. }
  77992. declare module BABYLON {
  77993. /**
  77994. * Class used to handle skinning animations
  77995. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77996. */
  77997. export class Skeleton implements IAnimatable {
  77998. /** defines the skeleton name */
  77999. name: string;
  78000. /** defines the skeleton Id */
  78001. id: string;
  78002. /**
  78003. * Defines the list of child bones
  78004. */
  78005. bones: Bone[];
  78006. /**
  78007. * Defines an estimate of the dimension of the skeleton at rest
  78008. */
  78009. dimensionsAtRest: Vector3;
  78010. /**
  78011. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78012. */
  78013. needInitialSkinMatrix: boolean;
  78014. /**
  78015. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78016. */
  78017. overrideMesh: Nullable<AbstractMesh>;
  78018. /**
  78019. * Gets the list of animations attached to this skeleton
  78020. */
  78021. animations: Array<Animation>;
  78022. private _scene;
  78023. private _isDirty;
  78024. private _transformMatrices;
  78025. private _transformMatrixTexture;
  78026. private _meshesWithPoseMatrix;
  78027. private _animatables;
  78028. private _identity;
  78029. private _synchronizedWithMesh;
  78030. private _ranges;
  78031. private _lastAbsoluteTransformsUpdateId;
  78032. private _canUseTextureForBones;
  78033. private _uniqueId;
  78034. /** @hidden */
  78035. _numBonesWithLinkedTransformNode: number;
  78036. /** @hidden */
  78037. _hasWaitingData: Nullable<boolean>;
  78038. /**
  78039. * Specifies if the skeleton should be serialized
  78040. */
  78041. doNotSerialize: boolean;
  78042. private _useTextureToStoreBoneMatrices;
  78043. /**
  78044. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78045. * Please note that this option is not available if the hardware does not support it
  78046. */
  78047. useTextureToStoreBoneMatrices: boolean;
  78048. private _animationPropertiesOverride;
  78049. /**
  78050. * Gets or sets the animation properties override
  78051. */
  78052. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78053. /**
  78054. * List of inspectable custom properties (used by the Inspector)
  78055. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78056. */
  78057. inspectableCustomProperties: IInspectable[];
  78058. /**
  78059. * An observable triggered before computing the skeleton's matrices
  78060. */
  78061. onBeforeComputeObservable: Observable<Skeleton>;
  78062. /**
  78063. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78064. */
  78065. readonly isUsingTextureForMatrices: boolean;
  78066. /**
  78067. * Gets the unique ID of this skeleton
  78068. */
  78069. readonly uniqueId: number;
  78070. /**
  78071. * Creates a new skeleton
  78072. * @param name defines the skeleton name
  78073. * @param id defines the skeleton Id
  78074. * @param scene defines the hosting scene
  78075. */
  78076. constructor(
  78077. /** defines the skeleton name */
  78078. name: string,
  78079. /** defines the skeleton Id */
  78080. id: string, scene: Scene);
  78081. /**
  78082. * Gets the current object class name.
  78083. * @return the class name
  78084. */
  78085. getClassName(): string;
  78086. /**
  78087. * Returns an array containing the root bones
  78088. * @returns an array containing the root bones
  78089. */
  78090. getChildren(): Array<Bone>;
  78091. /**
  78092. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78093. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78094. * @returns a Float32Array containing matrices data
  78095. */
  78096. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78097. /**
  78098. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78099. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78100. * @returns a raw texture containing the data
  78101. */
  78102. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78103. /**
  78104. * Gets the current hosting scene
  78105. * @returns a scene object
  78106. */
  78107. getScene(): Scene;
  78108. /**
  78109. * Gets a string representing the current skeleton data
  78110. * @param fullDetails defines a boolean indicating if we want a verbose version
  78111. * @returns a string representing the current skeleton data
  78112. */
  78113. toString(fullDetails?: boolean): string;
  78114. /**
  78115. * Get bone's index searching by name
  78116. * @param name defines bone's name to search for
  78117. * @return the indice of the bone. Returns -1 if not found
  78118. */
  78119. getBoneIndexByName(name: string): number;
  78120. /**
  78121. * Creater a new animation range
  78122. * @param name defines the name of the range
  78123. * @param from defines the start key
  78124. * @param to defines the end key
  78125. */
  78126. createAnimationRange(name: string, from: number, to: number): void;
  78127. /**
  78128. * Delete a specific animation range
  78129. * @param name defines the name of the range
  78130. * @param deleteFrames defines if frames must be removed as well
  78131. */
  78132. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78133. /**
  78134. * Gets a specific animation range
  78135. * @param name defines the name of the range to look for
  78136. * @returns the requested animation range or null if not found
  78137. */
  78138. getAnimationRange(name: string): Nullable<AnimationRange>;
  78139. /**
  78140. * Gets the list of all animation ranges defined on this skeleton
  78141. * @returns an array
  78142. */
  78143. getAnimationRanges(): Nullable<AnimationRange>[];
  78144. /**
  78145. * Copy animation range from a source skeleton.
  78146. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78147. * @param source defines the source skeleton
  78148. * @param name defines the name of the range to copy
  78149. * @param rescaleAsRequired defines if rescaling must be applied if required
  78150. * @returns true if operation was successful
  78151. */
  78152. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78153. /**
  78154. * Forces the skeleton to go to rest pose
  78155. */
  78156. returnToRest(): void;
  78157. private _getHighestAnimationFrame;
  78158. /**
  78159. * Begin a specific animation range
  78160. * @param name defines the name of the range to start
  78161. * @param loop defines if looping must be turned on (false by default)
  78162. * @param speedRatio defines the speed ratio to apply (1 by default)
  78163. * @param onAnimationEnd defines a callback which will be called when animation will end
  78164. * @returns a new animatable
  78165. */
  78166. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78167. /** @hidden */
  78168. _markAsDirty(): void;
  78169. /** @hidden */
  78170. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78171. /** @hidden */
  78172. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78173. private _computeTransformMatrices;
  78174. /**
  78175. * Build all resources required to render a skeleton
  78176. */
  78177. prepare(): void;
  78178. /**
  78179. * Gets the list of animatables currently running for this skeleton
  78180. * @returns an array of animatables
  78181. */
  78182. getAnimatables(): IAnimatable[];
  78183. /**
  78184. * Clone the current skeleton
  78185. * @param name defines the name of the new skeleton
  78186. * @param id defines the id of the new skeleton
  78187. * @returns the new skeleton
  78188. */
  78189. clone(name: string, id: string): Skeleton;
  78190. /**
  78191. * Enable animation blending for this skeleton
  78192. * @param blendingSpeed defines the blending speed to apply
  78193. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78194. */
  78195. enableBlending(blendingSpeed?: number): void;
  78196. /**
  78197. * Releases all resources associated with the current skeleton
  78198. */
  78199. dispose(): void;
  78200. /**
  78201. * Serialize the skeleton in a JSON object
  78202. * @returns a JSON object
  78203. */
  78204. serialize(): any;
  78205. /**
  78206. * Creates a new skeleton from serialized data
  78207. * @param parsedSkeleton defines the serialized data
  78208. * @param scene defines the hosting scene
  78209. * @returns a new skeleton
  78210. */
  78211. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78212. /**
  78213. * Compute all node absolute transforms
  78214. * @param forceUpdate defines if computation must be done even if cache is up to date
  78215. */
  78216. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78217. /**
  78218. * Gets the root pose matrix
  78219. * @returns a matrix
  78220. */
  78221. getPoseMatrix(): Nullable<Matrix>;
  78222. /**
  78223. * Sorts bones per internal index
  78224. */
  78225. sortBones(): void;
  78226. private _sortBones;
  78227. }
  78228. }
  78229. declare module BABYLON {
  78230. /**
  78231. * Class used to store bone information
  78232. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78233. */
  78234. export class Bone extends Node {
  78235. /**
  78236. * defines the bone name
  78237. */
  78238. name: string;
  78239. private static _tmpVecs;
  78240. private static _tmpQuat;
  78241. private static _tmpMats;
  78242. /**
  78243. * Gets the list of child bones
  78244. */
  78245. children: Bone[];
  78246. /** Gets the animations associated with this bone */
  78247. animations: Animation[];
  78248. /**
  78249. * Gets or sets bone length
  78250. */
  78251. length: number;
  78252. /**
  78253. * @hidden Internal only
  78254. * Set this value to map this bone to a different index in the transform matrices
  78255. * Set this value to -1 to exclude the bone from the transform matrices
  78256. */
  78257. _index: Nullable<number>;
  78258. private _skeleton;
  78259. private _localMatrix;
  78260. private _restPose;
  78261. private _baseMatrix;
  78262. private _absoluteTransform;
  78263. private _invertedAbsoluteTransform;
  78264. private _parent;
  78265. private _scalingDeterminant;
  78266. private _worldTransform;
  78267. private _localScaling;
  78268. private _localRotation;
  78269. private _localPosition;
  78270. private _needToDecompose;
  78271. private _needToCompose;
  78272. /** @hidden */
  78273. _linkedTransformNode: Nullable<TransformNode>;
  78274. /** @hidden */
  78275. _waitingTransformNodeId: Nullable<string>;
  78276. /** @hidden */
  78277. /** @hidden */
  78278. _matrix: Matrix;
  78279. /**
  78280. * Create a new bone
  78281. * @param name defines the bone name
  78282. * @param skeleton defines the parent skeleton
  78283. * @param parentBone defines the parent (can be null if the bone is the root)
  78284. * @param localMatrix defines the local matrix
  78285. * @param restPose defines the rest pose matrix
  78286. * @param baseMatrix defines the base matrix
  78287. * @param index defines index of the bone in the hiearchy
  78288. */
  78289. constructor(
  78290. /**
  78291. * defines the bone name
  78292. */
  78293. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  78294. /**
  78295. * Gets the current object class name.
  78296. * @return the class name
  78297. */
  78298. getClassName(): string;
  78299. /**
  78300. * Gets the parent skeleton
  78301. * @returns a skeleton
  78302. */
  78303. getSkeleton(): Skeleton;
  78304. /**
  78305. * Gets parent bone
  78306. * @returns a bone or null if the bone is the root of the bone hierarchy
  78307. */
  78308. getParent(): Nullable<Bone>;
  78309. /**
  78310. * Returns an array containing the root bones
  78311. * @returns an array containing the root bones
  78312. */
  78313. getChildren(): Array<Bone>;
  78314. /**
  78315. * Sets the parent bone
  78316. * @param parent defines the parent (can be null if the bone is the root)
  78317. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78318. */
  78319. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  78320. /**
  78321. * Gets the local matrix
  78322. * @returns a matrix
  78323. */
  78324. getLocalMatrix(): Matrix;
  78325. /**
  78326. * Gets the base matrix (initial matrix which remains unchanged)
  78327. * @returns a matrix
  78328. */
  78329. getBaseMatrix(): Matrix;
  78330. /**
  78331. * Gets the rest pose matrix
  78332. * @returns a matrix
  78333. */
  78334. getRestPose(): Matrix;
  78335. /**
  78336. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  78337. */
  78338. getWorldMatrix(): Matrix;
  78339. /**
  78340. * Sets the local matrix to rest pose matrix
  78341. */
  78342. returnToRest(): void;
  78343. /**
  78344. * Gets the inverse of the absolute transform matrix.
  78345. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  78346. * @returns a matrix
  78347. */
  78348. getInvertedAbsoluteTransform(): Matrix;
  78349. /**
  78350. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  78351. * @returns a matrix
  78352. */
  78353. getAbsoluteTransform(): Matrix;
  78354. /**
  78355. * Links with the given transform node.
  78356. * The local matrix of this bone is copied from the transform node every frame.
  78357. * @param transformNode defines the transform node to link to
  78358. */
  78359. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  78360. /**
  78361. * Gets the node used to drive the bone's transformation
  78362. * @returns a transform node or null
  78363. */
  78364. getTransformNode(): Nullable<TransformNode>;
  78365. /** Gets or sets current position (in local space) */
  78366. position: Vector3;
  78367. /** Gets or sets current rotation (in local space) */
  78368. rotation: Vector3;
  78369. /** Gets or sets current rotation quaternion (in local space) */
  78370. rotationQuaternion: Quaternion;
  78371. /** Gets or sets current scaling (in local space) */
  78372. scaling: Vector3;
  78373. /**
  78374. * Gets the animation properties override
  78375. */
  78376. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78377. private _decompose;
  78378. private _compose;
  78379. /**
  78380. * Update the base and local matrices
  78381. * @param matrix defines the new base or local matrix
  78382. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78383. * @param updateLocalMatrix defines if the local matrix should be updated
  78384. */
  78385. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  78386. /** @hidden */
  78387. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  78388. /**
  78389. * Flag the bone as dirty (Forcing it to update everything)
  78390. */
  78391. markAsDirty(): void;
  78392. /** @hidden */
  78393. _markAsDirtyAndCompose(): void;
  78394. private _markAsDirtyAndDecompose;
  78395. /**
  78396. * Translate the bone in local or world space
  78397. * @param vec The amount to translate the bone
  78398. * @param space The space that the translation is in
  78399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78400. */
  78401. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78402. /**
  78403. * Set the postion of the bone in local or world space
  78404. * @param position The position to set the bone
  78405. * @param space The space that the position is in
  78406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78407. */
  78408. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78409. /**
  78410. * Set the absolute position of the bone (world space)
  78411. * @param position The position to set the bone
  78412. * @param mesh The mesh that this bone is attached to
  78413. */
  78414. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  78415. /**
  78416. * Scale the bone on the x, y and z axes (in local space)
  78417. * @param x The amount to scale the bone on the x axis
  78418. * @param y The amount to scale the bone on the y axis
  78419. * @param z The amount to scale the bone on the z axis
  78420. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  78421. */
  78422. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  78423. /**
  78424. * Set the bone scaling in local space
  78425. * @param scale defines the scaling vector
  78426. */
  78427. setScale(scale: Vector3): void;
  78428. /**
  78429. * Gets the current scaling in local space
  78430. * @returns the current scaling vector
  78431. */
  78432. getScale(): Vector3;
  78433. /**
  78434. * Gets the current scaling in local space and stores it in a target vector
  78435. * @param result defines the target vector
  78436. */
  78437. getScaleToRef(result: Vector3): void;
  78438. /**
  78439. * Set the yaw, pitch, and roll of the bone in local or world space
  78440. * @param yaw The rotation of the bone on the y axis
  78441. * @param pitch The rotation of the bone on the x axis
  78442. * @param roll The rotation of the bone on the z axis
  78443. * @param space The space that the axes of rotation are in
  78444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78445. */
  78446. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  78447. /**
  78448. * Add a rotation to the bone on an axis in local or world space
  78449. * @param axis The axis to rotate the bone on
  78450. * @param amount The amount to rotate the bone
  78451. * @param space The space that the axis is in
  78452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78453. */
  78454. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  78455. /**
  78456. * Set the rotation of the bone to a particular axis angle in local or world space
  78457. * @param axis The axis to rotate the bone on
  78458. * @param angle The angle that the bone should be rotated to
  78459. * @param space The space that the axis is in
  78460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78461. */
  78462. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  78463. /**
  78464. * Set the euler rotation of the bone in local of world space
  78465. * @param rotation The euler rotation that the bone should be set to
  78466. * @param space The space that the rotation is in
  78467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78468. */
  78469. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78470. /**
  78471. * Set the quaternion rotation of the bone in local of world space
  78472. * @param quat The quaternion rotation that the bone should be set to
  78473. * @param space The space that the rotation is in
  78474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78475. */
  78476. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  78477. /**
  78478. * Set the rotation matrix of the bone in local of world space
  78479. * @param rotMat The rotation matrix that the bone should be set to
  78480. * @param space The space that the rotation is in
  78481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78482. */
  78483. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  78484. private _rotateWithMatrix;
  78485. private _getNegativeRotationToRef;
  78486. /**
  78487. * Get the position of the bone in local or world space
  78488. * @param space The space that the returned position is in
  78489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78490. * @returns The position of the bone
  78491. */
  78492. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78493. /**
  78494. * Copy the position of the bone to a vector3 in local or world space
  78495. * @param space The space that the returned position is in
  78496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78497. * @param result The vector3 to copy the position to
  78498. */
  78499. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  78500. /**
  78501. * Get the absolute position of the bone (world space)
  78502. * @param mesh The mesh that this bone is attached to
  78503. * @returns The absolute position of the bone
  78504. */
  78505. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  78506. /**
  78507. * Copy the absolute position of the bone (world space) to the result param
  78508. * @param mesh The mesh that this bone is attached to
  78509. * @param result The vector3 to copy the absolute position to
  78510. */
  78511. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  78512. /**
  78513. * Compute the absolute transforms of this bone and its children
  78514. */
  78515. computeAbsoluteTransforms(): void;
  78516. /**
  78517. * Get the world direction from an axis that is in the local space of the bone
  78518. * @param localAxis The local direction that is used to compute the world direction
  78519. * @param mesh The mesh that this bone is attached to
  78520. * @returns The world direction
  78521. */
  78522. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78523. /**
  78524. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  78525. * @param localAxis The local direction that is used to compute the world direction
  78526. * @param mesh The mesh that this bone is attached to
  78527. * @param result The vector3 that the world direction will be copied to
  78528. */
  78529. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78530. /**
  78531. * Get the euler rotation of the bone in local or world space
  78532. * @param space The space that the rotation should be in
  78533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78534. * @returns The euler rotation
  78535. */
  78536. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78537. /**
  78538. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  78539. * @param space The space that the rotation should be in
  78540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78541. * @param result The vector3 that the rotation should be copied to
  78542. */
  78543. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78544. /**
  78545. * Get the quaternion rotation of the bone in either local or world space
  78546. * @param space The space that the rotation should be in
  78547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78548. * @returns The quaternion rotation
  78549. */
  78550. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  78551. /**
  78552. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  78553. * @param space The space that the rotation should be in
  78554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78555. * @param result The quaternion that the rotation should be copied to
  78556. */
  78557. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  78558. /**
  78559. * Get the rotation matrix of the bone in local or world space
  78560. * @param space The space that the rotation should be in
  78561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78562. * @returns The rotation matrix
  78563. */
  78564. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  78565. /**
  78566. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  78567. * @param space The space that the rotation should be in
  78568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78569. * @param result The quaternion that the rotation should be copied to
  78570. */
  78571. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  78572. /**
  78573. * Get the world position of a point that is in the local space of the bone
  78574. * @param position The local position
  78575. * @param mesh The mesh that this bone is attached to
  78576. * @returns The world position
  78577. */
  78578. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78579. /**
  78580. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  78581. * @param position The local position
  78582. * @param mesh The mesh that this bone is attached to
  78583. * @param result The vector3 that the world position should be copied to
  78584. */
  78585. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78586. /**
  78587. * Get the local position of a point that is in world space
  78588. * @param position The world position
  78589. * @param mesh The mesh that this bone is attached to
  78590. * @returns The local position
  78591. */
  78592. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78593. /**
  78594. * Get the local position of a point that is in world space and copy it to the result param
  78595. * @param position The world position
  78596. * @param mesh The mesh that this bone is attached to
  78597. * @param result The vector3 that the local position should be copied to
  78598. */
  78599. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78600. }
  78601. }
  78602. declare module BABYLON {
  78603. /**
  78604. * 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.
  78605. * @see https://doc.babylonjs.com/how_to/transformnode
  78606. */
  78607. export class TransformNode extends Node {
  78608. /**
  78609. * Object will not rotate to face the camera
  78610. */
  78611. static BILLBOARDMODE_NONE: number;
  78612. /**
  78613. * Object will rotate to face the camera but only on the x axis
  78614. */
  78615. static BILLBOARDMODE_X: number;
  78616. /**
  78617. * Object will rotate to face the camera but only on the y axis
  78618. */
  78619. static BILLBOARDMODE_Y: number;
  78620. /**
  78621. * Object will rotate to face the camera but only on the z axis
  78622. */
  78623. static BILLBOARDMODE_Z: number;
  78624. /**
  78625. * Object will rotate to face the camera
  78626. */
  78627. static BILLBOARDMODE_ALL: number;
  78628. /**
  78629. * Object will rotate to face the camera's position instead of orientation
  78630. */
  78631. static BILLBOARDMODE_USE_POSITION: number;
  78632. private _forward;
  78633. private _forwardInverted;
  78634. private _up;
  78635. private _right;
  78636. private _rightInverted;
  78637. private _position;
  78638. private _rotation;
  78639. private _rotationQuaternion;
  78640. protected _scaling: Vector3;
  78641. protected _isDirty: boolean;
  78642. private _transformToBoneReferal;
  78643. private _isAbsoluteSynced;
  78644. private _billboardMode;
  78645. /**
  78646. * Gets or sets the billboard mode. Default is 0.
  78647. *
  78648. * | Value | Type | Description |
  78649. * | --- | --- | --- |
  78650. * | 0 | BILLBOARDMODE_NONE | |
  78651. * | 1 | BILLBOARDMODE_X | |
  78652. * | 2 | BILLBOARDMODE_Y | |
  78653. * | 4 | BILLBOARDMODE_Z | |
  78654. * | 7 | BILLBOARDMODE_ALL | |
  78655. *
  78656. */
  78657. billboardMode: number;
  78658. private _preserveParentRotationForBillboard;
  78659. /**
  78660. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  78661. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  78662. */
  78663. preserveParentRotationForBillboard: boolean;
  78664. /**
  78665. * 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
  78666. */
  78667. scalingDeterminant: number;
  78668. private _infiniteDistance;
  78669. /**
  78670. * Gets or sets the distance of the object to max, often used by skybox
  78671. */
  78672. infiniteDistance: boolean;
  78673. /**
  78674. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  78675. * By default the system will update normals to compensate
  78676. */
  78677. ignoreNonUniformScaling: boolean;
  78678. /**
  78679. * 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
  78680. */
  78681. reIntegrateRotationIntoRotationQuaternion: boolean;
  78682. /** @hidden */
  78683. _poseMatrix: Nullable<Matrix>;
  78684. /** @hidden */
  78685. _localMatrix: Matrix;
  78686. private _usePivotMatrix;
  78687. private _absolutePosition;
  78688. private _absoluteScaling;
  78689. private _absoluteRotationQuaternion;
  78690. private _pivotMatrix;
  78691. private _pivotMatrixInverse;
  78692. protected _postMultiplyPivotMatrix: boolean;
  78693. protected _isWorldMatrixFrozen: boolean;
  78694. /** @hidden */
  78695. _indexInSceneTransformNodesArray: number;
  78696. /**
  78697. * An event triggered after the world matrix is updated
  78698. */
  78699. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  78700. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  78701. /**
  78702. * Gets a string identifying the name of the class
  78703. * @returns "TransformNode" string
  78704. */
  78705. getClassName(): string;
  78706. /**
  78707. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  78708. */
  78709. position: Vector3;
  78710. /**
  78711. * 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)).
  78712. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  78713. */
  78714. rotation: Vector3;
  78715. /**
  78716. * 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)).
  78717. */
  78718. scaling: Vector3;
  78719. /**
  78720. * 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).
  78721. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  78722. */
  78723. rotationQuaternion: Nullable<Quaternion>;
  78724. /**
  78725. * The forward direction of that transform in world space.
  78726. */
  78727. readonly forward: Vector3;
  78728. /**
  78729. * The up direction of that transform in world space.
  78730. */
  78731. readonly up: Vector3;
  78732. /**
  78733. * The right direction of that transform in world space.
  78734. */
  78735. readonly right: Vector3;
  78736. /**
  78737. * Copies the parameter passed Matrix into the mesh Pose matrix.
  78738. * @param matrix the matrix to copy the pose from
  78739. * @returns this TransformNode.
  78740. */
  78741. updatePoseMatrix(matrix: Matrix): TransformNode;
  78742. /**
  78743. * Returns the mesh Pose matrix.
  78744. * @returns the pose matrix
  78745. */
  78746. getPoseMatrix(): Matrix;
  78747. /** @hidden */
  78748. _isSynchronized(): boolean;
  78749. /** @hidden */
  78750. _initCache(): void;
  78751. /**
  78752. * Flag the transform node as dirty (Forcing it to update everything)
  78753. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  78754. * @returns this transform node
  78755. */
  78756. markAsDirty(property: string): TransformNode;
  78757. /**
  78758. * Returns the current mesh absolute position.
  78759. * Returns a Vector3.
  78760. */
  78761. readonly absolutePosition: Vector3;
  78762. /**
  78763. * Returns the current mesh absolute scaling.
  78764. * Returns a Vector3.
  78765. */
  78766. readonly absoluteScaling: Vector3;
  78767. /**
  78768. * Returns the current mesh absolute rotation.
  78769. * Returns a Quaternion.
  78770. */
  78771. readonly absoluteRotationQuaternion: Quaternion;
  78772. /**
  78773. * Sets a new matrix to apply before all other transformation
  78774. * @param matrix defines the transform matrix
  78775. * @returns the current TransformNode
  78776. */
  78777. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78778. /**
  78779. * Sets a new pivot matrix to the current node
  78780. * @param matrix defines the new pivot matrix to use
  78781. * @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
  78782. * @returns the current TransformNode
  78783. */
  78784. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78785. /**
  78786. * Returns the mesh pivot matrix.
  78787. * Default : Identity.
  78788. * @returns the matrix
  78789. */
  78790. getPivotMatrix(): Matrix;
  78791. /**
  78792. * Instantiate (when possible) or clone that node with its hierarchy
  78793. * @param newParent defines the new parent to use for the instance (or clone)
  78794. * @returns an instance (or a clone) of the current node with its hiearchy
  78795. */
  78796. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  78797. /**
  78798. * Prevents the World matrix to be computed any longer
  78799. * @param newWorldMatrix defines an optional matrix to use as world matrix
  78800. * @returns the TransformNode.
  78801. */
  78802. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  78803. /**
  78804. * Allows back the World matrix computation.
  78805. * @returns the TransformNode.
  78806. */
  78807. unfreezeWorldMatrix(): this;
  78808. /**
  78809. * True if the World matrix has been frozen.
  78810. */
  78811. readonly isWorldMatrixFrozen: boolean;
  78812. /**
  78813. * Retuns the mesh absolute position in the World.
  78814. * @returns a Vector3.
  78815. */
  78816. getAbsolutePosition(): Vector3;
  78817. /**
  78818. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78819. * @param absolutePosition the absolute position to set
  78820. * @returns the TransformNode.
  78821. */
  78822. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78823. /**
  78824. * Sets the mesh position in its local space.
  78825. * @param vector3 the position to set in localspace
  78826. * @returns the TransformNode.
  78827. */
  78828. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78829. /**
  78830. * Returns the mesh position in the local space from the current World matrix values.
  78831. * @returns a new Vector3.
  78832. */
  78833. getPositionExpressedInLocalSpace(): Vector3;
  78834. /**
  78835. * Translates the mesh along the passed Vector3 in its local space.
  78836. * @param vector3 the distance to translate in localspace
  78837. * @returns the TransformNode.
  78838. */
  78839. locallyTranslate(vector3: Vector3): TransformNode;
  78840. private static _lookAtVectorCache;
  78841. /**
  78842. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78843. * @param targetPoint the position (must be in same space as current mesh) to look at
  78844. * @param yawCor optional yaw (y-axis) correction in radians
  78845. * @param pitchCor optional pitch (x-axis) correction in radians
  78846. * @param rollCor optional roll (z-axis) correction in radians
  78847. * @param space the choosen space of the target
  78848. * @returns the TransformNode.
  78849. */
  78850. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78851. /**
  78852. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78853. * This Vector3 is expressed in the World space.
  78854. * @param localAxis axis to rotate
  78855. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78856. */
  78857. getDirection(localAxis: Vector3): Vector3;
  78858. /**
  78859. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  78860. * localAxis is expressed in the mesh local space.
  78861. * result is computed in the Wordl space from the mesh World matrix.
  78862. * @param localAxis axis to rotate
  78863. * @param result the resulting transformnode
  78864. * @returns this TransformNode.
  78865. */
  78866. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  78867. /**
  78868. * Sets this transform node rotation to the given local axis.
  78869. * @param localAxis the axis in local space
  78870. * @param yawCor optional yaw (y-axis) correction in radians
  78871. * @param pitchCor optional pitch (x-axis) correction in radians
  78872. * @param rollCor optional roll (z-axis) correction in radians
  78873. * @returns this TransformNode
  78874. */
  78875. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  78876. /**
  78877. * Sets a new pivot point to the current node
  78878. * @param point defines the new pivot point to use
  78879. * @param space defines if the point is in world or local space (local by default)
  78880. * @returns the current TransformNode
  78881. */
  78882. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  78883. /**
  78884. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  78885. * @returns the pivot point
  78886. */
  78887. getPivotPoint(): Vector3;
  78888. /**
  78889. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  78890. * @param result the vector3 to store the result
  78891. * @returns this TransformNode.
  78892. */
  78893. getPivotPointToRef(result: Vector3): TransformNode;
  78894. /**
  78895. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  78896. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  78897. */
  78898. getAbsolutePivotPoint(): Vector3;
  78899. /**
  78900. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  78901. * @param result vector3 to store the result
  78902. * @returns this TransformNode.
  78903. */
  78904. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  78905. /**
  78906. * Defines the passed node as the parent of the current node.
  78907. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  78908. * @see https://doc.babylonjs.com/how_to/parenting
  78909. * @param node the node ot set as the parent
  78910. * @returns this TransformNode.
  78911. */
  78912. setParent(node: Nullable<Node>): TransformNode;
  78913. private _nonUniformScaling;
  78914. /**
  78915. * True if the scaling property of this object is non uniform eg. (1,2,1)
  78916. */
  78917. readonly nonUniformScaling: boolean;
  78918. /** @hidden */
  78919. _updateNonUniformScalingState(value: boolean): boolean;
  78920. /**
  78921. * Attach the current TransformNode to another TransformNode associated with a bone
  78922. * @param bone Bone affecting the TransformNode
  78923. * @param affectedTransformNode TransformNode associated with the bone
  78924. * @returns this object
  78925. */
  78926. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  78927. /**
  78928. * Detach the transform node if its associated with a bone
  78929. * @returns this object
  78930. */
  78931. detachFromBone(): TransformNode;
  78932. private static _rotationAxisCache;
  78933. /**
  78934. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  78935. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78936. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78937. * The passed axis is also normalized.
  78938. * @param axis the axis to rotate around
  78939. * @param amount the amount to rotate in radians
  78940. * @param space Space to rotate in (Default: local)
  78941. * @returns the TransformNode.
  78942. */
  78943. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78944. /**
  78945. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  78946. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78947. * The passed axis is also normalized. .
  78948. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  78949. * @param point the point to rotate around
  78950. * @param axis the axis to rotate around
  78951. * @param amount the amount to rotate in radians
  78952. * @returns the TransformNode
  78953. */
  78954. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  78955. /**
  78956. * Translates the mesh along the axis vector for the passed distance in the given space.
  78957. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78958. * @param axis the axis to translate in
  78959. * @param distance the distance to translate
  78960. * @param space Space to rotate in (Default: local)
  78961. * @returns the TransformNode.
  78962. */
  78963. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78964. /**
  78965. * Adds a rotation step to the mesh current rotation.
  78966. * x, y, z are Euler angles expressed in radians.
  78967. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  78968. * This means this rotation is made in the mesh local space only.
  78969. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  78970. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  78971. * ```javascript
  78972. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  78973. * ```
  78974. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  78975. * 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.
  78976. * @param x Rotation to add
  78977. * @param y Rotation to add
  78978. * @param z Rotation to add
  78979. * @returns the TransformNode.
  78980. */
  78981. addRotation(x: number, y: number, z: number): TransformNode;
  78982. /**
  78983. * @hidden
  78984. */
  78985. protected _getEffectiveParent(): Nullable<Node>;
  78986. /**
  78987. * Computes the world matrix of the node
  78988. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78989. * @returns the world matrix
  78990. */
  78991. computeWorldMatrix(force?: boolean): Matrix;
  78992. protected _afterComputeWorldMatrix(): void;
  78993. /**
  78994. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  78995. * @param func callback function to add
  78996. *
  78997. * @returns the TransformNode.
  78998. */
  78999. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79000. /**
  79001. * Removes a registered callback function.
  79002. * @param func callback function to remove
  79003. * @returns the TransformNode.
  79004. */
  79005. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79006. /**
  79007. * Gets the position of the current mesh in camera space
  79008. * @param camera defines the camera to use
  79009. * @returns a position
  79010. */
  79011. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79012. /**
  79013. * Returns the distance from the mesh to the active camera
  79014. * @param camera defines the camera to use
  79015. * @returns the distance
  79016. */
  79017. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79018. /**
  79019. * Clone the current transform node
  79020. * @param name Name of the new clone
  79021. * @param newParent New parent for the clone
  79022. * @param doNotCloneChildren Do not clone children hierarchy
  79023. * @returns the new transform node
  79024. */
  79025. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79026. /**
  79027. * Serializes the objects information.
  79028. * @param currentSerializationObject defines the object to serialize in
  79029. * @returns the serialized object
  79030. */
  79031. serialize(currentSerializationObject?: any): any;
  79032. /**
  79033. * Returns a new TransformNode object parsed from the source provided.
  79034. * @param parsedTransformNode is the source.
  79035. * @param scene the scne the object belongs to
  79036. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79037. * @returns a new TransformNode object parsed from the source provided.
  79038. */
  79039. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79040. /**
  79041. * Get all child-transformNodes of this node
  79042. * @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
  79043. * @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
  79044. * @returns an array of TransformNode
  79045. */
  79046. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79047. /**
  79048. * Releases resources associated with this transform node.
  79049. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79050. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79051. */
  79052. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79053. /**
  79054. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79055. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79056. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79057. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79058. * @returns the current mesh
  79059. */
  79060. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79061. private _syncAbsoluteScalingAndRotation;
  79062. }
  79063. }
  79064. declare module BABYLON {
  79065. /**
  79066. * Defines the types of pose enabled controllers that are supported
  79067. */
  79068. export enum PoseEnabledControllerType {
  79069. /**
  79070. * HTC Vive
  79071. */
  79072. VIVE = 0,
  79073. /**
  79074. * Oculus Rift
  79075. */
  79076. OCULUS = 1,
  79077. /**
  79078. * Windows mixed reality
  79079. */
  79080. WINDOWS = 2,
  79081. /**
  79082. * Samsung gear VR
  79083. */
  79084. GEAR_VR = 3,
  79085. /**
  79086. * Google Daydream
  79087. */
  79088. DAYDREAM = 4,
  79089. /**
  79090. * Generic
  79091. */
  79092. GENERIC = 5
  79093. }
  79094. /**
  79095. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79096. */
  79097. export interface MutableGamepadButton {
  79098. /**
  79099. * Value of the button/trigger
  79100. */
  79101. value: number;
  79102. /**
  79103. * If the button/trigger is currently touched
  79104. */
  79105. touched: boolean;
  79106. /**
  79107. * If the button/trigger is currently pressed
  79108. */
  79109. pressed: boolean;
  79110. }
  79111. /**
  79112. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79113. * @hidden
  79114. */
  79115. export interface ExtendedGamepadButton extends GamepadButton {
  79116. /**
  79117. * If the button/trigger is currently pressed
  79118. */
  79119. readonly pressed: boolean;
  79120. /**
  79121. * If the button/trigger is currently touched
  79122. */
  79123. readonly touched: boolean;
  79124. /**
  79125. * Value of the button/trigger
  79126. */
  79127. readonly value: number;
  79128. }
  79129. /** @hidden */
  79130. export interface _GamePadFactory {
  79131. /**
  79132. * Returns wether or not the current gamepad can be created for this type of controller.
  79133. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79134. * @returns true if it can be created, otherwise false
  79135. */
  79136. canCreate(gamepadInfo: any): boolean;
  79137. /**
  79138. * Creates a new instance of the Gamepad.
  79139. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79140. * @returns the new gamepad instance
  79141. */
  79142. create(gamepadInfo: any): Gamepad;
  79143. }
  79144. /**
  79145. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79146. */
  79147. export class PoseEnabledControllerHelper {
  79148. /** @hidden */
  79149. static _ControllerFactories: _GamePadFactory[];
  79150. /** @hidden */
  79151. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79152. /**
  79153. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79154. * @param vrGamepad the gamepad to initialized
  79155. * @returns a vr controller of the type the gamepad identified as
  79156. */
  79157. static InitiateController(vrGamepad: any): Gamepad;
  79158. }
  79159. /**
  79160. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79161. */
  79162. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79163. /**
  79164. * If the controller is used in a webXR session
  79165. */
  79166. isXR: boolean;
  79167. private _deviceRoomPosition;
  79168. private _deviceRoomRotationQuaternion;
  79169. /**
  79170. * The device position in babylon space
  79171. */
  79172. devicePosition: Vector3;
  79173. /**
  79174. * The device rotation in babylon space
  79175. */
  79176. deviceRotationQuaternion: Quaternion;
  79177. /**
  79178. * The scale factor of the device in babylon space
  79179. */
  79180. deviceScaleFactor: number;
  79181. /**
  79182. * (Likely devicePosition should be used instead) The device position in its room space
  79183. */
  79184. position: Vector3;
  79185. /**
  79186. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79187. */
  79188. rotationQuaternion: Quaternion;
  79189. /**
  79190. * The type of controller (Eg. Windows mixed reality)
  79191. */
  79192. controllerType: PoseEnabledControllerType;
  79193. protected _calculatedPosition: Vector3;
  79194. private _calculatedRotation;
  79195. /**
  79196. * The raw pose from the device
  79197. */
  79198. rawPose: DevicePose;
  79199. private _trackPosition;
  79200. private _maxRotationDistFromHeadset;
  79201. private _draggedRoomRotation;
  79202. /**
  79203. * @hidden
  79204. */
  79205. _disableTrackPosition(fixedPosition: Vector3): void;
  79206. /**
  79207. * Internal, the mesh attached to the controller
  79208. * @hidden
  79209. */
  79210. _mesh: Nullable<AbstractMesh>;
  79211. private _poseControlledCamera;
  79212. private _leftHandSystemQuaternion;
  79213. /**
  79214. * Internal, matrix used to convert room space to babylon space
  79215. * @hidden
  79216. */
  79217. _deviceToWorld: Matrix;
  79218. /**
  79219. * Node to be used when casting a ray from the controller
  79220. * @hidden
  79221. */
  79222. _pointingPoseNode: Nullable<TransformNode>;
  79223. /**
  79224. * Name of the child mesh that can be used to cast a ray from the controller
  79225. */
  79226. static readonly POINTING_POSE: string;
  79227. /**
  79228. * Creates a new PoseEnabledController from a gamepad
  79229. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79230. */
  79231. constructor(browserGamepad: any);
  79232. private _workingMatrix;
  79233. /**
  79234. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79235. */
  79236. update(): void;
  79237. /**
  79238. * Updates only the pose device and mesh without doing any button event checking
  79239. */
  79240. protected _updatePoseAndMesh(): void;
  79241. /**
  79242. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79243. * @param poseData raw pose fromthe device
  79244. */
  79245. updateFromDevice(poseData: DevicePose): void;
  79246. /**
  79247. * @hidden
  79248. */
  79249. _meshAttachedObservable: Observable<AbstractMesh>;
  79250. /**
  79251. * Attaches a mesh to the controller
  79252. * @param mesh the mesh to be attached
  79253. */
  79254. attachToMesh(mesh: AbstractMesh): void;
  79255. /**
  79256. * Attaches the controllers mesh to a camera
  79257. * @param camera the camera the mesh should be attached to
  79258. */
  79259. attachToPoseControlledCamera(camera: TargetCamera): void;
  79260. /**
  79261. * Disposes of the controller
  79262. */
  79263. dispose(): void;
  79264. /**
  79265. * The mesh that is attached to the controller
  79266. */
  79267. readonly mesh: Nullable<AbstractMesh>;
  79268. /**
  79269. * Gets the ray of the controller in the direction the controller is pointing
  79270. * @param length the length the resulting ray should be
  79271. * @returns a ray in the direction the controller is pointing
  79272. */
  79273. getForwardRay(length?: number): Ray;
  79274. }
  79275. }
  79276. declare module BABYLON {
  79277. /**
  79278. * Defines the WebVRController object that represents controllers tracked in 3D space
  79279. */
  79280. export abstract class WebVRController extends PoseEnabledController {
  79281. /**
  79282. * Internal, the default controller model for the controller
  79283. */
  79284. protected _defaultModel: AbstractMesh;
  79285. /**
  79286. * Fired when the trigger state has changed
  79287. */
  79288. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79289. /**
  79290. * Fired when the main button state has changed
  79291. */
  79292. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79293. /**
  79294. * Fired when the secondary button state has changed
  79295. */
  79296. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79297. /**
  79298. * Fired when the pad state has changed
  79299. */
  79300. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79301. /**
  79302. * Fired when controllers stick values have changed
  79303. */
  79304. onPadValuesChangedObservable: Observable<StickValues>;
  79305. /**
  79306. * Array of button availible on the controller
  79307. */
  79308. protected _buttons: Array<MutableGamepadButton>;
  79309. private _onButtonStateChange;
  79310. /**
  79311. * Fired when a controller button's state has changed
  79312. * @param callback the callback containing the button that was modified
  79313. */
  79314. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79315. /**
  79316. * X and Y axis corresponding to the controllers joystick
  79317. */
  79318. pad: StickValues;
  79319. /**
  79320. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79321. */
  79322. hand: string;
  79323. /**
  79324. * The default controller model for the controller
  79325. */
  79326. readonly defaultModel: AbstractMesh;
  79327. /**
  79328. * Creates a new WebVRController from a gamepad
  79329. * @param vrGamepad the gamepad that the WebVRController should be created from
  79330. */
  79331. constructor(vrGamepad: any);
  79332. /**
  79333. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79334. */
  79335. update(): void;
  79336. /**
  79337. * Function to be called when a button is modified
  79338. */
  79339. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79340. /**
  79341. * Loads a mesh and attaches it to the controller
  79342. * @param scene the scene the mesh should be added to
  79343. * @param meshLoaded callback for when the mesh has been loaded
  79344. */
  79345. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79346. private _setButtonValue;
  79347. private _changes;
  79348. private _checkChanges;
  79349. /**
  79350. * Disposes of th webVRCOntroller
  79351. */
  79352. dispose(): void;
  79353. }
  79354. }
  79355. declare module BABYLON {
  79356. /**
  79357. * The HemisphericLight simulates the ambient environment light,
  79358. * so the passed direction is the light reflection direction, not the incoming direction.
  79359. */
  79360. export class HemisphericLight extends Light {
  79361. /**
  79362. * The groundColor is the light in the opposite direction to the one specified during creation.
  79363. * 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.
  79364. */
  79365. groundColor: Color3;
  79366. /**
  79367. * The light reflection direction, not the incoming direction.
  79368. */
  79369. direction: Vector3;
  79370. /**
  79371. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79372. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79373. * The HemisphericLight can't cast shadows.
  79374. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79375. * @param name The friendly name of the light
  79376. * @param direction The direction of the light reflection
  79377. * @param scene The scene the light belongs to
  79378. */
  79379. constructor(name: string, direction: Vector3, scene: Scene);
  79380. protected _buildUniformLayout(): void;
  79381. /**
  79382. * Returns the string "HemisphericLight".
  79383. * @return The class name
  79384. */
  79385. getClassName(): string;
  79386. /**
  79387. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79388. * Returns the updated direction.
  79389. * @param target The target the direction should point to
  79390. * @return The computed direction
  79391. */
  79392. setDirectionToTarget(target: Vector3): Vector3;
  79393. /**
  79394. * Returns the shadow generator associated to the light.
  79395. * @returns Always null for hemispheric lights because it does not support shadows.
  79396. */
  79397. getShadowGenerator(): Nullable<IShadowGenerator>;
  79398. /**
  79399. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79400. * @param effect The effect to update
  79401. * @param lightIndex The index of the light in the effect to update
  79402. * @returns The hemispheric light
  79403. */
  79404. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79405. /**
  79406. * Computes the world matrix of the node
  79407. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79408. * @param useWasUpdatedFlag defines a reserved property
  79409. * @returns the world matrix
  79410. */
  79411. computeWorldMatrix(): Matrix;
  79412. /**
  79413. * Returns the integer 3.
  79414. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79415. */
  79416. getTypeID(): number;
  79417. /**
  79418. * Prepares the list of defines specific to the light type.
  79419. * @param defines the list of defines
  79420. * @param lightIndex defines the index of the light for the effect
  79421. */
  79422. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79423. }
  79424. }
  79425. declare module BABYLON {
  79426. /** @hidden */
  79427. export var vrMultiviewToSingleviewPixelShader: {
  79428. name: string;
  79429. shader: string;
  79430. };
  79431. }
  79432. declare module BABYLON {
  79433. /**
  79434. * Renders to multiple views with a single draw call
  79435. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79436. */
  79437. export class MultiviewRenderTarget extends RenderTargetTexture {
  79438. /**
  79439. * Creates a multiview render target
  79440. * @param scene scene used with the render target
  79441. * @param size the size of the render target (used for each view)
  79442. */
  79443. constructor(scene: Scene, size?: number | {
  79444. width: number;
  79445. height: number;
  79446. } | {
  79447. ratio: number;
  79448. });
  79449. /**
  79450. * @hidden
  79451. * @param faceIndex the face index, if its a cube texture
  79452. */
  79453. _bindFrameBuffer(faceIndex?: number): void;
  79454. /**
  79455. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79456. * @returns the view count
  79457. */
  79458. getViewCount(): number;
  79459. }
  79460. }
  79461. declare module BABYLON {
  79462. /**
  79463. * Reprasents a camera frustum
  79464. */
  79465. export class Frustum {
  79466. /**
  79467. * Gets the planes representing the frustum
  79468. * @param transform matrix to be applied to the returned planes
  79469. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  79470. */
  79471. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  79472. /**
  79473. * Gets the near frustum plane transformed by the transform matrix
  79474. * @param transform transformation matrix to be applied to the resulting frustum plane
  79475. * @param frustumPlane the resuling frustum plane
  79476. */
  79477. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79478. /**
  79479. * Gets the far frustum plane transformed by the transform matrix
  79480. * @param transform transformation matrix to be applied to the resulting frustum plane
  79481. * @param frustumPlane the resuling frustum plane
  79482. */
  79483. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79484. /**
  79485. * Gets the left frustum plane transformed by the transform matrix
  79486. * @param transform transformation matrix to be applied to the resulting frustum plane
  79487. * @param frustumPlane the resuling frustum plane
  79488. */
  79489. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79490. /**
  79491. * Gets the right frustum plane transformed by the transform matrix
  79492. * @param transform transformation matrix to be applied to the resulting frustum plane
  79493. * @param frustumPlane the resuling frustum plane
  79494. */
  79495. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79496. /**
  79497. * Gets the top frustum plane transformed by the transform matrix
  79498. * @param transform transformation matrix to be applied to the resulting frustum plane
  79499. * @param frustumPlane the resuling frustum plane
  79500. */
  79501. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79502. /**
  79503. * Gets the bottom frustum plane transformed by the transform matrix
  79504. * @param transform transformation matrix to be applied to the resulting frustum plane
  79505. * @param frustumPlane the resuling frustum plane
  79506. */
  79507. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79508. /**
  79509. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  79510. * @param transform transformation matrix to be applied to the resulting frustum planes
  79511. * @param frustumPlanes the resuling frustum planes
  79512. */
  79513. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  79514. }
  79515. }
  79516. declare module BABYLON {
  79517. interface Engine {
  79518. /**
  79519. * Creates a new multiview render target
  79520. * @param width defines the width of the texture
  79521. * @param height defines the height of the texture
  79522. * @returns the created multiview texture
  79523. */
  79524. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  79525. /**
  79526. * Binds a multiview framebuffer to be drawn to
  79527. * @param multiviewTexture texture to bind
  79528. */
  79529. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  79530. }
  79531. interface Camera {
  79532. /**
  79533. * @hidden
  79534. * 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)
  79535. */
  79536. _useMultiviewToSingleView: boolean;
  79537. /**
  79538. * @hidden
  79539. * 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)
  79540. */
  79541. _multiviewTexture: Nullable<RenderTargetTexture>;
  79542. /**
  79543. * @hidden
  79544. * ensures the multiview texture of the camera exists and has the specified width/height
  79545. * @param width height to set on the multiview texture
  79546. * @param height width to set on the multiview texture
  79547. */
  79548. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  79549. }
  79550. interface Scene {
  79551. /** @hidden */
  79552. _transformMatrixR: Matrix;
  79553. /** @hidden */
  79554. _multiviewSceneUbo: Nullable<UniformBuffer>;
  79555. /** @hidden */
  79556. _createMultiviewUbo(): void;
  79557. /** @hidden */
  79558. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  79559. /** @hidden */
  79560. _renderMultiviewToSingleView(camera: Camera): void;
  79561. }
  79562. }
  79563. declare module BABYLON {
  79564. /**
  79565. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  79566. * This will not be used for webXR as it supports displaying texture arrays directly
  79567. */
  79568. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  79569. /**
  79570. * Initializes a VRMultiviewToSingleview
  79571. * @param name name of the post process
  79572. * @param camera camera to be applied to
  79573. * @param scaleFactor scaling factor to the size of the output texture
  79574. */
  79575. constructor(name: string, camera: Camera, scaleFactor: number);
  79576. }
  79577. }
  79578. declare module BABYLON {
  79579. interface Engine {
  79580. /** @hidden */
  79581. _vrDisplay: any;
  79582. /** @hidden */
  79583. _vrSupported: boolean;
  79584. /** @hidden */
  79585. _oldSize: Size;
  79586. /** @hidden */
  79587. _oldHardwareScaleFactor: number;
  79588. /** @hidden */
  79589. _vrExclusivePointerMode: boolean;
  79590. /** @hidden */
  79591. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  79592. /** @hidden */
  79593. _onVRDisplayPointerRestricted: () => void;
  79594. /** @hidden */
  79595. _onVRDisplayPointerUnrestricted: () => void;
  79596. /** @hidden */
  79597. _onVrDisplayConnect: Nullable<(display: any) => void>;
  79598. /** @hidden */
  79599. _onVrDisplayDisconnect: Nullable<() => void>;
  79600. /** @hidden */
  79601. _onVrDisplayPresentChange: Nullable<() => void>;
  79602. /**
  79603. * Observable signaled when VR display mode changes
  79604. */
  79605. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  79606. /**
  79607. * Observable signaled when VR request present is complete
  79608. */
  79609. onVRRequestPresentComplete: Observable<boolean>;
  79610. /**
  79611. * Observable signaled when VR request present starts
  79612. */
  79613. onVRRequestPresentStart: Observable<Engine>;
  79614. /**
  79615. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  79616. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  79617. */
  79618. isInVRExclusivePointerMode: boolean;
  79619. /**
  79620. * Gets a boolean indicating if a webVR device was detected
  79621. * @returns true if a webVR device was detected
  79622. */
  79623. isVRDevicePresent(): boolean;
  79624. /**
  79625. * Gets the current webVR device
  79626. * @returns the current webVR device (or null)
  79627. */
  79628. getVRDevice(): any;
  79629. /**
  79630. * Initializes a webVR display and starts listening to display change events
  79631. * The onVRDisplayChangedObservable will be notified upon these changes
  79632. * @returns A promise containing a VRDisplay and if vr is supported
  79633. */
  79634. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  79635. /** @hidden */
  79636. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  79637. /**
  79638. * Call this function to switch to webVR mode
  79639. * Will do nothing if webVR is not supported or if there is no webVR device
  79640. * @see http://doc.babylonjs.com/how_to/webvr_camera
  79641. */
  79642. enableVR(): void;
  79643. /** @hidden */
  79644. _onVRFullScreenTriggered(): void;
  79645. }
  79646. }
  79647. declare module BABYLON {
  79648. /**
  79649. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  79650. * IMPORTANT!! The data is right-hand data.
  79651. * @export
  79652. * @interface DevicePose
  79653. */
  79654. export interface DevicePose {
  79655. /**
  79656. * The position of the device, values in array are [x,y,z].
  79657. */
  79658. readonly position: Nullable<Float32Array>;
  79659. /**
  79660. * The linearVelocity of the device, values in array are [x,y,z].
  79661. */
  79662. readonly linearVelocity: Nullable<Float32Array>;
  79663. /**
  79664. * The linearAcceleration of the device, values in array are [x,y,z].
  79665. */
  79666. readonly linearAcceleration: Nullable<Float32Array>;
  79667. /**
  79668. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  79669. */
  79670. readonly orientation: Nullable<Float32Array>;
  79671. /**
  79672. * The angularVelocity of the device, values in array are [x,y,z].
  79673. */
  79674. readonly angularVelocity: Nullable<Float32Array>;
  79675. /**
  79676. * The angularAcceleration of the device, values in array are [x,y,z].
  79677. */
  79678. readonly angularAcceleration: Nullable<Float32Array>;
  79679. }
  79680. /**
  79681. * Interface representing a pose controlled object in Babylon.
  79682. * A pose controlled object has both regular pose values as well as pose values
  79683. * from an external device such as a VR head mounted display
  79684. */
  79685. export interface PoseControlled {
  79686. /**
  79687. * The position of the object in babylon space.
  79688. */
  79689. position: Vector3;
  79690. /**
  79691. * The rotation quaternion of the object in babylon space.
  79692. */
  79693. rotationQuaternion: Quaternion;
  79694. /**
  79695. * The position of the device in babylon space.
  79696. */
  79697. devicePosition?: Vector3;
  79698. /**
  79699. * The rotation quaternion of the device in babylon space.
  79700. */
  79701. deviceRotationQuaternion: Quaternion;
  79702. /**
  79703. * The raw pose coming from the device.
  79704. */
  79705. rawPose: Nullable<DevicePose>;
  79706. /**
  79707. * The scale of the device to be used when translating from device space to babylon space.
  79708. */
  79709. deviceScaleFactor: number;
  79710. /**
  79711. * Updates the poseControlled values based on the input device pose.
  79712. * @param poseData the pose data to update the object with
  79713. */
  79714. updateFromDevice(poseData: DevicePose): void;
  79715. }
  79716. /**
  79717. * Set of options to customize the webVRCamera
  79718. */
  79719. export interface WebVROptions {
  79720. /**
  79721. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  79722. */
  79723. trackPosition?: boolean;
  79724. /**
  79725. * Sets the scale of the vrDevice in babylon space. (default: 1)
  79726. */
  79727. positionScale?: number;
  79728. /**
  79729. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  79730. */
  79731. displayName?: string;
  79732. /**
  79733. * Should the native controller meshes be initialized. (default: true)
  79734. */
  79735. controllerMeshes?: boolean;
  79736. /**
  79737. * Creating a default HemiLight only on controllers. (default: true)
  79738. */
  79739. defaultLightingOnControllers?: boolean;
  79740. /**
  79741. * If you don't want to use the default VR button of the helper. (default: false)
  79742. */
  79743. useCustomVRButton?: boolean;
  79744. /**
  79745. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  79746. */
  79747. customVRButton?: HTMLButtonElement;
  79748. /**
  79749. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  79750. */
  79751. rayLength?: number;
  79752. /**
  79753. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  79754. */
  79755. defaultHeight?: number;
  79756. /**
  79757. * If multiview should be used if availible (default: false)
  79758. */
  79759. useMultiview?: boolean;
  79760. }
  79761. /**
  79762. * This represents a WebVR camera.
  79763. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  79764. * @example http://doc.babylonjs.com/how_to/webvr_camera
  79765. */
  79766. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  79767. private webVROptions;
  79768. /**
  79769. * @hidden
  79770. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  79771. */
  79772. _vrDevice: any;
  79773. /**
  79774. * The rawPose of the vrDevice.
  79775. */
  79776. rawPose: Nullable<DevicePose>;
  79777. private _onVREnabled;
  79778. private _specsVersion;
  79779. private _attached;
  79780. private _frameData;
  79781. protected _descendants: Array<Node>;
  79782. private _deviceRoomPosition;
  79783. /** @hidden */
  79784. _deviceRoomRotationQuaternion: Quaternion;
  79785. private _standingMatrix;
  79786. /**
  79787. * Represents device position in babylon space.
  79788. */
  79789. devicePosition: Vector3;
  79790. /**
  79791. * Represents device rotation in babylon space.
  79792. */
  79793. deviceRotationQuaternion: Quaternion;
  79794. /**
  79795. * The scale of the device to be used when translating from device space to babylon space.
  79796. */
  79797. deviceScaleFactor: number;
  79798. private _deviceToWorld;
  79799. private _worldToDevice;
  79800. /**
  79801. * References to the webVR controllers for the vrDevice.
  79802. */
  79803. controllers: Array<WebVRController>;
  79804. /**
  79805. * Emits an event when a controller is attached.
  79806. */
  79807. onControllersAttachedObservable: Observable<WebVRController[]>;
  79808. /**
  79809. * Emits an event when a controller's mesh has been loaded;
  79810. */
  79811. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79812. /**
  79813. * Emits an event when the HMD's pose has been updated.
  79814. */
  79815. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79816. private _poseSet;
  79817. /**
  79818. * If the rig cameras be used as parent instead of this camera.
  79819. */
  79820. rigParenting: boolean;
  79821. private _lightOnControllers;
  79822. private _defaultHeight?;
  79823. /**
  79824. * Instantiates a WebVRFreeCamera.
  79825. * @param name The name of the WebVRFreeCamera
  79826. * @param position The starting anchor position for the camera
  79827. * @param scene The scene the camera belongs to
  79828. * @param webVROptions a set of customizable options for the webVRCamera
  79829. */
  79830. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79831. /**
  79832. * Gets the device distance from the ground in meters.
  79833. * @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.
  79834. */
  79835. deviceDistanceToRoomGround(): number;
  79836. /**
  79837. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79838. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79839. */
  79840. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79841. /**
  79842. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79843. * @returns A promise with a boolean set to if the standing matrix is supported.
  79844. */
  79845. useStandingMatrixAsync(): Promise<boolean>;
  79846. /**
  79847. * Disposes the camera
  79848. */
  79849. dispose(): void;
  79850. /**
  79851. * Gets a vrController by name.
  79852. * @param name The name of the controller to retreive
  79853. * @returns the controller matching the name specified or null if not found
  79854. */
  79855. getControllerByName(name: string): Nullable<WebVRController>;
  79856. private _leftController;
  79857. /**
  79858. * The controller corresponding to the users left hand.
  79859. */
  79860. readonly leftController: Nullable<WebVRController>;
  79861. private _rightController;
  79862. /**
  79863. * The controller corresponding to the users right hand.
  79864. */
  79865. readonly rightController: Nullable<WebVRController>;
  79866. /**
  79867. * Casts a ray forward from the vrCamera's gaze.
  79868. * @param length Length of the ray (default: 100)
  79869. * @returns the ray corresponding to the gaze
  79870. */
  79871. getForwardRay(length?: number): Ray;
  79872. /**
  79873. * @hidden
  79874. * Updates the camera based on device's frame data
  79875. */
  79876. _checkInputs(): void;
  79877. /**
  79878. * Updates the poseControlled values based on the input device pose.
  79879. * @param poseData Pose coming from the device
  79880. */
  79881. updateFromDevice(poseData: DevicePose): void;
  79882. private _htmlElementAttached;
  79883. private _detachIfAttached;
  79884. /**
  79885. * WebVR's attach control will start broadcasting frames to the device.
  79886. * Note that in certain browsers (chrome for example) this function must be called
  79887. * within a user-interaction callback. Example:
  79888. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  79889. *
  79890. * @param element html element to attach the vrDevice to
  79891. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  79892. */
  79893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79894. /**
  79895. * Detaches the camera from the html element and disables VR
  79896. *
  79897. * @param element html element to detach from
  79898. */
  79899. detachControl(element: HTMLElement): void;
  79900. /**
  79901. * @returns the name of this class
  79902. */
  79903. getClassName(): string;
  79904. /**
  79905. * Calls resetPose on the vrDisplay
  79906. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  79907. */
  79908. resetToCurrentRotation(): void;
  79909. /**
  79910. * @hidden
  79911. * Updates the rig cameras (left and right eye)
  79912. */
  79913. _updateRigCameras(): void;
  79914. private _workingVector;
  79915. private _oneVector;
  79916. private _workingMatrix;
  79917. private updateCacheCalled;
  79918. private _correctPositionIfNotTrackPosition;
  79919. /**
  79920. * @hidden
  79921. * Updates the cached values of the camera
  79922. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  79923. */
  79924. _updateCache(ignoreParentClass?: boolean): void;
  79925. /**
  79926. * @hidden
  79927. * Get current device position in babylon world
  79928. */
  79929. _computeDevicePosition(): void;
  79930. /**
  79931. * Updates the current device position and rotation in the babylon world
  79932. */
  79933. update(): void;
  79934. /**
  79935. * @hidden
  79936. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  79937. * @returns an identity matrix
  79938. */
  79939. _getViewMatrix(): Matrix;
  79940. private _tmpMatrix;
  79941. /**
  79942. * This function is called by the two RIG cameras.
  79943. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  79944. * @hidden
  79945. */
  79946. _getWebVRViewMatrix(): Matrix;
  79947. /** @hidden */
  79948. _getWebVRProjectionMatrix(): Matrix;
  79949. private _onGamepadConnectedObserver;
  79950. private _onGamepadDisconnectedObserver;
  79951. private _updateCacheWhenTrackingDisabledObserver;
  79952. /**
  79953. * Initializes the controllers and their meshes
  79954. */
  79955. initControllers(): void;
  79956. }
  79957. }
  79958. declare module BABYLON {
  79959. /**
  79960. * Size options for a post process
  79961. */
  79962. export type PostProcessOptions = {
  79963. width: number;
  79964. height: number;
  79965. };
  79966. /**
  79967. * PostProcess can be used to apply a shader to a texture after it has been rendered
  79968. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79969. */
  79970. export class PostProcess {
  79971. /** Name of the PostProcess. */
  79972. name: string;
  79973. /**
  79974. * Gets or sets the unique id of the post process
  79975. */
  79976. uniqueId: number;
  79977. /**
  79978. * Width of the texture to apply the post process on
  79979. */
  79980. width: number;
  79981. /**
  79982. * Height of the texture to apply the post process on
  79983. */
  79984. height: number;
  79985. /**
  79986. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  79987. * @hidden
  79988. */
  79989. _outputTexture: Nullable<InternalTexture>;
  79990. /**
  79991. * Sampling mode used by the shader
  79992. * See https://doc.babylonjs.com/classes/3.1/texture
  79993. */
  79994. renderTargetSamplingMode: number;
  79995. /**
  79996. * Clear color to use when screen clearing
  79997. */
  79998. clearColor: Color4;
  79999. /**
  80000. * If the buffer needs to be cleared before applying the post process. (default: true)
  80001. * Should be set to false if shader will overwrite all previous pixels.
  80002. */
  80003. autoClear: boolean;
  80004. /**
  80005. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80006. */
  80007. alphaMode: number;
  80008. /**
  80009. * Sets the setAlphaBlendConstants of the babylon engine
  80010. */
  80011. alphaConstants: Color4;
  80012. /**
  80013. * Animations to be used for the post processing
  80014. */
  80015. animations: Animation[];
  80016. /**
  80017. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80018. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80019. */
  80020. enablePixelPerfectMode: boolean;
  80021. /**
  80022. * Force the postprocess to be applied without taking in account viewport
  80023. */
  80024. forceFullscreenViewport: boolean;
  80025. /**
  80026. * List of inspectable custom properties (used by the Inspector)
  80027. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80028. */
  80029. inspectableCustomProperties: IInspectable[];
  80030. /**
  80031. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80032. *
  80033. * | Value | Type | Description |
  80034. * | ----- | ----------------------------------- | ----------- |
  80035. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80036. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80037. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80038. *
  80039. */
  80040. scaleMode: number;
  80041. /**
  80042. * Force textures to be a power of two (default: false)
  80043. */
  80044. alwaysForcePOT: boolean;
  80045. private _samples;
  80046. /**
  80047. * Number of sample textures (default: 1)
  80048. */
  80049. samples: number;
  80050. /**
  80051. * Modify the scale of the post process to be the same as the viewport (default: false)
  80052. */
  80053. adaptScaleToCurrentViewport: boolean;
  80054. private _camera;
  80055. private _scene;
  80056. private _engine;
  80057. private _options;
  80058. private _reusable;
  80059. private _textureType;
  80060. /**
  80061. * Smart array of input and output textures for the post process.
  80062. * @hidden
  80063. */
  80064. _textures: SmartArray<InternalTexture>;
  80065. /**
  80066. * The index in _textures that corresponds to the output texture.
  80067. * @hidden
  80068. */
  80069. _currentRenderTextureInd: number;
  80070. private _effect;
  80071. private _samplers;
  80072. private _fragmentUrl;
  80073. private _vertexUrl;
  80074. private _parameters;
  80075. private _scaleRatio;
  80076. protected _indexParameters: any;
  80077. private _shareOutputWithPostProcess;
  80078. private _texelSize;
  80079. private _forcedOutputTexture;
  80080. /**
  80081. * Returns the fragment url or shader name used in the post process.
  80082. * @returns the fragment url or name in the shader store.
  80083. */
  80084. getEffectName(): string;
  80085. /**
  80086. * An event triggered when the postprocess is activated.
  80087. */
  80088. onActivateObservable: Observable<Camera>;
  80089. private _onActivateObserver;
  80090. /**
  80091. * A function that is added to the onActivateObservable
  80092. */
  80093. onActivate: Nullable<(camera: Camera) => void>;
  80094. /**
  80095. * An event triggered when the postprocess changes its size.
  80096. */
  80097. onSizeChangedObservable: Observable<PostProcess>;
  80098. private _onSizeChangedObserver;
  80099. /**
  80100. * A function that is added to the onSizeChangedObservable
  80101. */
  80102. onSizeChanged: (postProcess: PostProcess) => void;
  80103. /**
  80104. * An event triggered when the postprocess applies its effect.
  80105. */
  80106. onApplyObservable: Observable<Effect>;
  80107. private _onApplyObserver;
  80108. /**
  80109. * A function that is added to the onApplyObservable
  80110. */
  80111. onApply: (effect: Effect) => void;
  80112. /**
  80113. * An event triggered before rendering the postprocess
  80114. */
  80115. onBeforeRenderObservable: Observable<Effect>;
  80116. private _onBeforeRenderObserver;
  80117. /**
  80118. * A function that is added to the onBeforeRenderObservable
  80119. */
  80120. onBeforeRender: (effect: Effect) => void;
  80121. /**
  80122. * An event triggered after rendering the postprocess
  80123. */
  80124. onAfterRenderObservable: Observable<Effect>;
  80125. private _onAfterRenderObserver;
  80126. /**
  80127. * A function that is added to the onAfterRenderObservable
  80128. */
  80129. onAfterRender: (efect: Effect) => void;
  80130. /**
  80131. * 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
  80132. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80133. */
  80134. inputTexture: InternalTexture;
  80135. /**
  80136. * Gets the camera which post process is applied to.
  80137. * @returns The camera the post process is applied to.
  80138. */
  80139. getCamera(): Camera;
  80140. /**
  80141. * Gets the texel size of the postprocess.
  80142. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80143. */
  80144. readonly texelSize: Vector2;
  80145. /**
  80146. * Creates a new instance PostProcess
  80147. * @param name The name of the PostProcess.
  80148. * @param fragmentUrl The url of the fragment shader to be used.
  80149. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80150. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80151. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80152. * @param camera The camera to apply the render pass to.
  80153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80154. * @param engine The engine which the post process will be applied. (default: current engine)
  80155. * @param reusable If the post process can be reused on the same frame. (default: false)
  80156. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80157. * @param textureType Type of textures used when performing the post process. (default: 0)
  80158. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80159. * @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
  80160. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80161. */
  80162. constructor(
  80163. /** Name of the PostProcess. */
  80164. 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);
  80165. /**
  80166. * Gets a string idenfifying the name of the class
  80167. * @returns "PostProcess" string
  80168. */
  80169. getClassName(): string;
  80170. /**
  80171. * Gets the engine which this post process belongs to.
  80172. * @returns The engine the post process was enabled with.
  80173. */
  80174. getEngine(): Engine;
  80175. /**
  80176. * The effect that is created when initializing the post process.
  80177. * @returns The created effect corresponding the the postprocess.
  80178. */
  80179. getEffect(): Effect;
  80180. /**
  80181. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80182. * @param postProcess The post process to share the output with.
  80183. * @returns This post process.
  80184. */
  80185. shareOutputWith(postProcess: PostProcess): PostProcess;
  80186. /**
  80187. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80188. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80189. */
  80190. useOwnOutput(): void;
  80191. /**
  80192. * Updates the effect with the current post process compile time values and recompiles the shader.
  80193. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80194. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80195. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80196. * @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
  80197. * @param onCompiled Called when the shader has been compiled.
  80198. * @param onError Called if there is an error when compiling a shader.
  80199. */
  80200. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80201. /**
  80202. * The post process is reusable if it can be used multiple times within one frame.
  80203. * @returns If the post process is reusable
  80204. */
  80205. isReusable(): boolean;
  80206. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80207. markTextureDirty(): void;
  80208. /**
  80209. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80210. * 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.
  80211. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80212. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80213. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80214. * @returns The target texture that was bound to be written to.
  80215. */
  80216. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80217. /**
  80218. * If the post process is supported.
  80219. */
  80220. readonly isSupported: boolean;
  80221. /**
  80222. * The aspect ratio of the output texture.
  80223. */
  80224. readonly aspectRatio: number;
  80225. /**
  80226. * Get a value indicating if the post-process is ready to be used
  80227. * @returns true if the post-process is ready (shader is compiled)
  80228. */
  80229. isReady(): boolean;
  80230. /**
  80231. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80232. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80233. */
  80234. apply(): Nullable<Effect>;
  80235. private _disposeTextures;
  80236. /**
  80237. * Disposes the post process.
  80238. * @param camera The camera to dispose the post process on.
  80239. */
  80240. dispose(camera?: Camera): void;
  80241. }
  80242. }
  80243. declare module BABYLON {
  80244. /** @hidden */
  80245. export var kernelBlurVaryingDeclaration: {
  80246. name: string;
  80247. shader: string;
  80248. };
  80249. }
  80250. declare module BABYLON {
  80251. /** @hidden */
  80252. export var kernelBlurFragment: {
  80253. name: string;
  80254. shader: string;
  80255. };
  80256. }
  80257. declare module BABYLON {
  80258. /** @hidden */
  80259. export var kernelBlurFragment2: {
  80260. name: string;
  80261. shader: string;
  80262. };
  80263. }
  80264. declare module BABYLON {
  80265. /** @hidden */
  80266. export var kernelBlurPixelShader: {
  80267. name: string;
  80268. shader: string;
  80269. };
  80270. }
  80271. declare module BABYLON {
  80272. /** @hidden */
  80273. export var kernelBlurVertex: {
  80274. name: string;
  80275. shader: string;
  80276. };
  80277. }
  80278. declare module BABYLON {
  80279. /** @hidden */
  80280. export var kernelBlurVertexShader: {
  80281. name: string;
  80282. shader: string;
  80283. };
  80284. }
  80285. declare module BABYLON {
  80286. /**
  80287. * The Blur Post Process which blurs an image based on a kernel and direction.
  80288. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80289. */
  80290. export class BlurPostProcess extends PostProcess {
  80291. /** The direction in which to blur the image. */
  80292. direction: Vector2;
  80293. private blockCompilation;
  80294. protected _kernel: number;
  80295. protected _idealKernel: number;
  80296. protected _packedFloat: boolean;
  80297. private _staticDefines;
  80298. /**
  80299. * Sets the length in pixels of the blur sample region
  80300. */
  80301. /**
  80302. * Gets the length in pixels of the blur sample region
  80303. */
  80304. kernel: number;
  80305. /**
  80306. * Sets wether or not the blur needs to unpack/repack floats
  80307. */
  80308. /**
  80309. * Gets wether or not the blur is unpacking/repacking floats
  80310. */
  80311. packedFloat: boolean;
  80312. /**
  80313. * Creates a new instance BlurPostProcess
  80314. * @param name The name of the effect.
  80315. * @param direction The direction in which to blur the image.
  80316. * @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.
  80317. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80318. * @param camera The camera to apply the render pass to.
  80319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80320. * @param engine The engine which the post process will be applied. (default: current engine)
  80321. * @param reusable If the post process can be reused on the same frame. (default: false)
  80322. * @param textureType Type of textures used when performing the post process. (default: 0)
  80323. * @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)
  80324. */
  80325. constructor(name: string,
  80326. /** The direction in which to blur the image. */
  80327. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80328. /**
  80329. * Updates the effect with the current post process compile time values and recompiles the shader.
  80330. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80331. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80332. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80333. * @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
  80334. * @param onCompiled Called when the shader has been compiled.
  80335. * @param onError Called if there is an error when compiling a shader.
  80336. */
  80337. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80338. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80339. /**
  80340. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80341. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80342. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80343. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80344. * The gaps between physical kernels are compensated for in the weighting of the samples
  80345. * @param idealKernel Ideal blur kernel.
  80346. * @return Nearest best kernel.
  80347. */
  80348. protected _nearestBestKernel(idealKernel: number): number;
  80349. /**
  80350. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80351. * @param x The point on the Gaussian distribution to sample.
  80352. * @return the value of the Gaussian function at x.
  80353. */
  80354. protected _gaussianWeight(x: number): number;
  80355. /**
  80356. * Generates a string that can be used as a floating point number in GLSL.
  80357. * @param x Value to print.
  80358. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80359. * @return GLSL float string.
  80360. */
  80361. protected _glslFloat(x: number, decimalFigures?: number): string;
  80362. }
  80363. }
  80364. declare module BABYLON {
  80365. /**
  80366. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80367. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80368. * You can then easily use it as a reflectionTexture on a flat surface.
  80369. * In case the surface is not a plane, please consider relying on reflection probes.
  80370. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80371. */
  80372. export class MirrorTexture extends RenderTargetTexture {
  80373. private scene;
  80374. /**
  80375. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80376. * 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.
  80377. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80378. */
  80379. mirrorPlane: Plane;
  80380. /**
  80381. * Define the blur ratio used to blur the reflection if needed.
  80382. */
  80383. blurRatio: number;
  80384. /**
  80385. * Define the adaptive blur kernel used to blur the reflection if needed.
  80386. * This will autocompute the closest best match for the `blurKernel`
  80387. */
  80388. adaptiveBlurKernel: number;
  80389. /**
  80390. * Define the blur kernel used to blur the reflection if needed.
  80391. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80392. */
  80393. blurKernel: number;
  80394. /**
  80395. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80396. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80397. */
  80398. blurKernelX: number;
  80399. /**
  80400. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80401. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80402. */
  80403. blurKernelY: number;
  80404. private _autoComputeBlurKernel;
  80405. protected _onRatioRescale(): void;
  80406. private _updateGammaSpace;
  80407. private _imageProcessingConfigChangeObserver;
  80408. private _transformMatrix;
  80409. private _mirrorMatrix;
  80410. private _savedViewMatrix;
  80411. private _blurX;
  80412. private _blurY;
  80413. private _adaptiveBlurKernel;
  80414. private _blurKernelX;
  80415. private _blurKernelY;
  80416. private _blurRatio;
  80417. /**
  80418. * Instantiates a Mirror Texture.
  80419. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80420. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80421. * You can then easily use it as a reflectionTexture on a flat surface.
  80422. * In case the surface is not a plane, please consider relying on reflection probes.
  80423. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80424. * @param name
  80425. * @param size
  80426. * @param scene
  80427. * @param generateMipMaps
  80428. * @param type
  80429. * @param samplingMode
  80430. * @param generateDepthBuffer
  80431. */
  80432. constructor(name: string, size: number | {
  80433. width: number;
  80434. height: number;
  80435. } | {
  80436. ratio: number;
  80437. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80438. private _preparePostProcesses;
  80439. /**
  80440. * Clone the mirror texture.
  80441. * @returns the cloned texture
  80442. */
  80443. clone(): MirrorTexture;
  80444. /**
  80445. * Serialize the texture to a JSON representation you could use in Parse later on
  80446. * @returns the serialized JSON representation
  80447. */
  80448. serialize(): any;
  80449. /**
  80450. * Dispose the texture and release its associated resources.
  80451. */
  80452. dispose(): void;
  80453. }
  80454. }
  80455. declare module BABYLON {
  80456. /**
  80457. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80458. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80459. */
  80460. export class Texture extends BaseTexture {
  80461. /** @hidden */
  80462. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80463. /** @hidden */
  80464. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80465. /** @hidden */
  80466. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80467. /** nearest is mag = nearest and min = nearest and mip = linear */
  80468. static readonly NEAREST_SAMPLINGMODE: number;
  80469. /** nearest is mag = nearest and min = nearest and mip = linear */
  80470. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80471. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80472. static readonly BILINEAR_SAMPLINGMODE: number;
  80473. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80474. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80475. /** Trilinear is mag = linear and min = linear and mip = linear */
  80476. static readonly TRILINEAR_SAMPLINGMODE: number;
  80477. /** Trilinear is mag = linear and min = linear and mip = linear */
  80478. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80479. /** mag = nearest and min = nearest and mip = nearest */
  80480. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80481. /** mag = nearest and min = linear and mip = nearest */
  80482. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80483. /** mag = nearest and min = linear and mip = linear */
  80484. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80485. /** mag = nearest and min = linear and mip = none */
  80486. static readonly NEAREST_LINEAR: number;
  80487. /** mag = nearest and min = nearest and mip = none */
  80488. static readonly NEAREST_NEAREST: number;
  80489. /** mag = linear and min = nearest and mip = nearest */
  80490. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80491. /** mag = linear and min = nearest and mip = linear */
  80492. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80493. /** mag = linear and min = linear and mip = none */
  80494. static readonly LINEAR_LINEAR: number;
  80495. /** mag = linear and min = nearest and mip = none */
  80496. static readonly LINEAR_NEAREST: number;
  80497. /** Explicit coordinates mode */
  80498. static readonly EXPLICIT_MODE: number;
  80499. /** Spherical coordinates mode */
  80500. static readonly SPHERICAL_MODE: number;
  80501. /** Planar coordinates mode */
  80502. static readonly PLANAR_MODE: number;
  80503. /** Cubic coordinates mode */
  80504. static readonly CUBIC_MODE: number;
  80505. /** Projection coordinates mode */
  80506. static readonly PROJECTION_MODE: number;
  80507. /** Inverse Cubic coordinates mode */
  80508. static readonly SKYBOX_MODE: number;
  80509. /** Inverse Cubic coordinates mode */
  80510. static readonly INVCUBIC_MODE: number;
  80511. /** Equirectangular coordinates mode */
  80512. static readonly EQUIRECTANGULAR_MODE: number;
  80513. /** Equirectangular Fixed coordinates mode */
  80514. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80515. /** Equirectangular Fixed Mirrored coordinates mode */
  80516. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80517. /** Texture is not repeating outside of 0..1 UVs */
  80518. static readonly CLAMP_ADDRESSMODE: number;
  80519. /** Texture is repeating outside of 0..1 UVs */
  80520. static readonly WRAP_ADDRESSMODE: number;
  80521. /** Texture is repeating and mirrored */
  80522. static readonly MIRROR_ADDRESSMODE: number;
  80523. /**
  80524. * 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
  80525. */
  80526. static UseSerializedUrlIfAny: boolean;
  80527. /**
  80528. * Define the url of the texture.
  80529. */
  80530. url: Nullable<string>;
  80531. /**
  80532. * Define an offset on the texture to offset the u coordinates of the UVs
  80533. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80534. */
  80535. uOffset: number;
  80536. /**
  80537. * Define an offset on the texture to offset the v coordinates of the UVs
  80538. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80539. */
  80540. vOffset: number;
  80541. /**
  80542. * Define an offset on the texture to scale the u coordinates of the UVs
  80543. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80544. */
  80545. uScale: number;
  80546. /**
  80547. * Define an offset on the texture to scale the v coordinates of the UVs
  80548. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80549. */
  80550. vScale: number;
  80551. /**
  80552. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80553. * @see http://doc.babylonjs.com/how_to/more_materials
  80554. */
  80555. uAng: number;
  80556. /**
  80557. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80558. * @see http://doc.babylonjs.com/how_to/more_materials
  80559. */
  80560. vAng: number;
  80561. /**
  80562. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80563. * @see http://doc.babylonjs.com/how_to/more_materials
  80564. */
  80565. wAng: number;
  80566. /**
  80567. * Defines the center of rotation (U)
  80568. */
  80569. uRotationCenter: number;
  80570. /**
  80571. * Defines the center of rotation (V)
  80572. */
  80573. vRotationCenter: number;
  80574. /**
  80575. * Defines the center of rotation (W)
  80576. */
  80577. wRotationCenter: number;
  80578. /**
  80579. * Are mip maps generated for this texture or not.
  80580. */
  80581. readonly noMipmap: boolean;
  80582. /**
  80583. * List of inspectable custom properties (used by the Inspector)
  80584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80585. */
  80586. inspectableCustomProperties: Nullable<IInspectable[]>;
  80587. private _noMipmap;
  80588. /** @hidden */
  80589. _invertY: boolean;
  80590. private _rowGenerationMatrix;
  80591. private _cachedTextureMatrix;
  80592. private _projectionModeMatrix;
  80593. private _t0;
  80594. private _t1;
  80595. private _t2;
  80596. private _cachedUOffset;
  80597. private _cachedVOffset;
  80598. private _cachedUScale;
  80599. private _cachedVScale;
  80600. private _cachedUAng;
  80601. private _cachedVAng;
  80602. private _cachedWAng;
  80603. private _cachedProjectionMatrixId;
  80604. private _cachedCoordinatesMode;
  80605. /** @hidden */
  80606. protected _initialSamplingMode: number;
  80607. /** @hidden */
  80608. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80609. private _deleteBuffer;
  80610. protected _format: Nullable<number>;
  80611. private _delayedOnLoad;
  80612. private _delayedOnError;
  80613. /**
  80614. * Observable triggered once the texture has been loaded.
  80615. */
  80616. onLoadObservable: Observable<Texture>;
  80617. protected _isBlocking: boolean;
  80618. /**
  80619. * Is the texture preventing material to render while loading.
  80620. * If false, a default texture will be used instead of the loading one during the preparation step.
  80621. */
  80622. isBlocking: boolean;
  80623. /**
  80624. * Get the current sampling mode associated with the texture.
  80625. */
  80626. readonly samplingMode: number;
  80627. /**
  80628. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80629. */
  80630. readonly invertY: boolean;
  80631. /**
  80632. * Instantiates a new texture.
  80633. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80634. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80635. * @param url define the url of the picture to load as a texture
  80636. * @param scene define the scene or engine the texture will belong to
  80637. * @param noMipmap define if the texture will require mip maps or not
  80638. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80639. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80640. * @param onLoad define a callback triggered when the texture has been loaded
  80641. * @param onError define a callback triggered when an error occurred during the loading session
  80642. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80643. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80644. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80645. */
  80646. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  80647. /**
  80648. * Update the url (and optional buffer) of this texture if url was null during construction.
  80649. * @param url the url of the texture
  80650. * @param buffer the buffer of the texture (defaults to null)
  80651. * @param onLoad callback called when the texture is loaded (defaults to null)
  80652. */
  80653. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80654. /**
  80655. * Finish the loading sequence of a texture flagged as delayed load.
  80656. * @hidden
  80657. */
  80658. delayLoad(): void;
  80659. private _prepareRowForTextureGeneration;
  80660. /**
  80661. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80662. * @returns the transform matrix of the texture.
  80663. */
  80664. getTextureMatrix(): Matrix;
  80665. /**
  80666. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80667. * @returns The reflection texture transform
  80668. */
  80669. getReflectionTextureMatrix(): Matrix;
  80670. /**
  80671. * Clones the texture.
  80672. * @returns the cloned texture
  80673. */
  80674. clone(): Texture;
  80675. /**
  80676. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80677. * @returns The JSON representation of the texture
  80678. */
  80679. serialize(): any;
  80680. /**
  80681. * Get the current class name of the texture useful for serialization or dynamic coding.
  80682. * @returns "Texture"
  80683. */
  80684. getClassName(): string;
  80685. /**
  80686. * Dispose the texture and release its associated resources.
  80687. */
  80688. dispose(): void;
  80689. /**
  80690. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80691. * @param parsedTexture Define the JSON representation of the texture
  80692. * @param scene Define the scene the parsed texture should be instantiated in
  80693. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80694. * @returns The parsed texture if successful
  80695. */
  80696. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80697. /**
  80698. * Creates a texture from its base 64 representation.
  80699. * @param data Define the base64 payload without the data: prefix
  80700. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80701. * @param scene Define the scene the texture should belong to
  80702. * @param noMipmap Forces the texture to not create mip map information if true
  80703. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80704. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80705. * @param onLoad define a callback triggered when the texture has been loaded
  80706. * @param onError define a callback triggered when an error occurred during the loading session
  80707. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80708. * @returns the created texture
  80709. */
  80710. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80711. /**
  80712. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80713. * @param data Define the base64 payload without the data: prefix
  80714. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80715. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80716. * @param scene Define the scene the texture should belong to
  80717. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80718. * @param noMipmap Forces the texture to not create mip map information if true
  80719. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80720. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80721. * @param onLoad define a callback triggered when the texture has been loaded
  80722. * @param onError define a callback triggered when an error occurred during the loading session
  80723. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80724. * @returns the created texture
  80725. */
  80726. 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;
  80727. }
  80728. }
  80729. declare module BABYLON {
  80730. /**
  80731. * PostProcessManager is used to manage one or more post processes or post process pipelines
  80732. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80733. */
  80734. export class PostProcessManager {
  80735. private _scene;
  80736. private _indexBuffer;
  80737. private _vertexBuffers;
  80738. /**
  80739. * Creates a new instance PostProcess
  80740. * @param scene The scene that the post process is associated with.
  80741. */
  80742. constructor(scene: Scene);
  80743. private _prepareBuffers;
  80744. private _buildIndexBuffer;
  80745. /**
  80746. * Rebuilds the vertex buffers of the manager.
  80747. * @hidden
  80748. */
  80749. _rebuild(): void;
  80750. /**
  80751. * Prepares a frame to be run through a post process.
  80752. * @param sourceTexture The input texture to the post procesess. (default: null)
  80753. * @param postProcesses An array of post processes to be run. (default: null)
  80754. * @returns True if the post processes were able to be run.
  80755. * @hidden
  80756. */
  80757. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  80758. /**
  80759. * Manually render a set of post processes to a texture.
  80760. * @param postProcesses An array of post processes to be run.
  80761. * @param targetTexture The target texture to render to.
  80762. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  80763. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  80764. * @param lodLevel defines which lod of the texture to render to
  80765. */
  80766. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  80767. /**
  80768. * Finalize the result of the output of the postprocesses.
  80769. * @param doNotPresent If true the result will not be displayed to the screen.
  80770. * @param targetTexture The target texture to render to.
  80771. * @param faceIndex The index of the face to bind the target texture to.
  80772. * @param postProcesses The array of post processes to render.
  80773. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80774. * @hidden
  80775. */
  80776. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80777. /**
  80778. * Disposes of the post process manager.
  80779. */
  80780. dispose(): void;
  80781. }
  80782. }
  80783. declare module BABYLON {
  80784. /** Interface used by value gradients (color, factor, ...) */
  80785. export interface IValueGradient {
  80786. /**
  80787. * Gets or sets the gradient value (between 0 and 1)
  80788. */
  80789. gradient: number;
  80790. }
  80791. /** Class used to store color4 gradient */
  80792. export class ColorGradient implements IValueGradient {
  80793. /**
  80794. * Gets or sets the gradient value (between 0 and 1)
  80795. */
  80796. gradient: number;
  80797. /**
  80798. * Gets or sets first associated color
  80799. */
  80800. color1: Color4;
  80801. /**
  80802. * Gets or sets second associated color
  80803. */
  80804. color2?: Color4;
  80805. /**
  80806. * Will get a color picked randomly between color1 and color2.
  80807. * If color2 is undefined then color1 will be used
  80808. * @param result defines the target Color4 to store the result in
  80809. */
  80810. getColorToRef(result: Color4): void;
  80811. }
  80812. /** Class used to store color 3 gradient */
  80813. export class Color3Gradient implements IValueGradient {
  80814. /**
  80815. * Gets or sets the gradient value (between 0 and 1)
  80816. */
  80817. gradient: number;
  80818. /**
  80819. * Gets or sets the associated color
  80820. */
  80821. color: Color3;
  80822. }
  80823. /** Class used to store factor gradient */
  80824. export class FactorGradient implements IValueGradient {
  80825. /**
  80826. * Gets or sets the gradient value (between 0 and 1)
  80827. */
  80828. gradient: number;
  80829. /**
  80830. * Gets or sets first associated factor
  80831. */
  80832. factor1: number;
  80833. /**
  80834. * Gets or sets second associated factor
  80835. */
  80836. factor2?: number;
  80837. /**
  80838. * Will get a number picked randomly between factor1 and factor2.
  80839. * If factor2 is undefined then factor1 will be used
  80840. * @returns the picked number
  80841. */
  80842. getFactor(): number;
  80843. }
  80844. /**
  80845. * Helper used to simplify some generic gradient tasks
  80846. */
  80847. export class GradientHelper {
  80848. /**
  80849. * Gets the current gradient from an array of IValueGradient
  80850. * @param ratio defines the current ratio to get
  80851. * @param gradients defines the array of IValueGradient
  80852. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  80853. */
  80854. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  80855. }
  80856. }
  80857. declare module BABYLON {
  80858. interface AbstractScene {
  80859. /**
  80860. * The list of procedural textures added to the scene
  80861. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80862. */
  80863. proceduralTextures: Array<ProceduralTexture>;
  80864. }
  80865. /**
  80866. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  80867. * in a given scene.
  80868. */
  80869. export class ProceduralTextureSceneComponent implements ISceneComponent {
  80870. /**
  80871. * The component name helpfull to identify the component in the list of scene components.
  80872. */
  80873. readonly name: string;
  80874. /**
  80875. * The scene the component belongs to.
  80876. */
  80877. scene: Scene;
  80878. /**
  80879. * Creates a new instance of the component for the given scene
  80880. * @param scene Defines the scene to register the component in
  80881. */
  80882. constructor(scene: Scene);
  80883. /**
  80884. * Registers the component in a given scene
  80885. */
  80886. register(): void;
  80887. /**
  80888. * Rebuilds the elements related to this component in case of
  80889. * context lost for instance.
  80890. */
  80891. rebuild(): void;
  80892. /**
  80893. * Disposes the component and the associated ressources.
  80894. */
  80895. dispose(): void;
  80896. private _beforeClear;
  80897. }
  80898. }
  80899. declare module BABYLON {
  80900. interface Engine {
  80901. /**
  80902. * Creates a new render target cube texture
  80903. * @param size defines the size of the texture
  80904. * @param options defines the options used to create the texture
  80905. * @returns a new render target cube texture stored in an InternalTexture
  80906. */
  80907. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  80908. }
  80909. }
  80910. declare module BABYLON {
  80911. /** @hidden */
  80912. export var proceduralVertexShader: {
  80913. name: string;
  80914. shader: string;
  80915. };
  80916. }
  80917. declare module BABYLON {
  80918. /**
  80919. * 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.
  80920. * This is the base class of any Procedural texture and contains most of the shareable code.
  80921. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80922. */
  80923. export class ProceduralTexture extends Texture {
  80924. isCube: boolean;
  80925. /**
  80926. * Define if the texture is enabled or not (disabled texture will not render)
  80927. */
  80928. isEnabled: boolean;
  80929. /**
  80930. * Define if the texture must be cleared before rendering (default is true)
  80931. */
  80932. autoClear: boolean;
  80933. /**
  80934. * Callback called when the texture is generated
  80935. */
  80936. onGenerated: () => void;
  80937. /**
  80938. * Event raised when the texture is generated
  80939. */
  80940. onGeneratedObservable: Observable<ProceduralTexture>;
  80941. /** @hidden */
  80942. _generateMipMaps: boolean;
  80943. /** @hidden **/
  80944. _effect: Effect;
  80945. /** @hidden */
  80946. _textures: {
  80947. [key: string]: Texture;
  80948. };
  80949. private _size;
  80950. private _currentRefreshId;
  80951. private _refreshRate;
  80952. private _vertexBuffers;
  80953. private _indexBuffer;
  80954. private _uniforms;
  80955. private _samplers;
  80956. private _fragment;
  80957. private _floats;
  80958. private _ints;
  80959. private _floatsArrays;
  80960. private _colors3;
  80961. private _colors4;
  80962. private _vectors2;
  80963. private _vectors3;
  80964. private _matrices;
  80965. private _fallbackTexture;
  80966. private _fallbackTextureUsed;
  80967. private _engine;
  80968. private _cachedDefines;
  80969. private _contentUpdateId;
  80970. private _contentData;
  80971. /**
  80972. * Instantiates a new procedural texture.
  80973. * 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.
  80974. * This is the base class of any Procedural texture and contains most of the shareable code.
  80975. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80976. * @param name Define the name of the texture
  80977. * @param size Define the size of the texture to create
  80978. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  80979. * @param scene Define the scene the texture belongs to
  80980. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  80981. * @param generateMipMaps Define if the texture should creates mip maps or not
  80982. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  80983. */
  80984. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  80985. /**
  80986. * The effect that is created when initializing the post process.
  80987. * @returns The created effect corresponding the the postprocess.
  80988. */
  80989. getEffect(): Effect;
  80990. /**
  80991. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  80992. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  80993. */
  80994. getContent(): Nullable<ArrayBufferView>;
  80995. private _createIndexBuffer;
  80996. /** @hidden */
  80997. _rebuild(): void;
  80998. /**
  80999. * Resets the texture in order to recreate its associated resources.
  81000. * This can be called in case of context loss
  81001. */
  81002. reset(): void;
  81003. protected _getDefines(): string;
  81004. /**
  81005. * Is the texture ready to be used ? (rendered at least once)
  81006. * @returns true if ready, otherwise, false.
  81007. */
  81008. isReady(): boolean;
  81009. /**
  81010. * Resets the refresh counter of the texture and start bak from scratch.
  81011. * Could be useful to regenerate the texture if it is setup to render only once.
  81012. */
  81013. resetRefreshCounter(): void;
  81014. /**
  81015. * Set the fragment shader to use in order to render the texture.
  81016. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81017. */
  81018. setFragment(fragment: any): void;
  81019. /**
  81020. * Define the refresh rate of the texture or the rendering frequency.
  81021. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81022. */
  81023. refreshRate: number;
  81024. /** @hidden */
  81025. _shouldRender(): boolean;
  81026. /**
  81027. * Get the size the texture is rendering at.
  81028. * @returns the size (texture is always squared)
  81029. */
  81030. getRenderSize(): number;
  81031. /**
  81032. * Resize the texture to new value.
  81033. * @param size Define the new size the texture should have
  81034. * @param generateMipMaps Define whether the new texture should create mip maps
  81035. */
  81036. resize(size: number, generateMipMaps: boolean): void;
  81037. private _checkUniform;
  81038. /**
  81039. * Set a texture in the shader program used to render.
  81040. * @param name Define the name of the uniform samplers as defined in the shader
  81041. * @param texture Define the texture to bind to this sampler
  81042. * @return the texture itself allowing "fluent" like uniform updates
  81043. */
  81044. setTexture(name: string, texture: Texture): ProceduralTexture;
  81045. /**
  81046. * Set a float in the shader.
  81047. * @param name Define the name of the uniform as defined in the shader
  81048. * @param value Define the value to give to the uniform
  81049. * @return the texture itself allowing "fluent" like uniform updates
  81050. */
  81051. setFloat(name: string, value: number): ProceduralTexture;
  81052. /**
  81053. * Set a int in the shader.
  81054. * @param name Define the name of the uniform as defined in the shader
  81055. * @param value Define the value to give to the uniform
  81056. * @return the texture itself allowing "fluent" like uniform updates
  81057. */
  81058. setInt(name: string, value: number): ProceduralTexture;
  81059. /**
  81060. * Set an array of floats in the shader.
  81061. * @param name Define the name of the uniform as defined in the shader
  81062. * @param value Define the value to give to the uniform
  81063. * @return the texture itself allowing "fluent" like uniform updates
  81064. */
  81065. setFloats(name: string, value: number[]): ProceduralTexture;
  81066. /**
  81067. * Set a vec3 in the shader from a Color3.
  81068. * @param name Define the name of the uniform as defined in the shader
  81069. * @param value Define the value to give to the uniform
  81070. * @return the texture itself allowing "fluent" like uniform updates
  81071. */
  81072. setColor3(name: string, value: Color3): ProceduralTexture;
  81073. /**
  81074. * Set a vec4 in the shader from a Color4.
  81075. * @param name Define the name of the uniform as defined in the shader
  81076. * @param value Define the value to give to the uniform
  81077. * @return the texture itself allowing "fluent" like uniform updates
  81078. */
  81079. setColor4(name: string, value: Color4): ProceduralTexture;
  81080. /**
  81081. * Set a vec2 in the shader from a Vector2.
  81082. * @param name Define the name of the uniform as defined in the shader
  81083. * @param value Define the value to give to the uniform
  81084. * @return the texture itself allowing "fluent" like uniform updates
  81085. */
  81086. setVector2(name: string, value: Vector2): ProceduralTexture;
  81087. /**
  81088. * Set a vec3 in the shader from a Vector3.
  81089. * @param name Define the name of the uniform as defined in the shader
  81090. * @param value Define the value to give to the uniform
  81091. * @return the texture itself allowing "fluent" like uniform updates
  81092. */
  81093. setVector3(name: string, value: Vector3): ProceduralTexture;
  81094. /**
  81095. * Set a mat4 in the shader from a MAtrix.
  81096. * @param name Define the name of the uniform as defined in the shader
  81097. * @param value Define the value to give to the uniform
  81098. * @return the texture itself allowing "fluent" like uniform updates
  81099. */
  81100. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81101. /**
  81102. * Render the texture to its associated render target.
  81103. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81104. */
  81105. render(useCameraPostProcess?: boolean): void;
  81106. /**
  81107. * Clone the texture.
  81108. * @returns the cloned texture
  81109. */
  81110. clone(): ProceduralTexture;
  81111. /**
  81112. * Dispose the texture and release its asoociated resources.
  81113. */
  81114. dispose(): void;
  81115. }
  81116. }
  81117. declare module BABYLON {
  81118. /**
  81119. * This represents the base class for particle system in Babylon.
  81120. * 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.
  81121. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81122. * @example https://doc.babylonjs.com/babylon101/particles
  81123. */
  81124. export class BaseParticleSystem {
  81125. /**
  81126. * Source color is added to the destination color without alpha affecting the result
  81127. */
  81128. static BLENDMODE_ONEONE: number;
  81129. /**
  81130. * Blend current color and particle color using particle’s alpha
  81131. */
  81132. static BLENDMODE_STANDARD: number;
  81133. /**
  81134. * Add current color and particle color multiplied by particle’s alpha
  81135. */
  81136. static BLENDMODE_ADD: number;
  81137. /**
  81138. * Multiply current color with particle color
  81139. */
  81140. static BLENDMODE_MULTIPLY: number;
  81141. /**
  81142. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81143. */
  81144. static BLENDMODE_MULTIPLYADD: number;
  81145. /**
  81146. * List of animations used by the particle system.
  81147. */
  81148. animations: Animation[];
  81149. /**
  81150. * The id of the Particle system.
  81151. */
  81152. id: string;
  81153. /**
  81154. * The friendly name of the Particle system.
  81155. */
  81156. name: string;
  81157. /**
  81158. * The rendering group used by the Particle system to chose when to render.
  81159. */
  81160. renderingGroupId: number;
  81161. /**
  81162. * The emitter represents the Mesh or position we are attaching the particle system to.
  81163. */
  81164. emitter: Nullable<AbstractMesh | Vector3>;
  81165. /**
  81166. * The maximum number of particles to emit per frame
  81167. */
  81168. emitRate: number;
  81169. /**
  81170. * If you want to launch only a few particles at once, that can be done, as well.
  81171. */
  81172. manualEmitCount: number;
  81173. /**
  81174. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81175. */
  81176. updateSpeed: number;
  81177. /**
  81178. * The amount of time the particle system is running (depends of the overall update speed).
  81179. */
  81180. targetStopDuration: number;
  81181. /**
  81182. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81183. */
  81184. disposeOnStop: boolean;
  81185. /**
  81186. * Minimum power of emitting particles.
  81187. */
  81188. minEmitPower: number;
  81189. /**
  81190. * Maximum power of emitting particles.
  81191. */
  81192. maxEmitPower: number;
  81193. /**
  81194. * Minimum life time of emitting particles.
  81195. */
  81196. minLifeTime: number;
  81197. /**
  81198. * Maximum life time of emitting particles.
  81199. */
  81200. maxLifeTime: number;
  81201. /**
  81202. * Minimum Size of emitting particles.
  81203. */
  81204. minSize: number;
  81205. /**
  81206. * Maximum Size of emitting particles.
  81207. */
  81208. maxSize: number;
  81209. /**
  81210. * Minimum scale of emitting particles on X axis.
  81211. */
  81212. minScaleX: number;
  81213. /**
  81214. * Maximum scale of emitting particles on X axis.
  81215. */
  81216. maxScaleX: number;
  81217. /**
  81218. * Minimum scale of emitting particles on Y axis.
  81219. */
  81220. minScaleY: number;
  81221. /**
  81222. * Maximum scale of emitting particles on Y axis.
  81223. */
  81224. maxScaleY: number;
  81225. /**
  81226. * Gets or sets the minimal initial rotation in radians.
  81227. */
  81228. minInitialRotation: number;
  81229. /**
  81230. * Gets or sets the maximal initial rotation in radians.
  81231. */
  81232. maxInitialRotation: number;
  81233. /**
  81234. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81235. */
  81236. minAngularSpeed: number;
  81237. /**
  81238. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81239. */
  81240. maxAngularSpeed: number;
  81241. /**
  81242. * The texture used to render each particle. (this can be a spritesheet)
  81243. */
  81244. particleTexture: Nullable<Texture>;
  81245. /**
  81246. * The layer mask we are rendering the particles through.
  81247. */
  81248. layerMask: number;
  81249. /**
  81250. * This can help using your own shader to render the particle system.
  81251. * The according effect will be created
  81252. */
  81253. customShader: any;
  81254. /**
  81255. * By default particle system starts as soon as they are created. This prevents the
  81256. * automatic start to happen and let you decide when to start emitting particles.
  81257. */
  81258. preventAutoStart: boolean;
  81259. private _noiseTexture;
  81260. /**
  81261. * Gets or sets a texture used to add random noise to particle positions
  81262. */
  81263. noiseTexture: Nullable<ProceduralTexture>;
  81264. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81265. noiseStrength: Vector3;
  81266. /**
  81267. * Callback triggered when the particle animation is ending.
  81268. */
  81269. onAnimationEnd: Nullable<() => void>;
  81270. /**
  81271. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81272. */
  81273. blendMode: number;
  81274. /**
  81275. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81276. * to override the particles.
  81277. */
  81278. forceDepthWrite: boolean;
  81279. /** 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 */
  81280. preWarmCycles: number;
  81281. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81282. preWarmStepOffset: number;
  81283. /**
  81284. * 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)
  81285. */
  81286. spriteCellChangeSpeed: number;
  81287. /**
  81288. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81289. */
  81290. startSpriteCellID: number;
  81291. /**
  81292. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81293. */
  81294. endSpriteCellID: number;
  81295. /**
  81296. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81297. */
  81298. spriteCellWidth: number;
  81299. /**
  81300. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81301. */
  81302. spriteCellHeight: number;
  81303. /**
  81304. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81305. */
  81306. spriteRandomStartCell: boolean;
  81307. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81308. translationPivot: Vector2;
  81309. /** @hidden */
  81310. protected _isAnimationSheetEnabled: boolean;
  81311. /**
  81312. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81313. */
  81314. beginAnimationOnStart: boolean;
  81315. /**
  81316. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81317. */
  81318. beginAnimationFrom: number;
  81319. /**
  81320. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81321. */
  81322. beginAnimationTo: number;
  81323. /**
  81324. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81325. */
  81326. beginAnimationLoop: boolean;
  81327. /**
  81328. * Gets or sets a world offset applied to all particles
  81329. */
  81330. worldOffset: Vector3;
  81331. /**
  81332. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81333. */
  81334. isAnimationSheetEnabled: boolean;
  81335. /**
  81336. * Get hosting scene
  81337. * @returns the scene
  81338. */
  81339. getScene(): Scene;
  81340. /**
  81341. * You can use gravity if you want to give an orientation to your particles.
  81342. */
  81343. gravity: Vector3;
  81344. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81345. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81346. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81347. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81348. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81349. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81350. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81351. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81352. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81353. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81354. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81355. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81356. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81357. /**
  81358. * Defines the delay in milliseconds before starting the system (0 by default)
  81359. */
  81360. startDelay: number;
  81361. /**
  81362. * Gets the current list of drag gradients.
  81363. * You must use addDragGradient and removeDragGradient to udpate this list
  81364. * @returns the list of drag gradients
  81365. */
  81366. getDragGradients(): Nullable<Array<FactorGradient>>;
  81367. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81368. limitVelocityDamping: number;
  81369. /**
  81370. * Gets the current list of limit velocity gradients.
  81371. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81372. * @returns the list of limit velocity gradients
  81373. */
  81374. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81375. /**
  81376. * Gets the current list of color gradients.
  81377. * You must use addColorGradient and removeColorGradient to udpate this list
  81378. * @returns the list of color gradients
  81379. */
  81380. getColorGradients(): Nullable<Array<ColorGradient>>;
  81381. /**
  81382. * Gets the current list of size gradients.
  81383. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81384. * @returns the list of size gradients
  81385. */
  81386. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81387. /**
  81388. * Gets the current list of color remap gradients.
  81389. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81390. * @returns the list of color remap gradients
  81391. */
  81392. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81393. /**
  81394. * Gets the current list of alpha remap gradients.
  81395. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81396. * @returns the list of alpha remap gradients
  81397. */
  81398. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81399. /**
  81400. * Gets the current list of life time gradients.
  81401. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81402. * @returns the list of life time gradients
  81403. */
  81404. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81405. /**
  81406. * Gets the current list of angular speed gradients.
  81407. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81408. * @returns the list of angular speed gradients
  81409. */
  81410. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81411. /**
  81412. * Gets the current list of velocity gradients.
  81413. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81414. * @returns the list of velocity gradients
  81415. */
  81416. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81417. /**
  81418. * Gets the current list of start size gradients.
  81419. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81420. * @returns the list of start size gradients
  81421. */
  81422. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81423. /**
  81424. * Gets the current list of emit rate gradients.
  81425. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81426. * @returns the list of emit rate gradients
  81427. */
  81428. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81429. /**
  81430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81431. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81432. */
  81433. direction1: Vector3;
  81434. /**
  81435. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81436. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81437. */
  81438. direction2: Vector3;
  81439. /**
  81440. * 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.
  81441. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81442. */
  81443. minEmitBox: Vector3;
  81444. /**
  81445. * 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.
  81446. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81447. */
  81448. maxEmitBox: Vector3;
  81449. /**
  81450. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81451. */
  81452. color1: Color4;
  81453. /**
  81454. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81455. */
  81456. color2: Color4;
  81457. /**
  81458. * Color the particle will have at the end of its lifetime
  81459. */
  81460. colorDead: Color4;
  81461. /**
  81462. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81463. */
  81464. textureMask: Color4;
  81465. /**
  81466. * The particle emitter type defines the emitter used by the particle system.
  81467. * It can be for example box, sphere, or cone...
  81468. */
  81469. particleEmitterType: IParticleEmitterType;
  81470. /** @hidden */
  81471. _isSubEmitter: boolean;
  81472. /**
  81473. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81474. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81475. */
  81476. billboardMode: number;
  81477. protected _isBillboardBased: boolean;
  81478. /**
  81479. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81480. */
  81481. isBillboardBased: boolean;
  81482. /**
  81483. * The scene the particle system belongs to.
  81484. */
  81485. protected _scene: Scene;
  81486. /**
  81487. * Local cache of defines for image processing.
  81488. */
  81489. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81490. /**
  81491. * Default configuration related to image processing available in the standard Material.
  81492. */
  81493. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81494. /**
  81495. * Gets the image processing configuration used either in this material.
  81496. */
  81497. /**
  81498. * Sets the Default image processing configuration used either in the this material.
  81499. *
  81500. * If sets to null, the scene one is in use.
  81501. */
  81502. imageProcessingConfiguration: ImageProcessingConfiguration;
  81503. /**
  81504. * Attaches a new image processing configuration to the Standard Material.
  81505. * @param configuration
  81506. */
  81507. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81508. /** @hidden */
  81509. protected _reset(): void;
  81510. /** @hidden */
  81511. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81512. /**
  81513. * Instantiates a particle system.
  81514. * 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.
  81515. * @param name The name of the particle system
  81516. */
  81517. constructor(name: string);
  81518. /**
  81519. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81522. * @returns the emitter
  81523. */
  81524. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81525. /**
  81526. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81527. * @param radius The radius of the hemisphere to emit from
  81528. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81529. * @returns the emitter
  81530. */
  81531. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81532. /**
  81533. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81534. * @param radius The radius of the sphere to emit from
  81535. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81536. * @returns the emitter
  81537. */
  81538. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81539. /**
  81540. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81541. * @param radius The radius of the sphere to emit from
  81542. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81543. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81544. * @returns the emitter
  81545. */
  81546. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81547. /**
  81548. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81549. * @param radius The radius of the emission cylinder
  81550. * @param height The height of the emission cylinder
  81551. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81552. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81553. * @returns the emitter
  81554. */
  81555. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81556. /**
  81557. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81558. * @param radius The radius of the cylinder to emit from
  81559. * @param height The height of the emission cylinder
  81560. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81563. * @returns the emitter
  81564. */
  81565. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81566. /**
  81567. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81568. * @param radius The radius of the cone to emit from
  81569. * @param angle The base angle of the cone
  81570. * @returns the emitter
  81571. */
  81572. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81573. /**
  81574. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81575. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81576. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81577. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81578. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81579. * @returns the emitter
  81580. */
  81581. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81582. }
  81583. }
  81584. declare module BABYLON {
  81585. /**
  81586. * Type of sub emitter
  81587. */
  81588. export enum SubEmitterType {
  81589. /**
  81590. * Attached to the particle over it's lifetime
  81591. */
  81592. ATTACHED = 0,
  81593. /**
  81594. * Created when the particle dies
  81595. */
  81596. END = 1
  81597. }
  81598. /**
  81599. * Sub emitter class used to emit particles from an existing particle
  81600. */
  81601. export class SubEmitter {
  81602. /**
  81603. * the particle system to be used by the sub emitter
  81604. */
  81605. particleSystem: ParticleSystem;
  81606. /**
  81607. * Type of the submitter (Default: END)
  81608. */
  81609. type: SubEmitterType;
  81610. /**
  81611. * 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)
  81612. * Note: This only is supported when using an emitter of type Mesh
  81613. */
  81614. inheritDirection: boolean;
  81615. /**
  81616. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81617. */
  81618. inheritedVelocityAmount: number;
  81619. /**
  81620. * Creates a sub emitter
  81621. * @param particleSystem the particle system to be used by the sub emitter
  81622. */
  81623. constructor(
  81624. /**
  81625. * the particle system to be used by the sub emitter
  81626. */
  81627. particleSystem: ParticleSystem);
  81628. /**
  81629. * Clones the sub emitter
  81630. * @returns the cloned sub emitter
  81631. */
  81632. clone(): SubEmitter;
  81633. /**
  81634. * Serialize current object to a JSON object
  81635. * @returns the serialized object
  81636. */
  81637. serialize(): any;
  81638. /** @hidden */
  81639. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  81640. /**
  81641. * Creates a new SubEmitter from a serialized JSON version
  81642. * @param serializationObject defines the JSON object to read from
  81643. * @param scene defines the hosting scene
  81644. * @param rootUrl defines the rootUrl for data loading
  81645. * @returns a new SubEmitter
  81646. */
  81647. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  81648. /** Release associated resources */
  81649. dispose(): void;
  81650. }
  81651. }
  81652. declare module BABYLON {
  81653. /** @hidden */
  81654. export var clipPlaneFragmentDeclaration: {
  81655. name: string;
  81656. shader: string;
  81657. };
  81658. }
  81659. declare module BABYLON {
  81660. /** @hidden */
  81661. export var imageProcessingDeclaration: {
  81662. name: string;
  81663. shader: string;
  81664. };
  81665. }
  81666. declare module BABYLON {
  81667. /** @hidden */
  81668. export var imageProcessingFunctions: {
  81669. name: string;
  81670. shader: string;
  81671. };
  81672. }
  81673. declare module BABYLON {
  81674. /** @hidden */
  81675. export var clipPlaneFragment: {
  81676. name: string;
  81677. shader: string;
  81678. };
  81679. }
  81680. declare module BABYLON {
  81681. /** @hidden */
  81682. export var particlesPixelShader: {
  81683. name: string;
  81684. shader: string;
  81685. };
  81686. }
  81687. declare module BABYLON {
  81688. /** @hidden */
  81689. export var clipPlaneVertexDeclaration: {
  81690. name: string;
  81691. shader: string;
  81692. };
  81693. }
  81694. declare module BABYLON {
  81695. /** @hidden */
  81696. export var clipPlaneVertex: {
  81697. name: string;
  81698. shader: string;
  81699. };
  81700. }
  81701. declare module BABYLON {
  81702. /** @hidden */
  81703. export var particlesVertexShader: {
  81704. name: string;
  81705. shader: string;
  81706. };
  81707. }
  81708. declare module BABYLON {
  81709. /**
  81710. * This represents a particle system in Babylon.
  81711. * 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.
  81712. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81713. * @example https://doc.babylonjs.com/babylon101/particles
  81714. */
  81715. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  81716. /**
  81717. * Billboard mode will only apply to Y axis
  81718. */
  81719. static readonly BILLBOARDMODE_Y: number;
  81720. /**
  81721. * Billboard mode will apply to all axes
  81722. */
  81723. static readonly BILLBOARDMODE_ALL: number;
  81724. /**
  81725. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81726. */
  81727. static readonly BILLBOARDMODE_STRETCHED: number;
  81728. /**
  81729. * This function can be defined to provide custom update for active particles.
  81730. * This function will be called instead of regular update (age, position, color, etc.).
  81731. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  81732. */
  81733. updateFunction: (particles: Particle[]) => void;
  81734. private _emitterWorldMatrix;
  81735. /**
  81736. * This function can be defined to specify initial direction for every new particle.
  81737. * It by default use the emitterType defined function
  81738. */
  81739. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  81740. /**
  81741. * This function can be defined to specify initial position for every new particle.
  81742. * It by default use the emitterType defined function
  81743. */
  81744. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  81745. /**
  81746. * @hidden
  81747. */
  81748. _inheritedVelocityOffset: Vector3;
  81749. /**
  81750. * An event triggered when the system is disposed
  81751. */
  81752. onDisposeObservable: Observable<ParticleSystem>;
  81753. private _onDisposeObserver;
  81754. /**
  81755. * Sets a callback that will be triggered when the system is disposed
  81756. */
  81757. onDispose: () => void;
  81758. private _particles;
  81759. private _epsilon;
  81760. private _capacity;
  81761. private _stockParticles;
  81762. private _newPartsExcess;
  81763. private _vertexData;
  81764. private _vertexBuffer;
  81765. private _vertexBuffers;
  81766. private _spriteBuffer;
  81767. private _indexBuffer;
  81768. private _effect;
  81769. private _customEffect;
  81770. private _cachedDefines;
  81771. private _scaledColorStep;
  81772. private _colorDiff;
  81773. private _scaledDirection;
  81774. private _scaledGravity;
  81775. private _currentRenderId;
  81776. private _alive;
  81777. private _useInstancing;
  81778. private _started;
  81779. private _stopped;
  81780. private _actualFrame;
  81781. private _scaledUpdateSpeed;
  81782. private _vertexBufferSize;
  81783. /** @hidden */
  81784. _currentEmitRateGradient: Nullable<FactorGradient>;
  81785. /** @hidden */
  81786. _currentEmitRate1: number;
  81787. /** @hidden */
  81788. _currentEmitRate2: number;
  81789. /** @hidden */
  81790. _currentStartSizeGradient: Nullable<FactorGradient>;
  81791. /** @hidden */
  81792. _currentStartSize1: number;
  81793. /** @hidden */
  81794. _currentStartSize2: number;
  81795. private readonly _rawTextureWidth;
  81796. private _rampGradientsTexture;
  81797. private _useRampGradients;
  81798. /** Gets or sets a boolean indicating that ramp gradients must be used
  81799. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81800. */
  81801. useRampGradients: boolean;
  81802. /**
  81803. * 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.
  81804. * 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: [])
  81805. */
  81806. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81807. private _subEmitters;
  81808. /**
  81809. * @hidden
  81810. * If the particle systems emitter should be disposed when the particle system is disposed
  81811. */
  81812. _disposeEmitterOnDispose: boolean;
  81813. /**
  81814. * The current active Sub-systems, this property is used by the root particle system only.
  81815. */
  81816. activeSubSystems: Array<ParticleSystem>;
  81817. private _rootParticleSystem;
  81818. /**
  81819. * Gets the current list of active particles
  81820. */
  81821. readonly particles: Particle[];
  81822. /**
  81823. * Returns the string "ParticleSystem"
  81824. * @returns a string containing the class name
  81825. */
  81826. getClassName(): string;
  81827. /**
  81828. * Instantiates a particle system.
  81829. * 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.
  81830. * @param name The name of the particle system
  81831. * @param capacity The max number of particles alive at the same time
  81832. * @param scene The scene the particle system belongs to
  81833. * @param customEffect a custom effect used to change the way particles are rendered by default
  81834. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81835. * @param epsilon Offset used to render the particles
  81836. */
  81837. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81838. private _addFactorGradient;
  81839. private _removeFactorGradient;
  81840. /**
  81841. * Adds a new life time gradient
  81842. * @param gradient defines the gradient to use (between 0 and 1)
  81843. * @param factor defines the life time factor to affect to the specified gradient
  81844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81845. * @returns the current particle system
  81846. */
  81847. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81848. /**
  81849. * Remove a specific life time gradient
  81850. * @param gradient defines the gradient to remove
  81851. * @returns the current particle system
  81852. */
  81853. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81854. /**
  81855. * Adds a new size gradient
  81856. * @param gradient defines the gradient to use (between 0 and 1)
  81857. * @param factor defines the size factor to affect to the specified gradient
  81858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81859. * @returns the current particle system
  81860. */
  81861. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81862. /**
  81863. * Remove a specific size gradient
  81864. * @param gradient defines the gradient to remove
  81865. * @returns the current particle system
  81866. */
  81867. removeSizeGradient(gradient: number): IParticleSystem;
  81868. /**
  81869. * Adds a new color remap gradient
  81870. * @param gradient defines the gradient to use (between 0 and 1)
  81871. * @param min defines the color remap minimal range
  81872. * @param max defines the color remap maximal range
  81873. * @returns the current particle system
  81874. */
  81875. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81876. /**
  81877. * Remove a specific color remap gradient
  81878. * @param gradient defines the gradient to remove
  81879. * @returns the current particle system
  81880. */
  81881. removeColorRemapGradient(gradient: number): IParticleSystem;
  81882. /**
  81883. * Adds a new alpha remap gradient
  81884. * @param gradient defines the gradient to use (between 0 and 1)
  81885. * @param min defines the alpha remap minimal range
  81886. * @param max defines the alpha remap maximal range
  81887. * @returns the current particle system
  81888. */
  81889. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81890. /**
  81891. * Remove a specific alpha remap gradient
  81892. * @param gradient defines the gradient to remove
  81893. * @returns the current particle system
  81894. */
  81895. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  81896. /**
  81897. * Adds a new angular speed gradient
  81898. * @param gradient defines the gradient to use (between 0 and 1)
  81899. * @param factor defines the angular speed to affect to the specified gradient
  81900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81901. * @returns the current particle system
  81902. */
  81903. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81904. /**
  81905. * Remove a specific angular speed gradient
  81906. * @param gradient defines the gradient to remove
  81907. * @returns the current particle system
  81908. */
  81909. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81910. /**
  81911. * Adds a new velocity gradient
  81912. * @param gradient defines the gradient to use (between 0 and 1)
  81913. * @param factor defines the velocity to affect to the specified gradient
  81914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81915. * @returns the current particle system
  81916. */
  81917. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81918. /**
  81919. * Remove a specific velocity gradient
  81920. * @param gradient defines the gradient to remove
  81921. * @returns the current particle system
  81922. */
  81923. removeVelocityGradient(gradient: number): IParticleSystem;
  81924. /**
  81925. * Adds a new limit velocity gradient
  81926. * @param gradient defines the gradient to use (between 0 and 1)
  81927. * @param factor defines the limit velocity value to affect to the specified gradient
  81928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81929. * @returns the current particle system
  81930. */
  81931. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81932. /**
  81933. * Remove a specific limit velocity gradient
  81934. * @param gradient defines the gradient to remove
  81935. * @returns the current particle system
  81936. */
  81937. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81938. /**
  81939. * Adds a new drag gradient
  81940. * @param gradient defines the gradient to use (between 0 and 1)
  81941. * @param factor defines the drag value to affect to the specified gradient
  81942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81943. * @returns the current particle system
  81944. */
  81945. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81946. /**
  81947. * Remove a specific drag gradient
  81948. * @param gradient defines the gradient to remove
  81949. * @returns the current particle system
  81950. */
  81951. removeDragGradient(gradient: number): IParticleSystem;
  81952. /**
  81953. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81954. * @param gradient defines the gradient to use (between 0 and 1)
  81955. * @param factor defines the emit rate value to affect to the specified gradient
  81956. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81957. * @returns the current particle system
  81958. */
  81959. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81960. /**
  81961. * Remove a specific emit rate gradient
  81962. * @param gradient defines the gradient to remove
  81963. * @returns the current particle system
  81964. */
  81965. removeEmitRateGradient(gradient: number): IParticleSystem;
  81966. /**
  81967. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81968. * @param gradient defines the gradient to use (between 0 and 1)
  81969. * @param factor defines the start size value to affect to the specified gradient
  81970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81971. * @returns the current particle system
  81972. */
  81973. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81974. /**
  81975. * Remove a specific start size gradient
  81976. * @param gradient defines the gradient to remove
  81977. * @returns the current particle system
  81978. */
  81979. removeStartSizeGradient(gradient: number): IParticleSystem;
  81980. private _createRampGradientTexture;
  81981. /**
  81982. * Gets the current list of ramp gradients.
  81983. * You must use addRampGradient and removeRampGradient to udpate this list
  81984. * @returns the list of ramp gradients
  81985. */
  81986. getRampGradients(): Nullable<Array<Color3Gradient>>;
  81987. /**
  81988. * Adds a new ramp gradient used to remap particle colors
  81989. * @param gradient defines the gradient to use (between 0 and 1)
  81990. * @param color defines the color to affect to the specified gradient
  81991. * @returns the current particle system
  81992. */
  81993. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  81994. /**
  81995. * Remove a specific ramp gradient
  81996. * @param gradient defines the gradient to remove
  81997. * @returns the current particle system
  81998. */
  81999. removeRampGradient(gradient: number): ParticleSystem;
  82000. /**
  82001. * Adds a new color gradient
  82002. * @param gradient defines the gradient to use (between 0 and 1)
  82003. * @param color1 defines the color to affect to the specified gradient
  82004. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82005. * @returns this particle system
  82006. */
  82007. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82008. /**
  82009. * Remove a specific color gradient
  82010. * @param gradient defines the gradient to remove
  82011. * @returns this particle system
  82012. */
  82013. removeColorGradient(gradient: number): IParticleSystem;
  82014. private _fetchR;
  82015. protected _reset(): void;
  82016. private _resetEffect;
  82017. private _createVertexBuffers;
  82018. private _createIndexBuffer;
  82019. /**
  82020. * Gets the maximum number of particles active at the same time.
  82021. * @returns The max number of active particles.
  82022. */
  82023. getCapacity(): number;
  82024. /**
  82025. * Gets whether there are still active particles in the system.
  82026. * @returns True if it is alive, otherwise false.
  82027. */
  82028. isAlive(): boolean;
  82029. /**
  82030. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82031. * @returns True if it has been started, otherwise false.
  82032. */
  82033. isStarted(): boolean;
  82034. private _prepareSubEmitterInternalArray;
  82035. /**
  82036. * Starts the particle system and begins to emit
  82037. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82038. */
  82039. start(delay?: number): void;
  82040. /**
  82041. * Stops the particle system.
  82042. * @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.
  82043. */
  82044. stop(stopSubEmitters?: boolean): void;
  82045. /**
  82046. * Remove all active particles
  82047. */
  82048. reset(): void;
  82049. /**
  82050. * @hidden (for internal use only)
  82051. */
  82052. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82053. /**
  82054. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82055. * Its lifetime will start back at 0.
  82056. */
  82057. recycleParticle: (particle: Particle) => void;
  82058. private _stopSubEmitters;
  82059. private _createParticle;
  82060. private _removeFromRoot;
  82061. private _emitFromParticle;
  82062. private _update;
  82063. /** @hidden */
  82064. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82065. /** @hidden */
  82066. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82067. /** @hidden */
  82068. private _getEffect;
  82069. /**
  82070. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82071. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82072. */
  82073. animate(preWarmOnly?: boolean): void;
  82074. private _appendParticleVertices;
  82075. /**
  82076. * Rebuilds the particle system.
  82077. */
  82078. rebuild(): void;
  82079. /**
  82080. * Is this system ready to be used/rendered
  82081. * @return true if the system is ready
  82082. */
  82083. isReady(): boolean;
  82084. private _render;
  82085. /**
  82086. * Renders the particle system in its current state.
  82087. * @returns the current number of particles
  82088. */
  82089. render(): number;
  82090. /**
  82091. * Disposes the particle system and free the associated resources
  82092. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82093. */
  82094. dispose(disposeTexture?: boolean): void;
  82095. /**
  82096. * Clones the particle system.
  82097. * @param name The name of the cloned object
  82098. * @param newEmitter The new emitter to use
  82099. * @returns the cloned particle system
  82100. */
  82101. clone(name: string, newEmitter: any): ParticleSystem;
  82102. /**
  82103. * Serializes the particle system to a JSON object.
  82104. * @returns the JSON object
  82105. */
  82106. serialize(): any;
  82107. /** @hidden */
  82108. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82109. /** @hidden */
  82110. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82111. /**
  82112. * Parses a JSON object to create a particle system.
  82113. * @param parsedParticleSystem The JSON object to parse
  82114. * @param scene The scene to create the particle system in
  82115. * @param rootUrl The root url to use to load external dependencies like texture
  82116. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82117. * @returns the Parsed particle system
  82118. */
  82119. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82120. }
  82121. }
  82122. declare module BABYLON {
  82123. /**
  82124. * A particle represents one of the element emitted by a particle system.
  82125. * This is mainly define by its coordinates, direction, velocity and age.
  82126. */
  82127. export class Particle {
  82128. /**
  82129. * The particle system the particle belongs to.
  82130. */
  82131. particleSystem: ParticleSystem;
  82132. private static _Count;
  82133. /**
  82134. * Unique ID of the particle
  82135. */
  82136. id: number;
  82137. /**
  82138. * The world position of the particle in the scene.
  82139. */
  82140. position: Vector3;
  82141. /**
  82142. * The world direction of the particle in the scene.
  82143. */
  82144. direction: Vector3;
  82145. /**
  82146. * The color of the particle.
  82147. */
  82148. color: Color4;
  82149. /**
  82150. * The color change of the particle per step.
  82151. */
  82152. colorStep: Color4;
  82153. /**
  82154. * Defines how long will the life of the particle be.
  82155. */
  82156. lifeTime: number;
  82157. /**
  82158. * The current age of the particle.
  82159. */
  82160. age: number;
  82161. /**
  82162. * The current size of the particle.
  82163. */
  82164. size: number;
  82165. /**
  82166. * The current scale of the particle.
  82167. */
  82168. scale: Vector2;
  82169. /**
  82170. * The current angle of the particle.
  82171. */
  82172. angle: number;
  82173. /**
  82174. * Defines how fast is the angle changing.
  82175. */
  82176. angularSpeed: number;
  82177. /**
  82178. * Defines the cell index used by the particle to be rendered from a sprite.
  82179. */
  82180. cellIndex: number;
  82181. /**
  82182. * The information required to support color remapping
  82183. */
  82184. remapData: Vector4;
  82185. /** @hidden */
  82186. _randomCellOffset?: number;
  82187. /** @hidden */
  82188. _initialDirection: Nullable<Vector3>;
  82189. /** @hidden */
  82190. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82191. /** @hidden */
  82192. _initialStartSpriteCellID: number;
  82193. /** @hidden */
  82194. _initialEndSpriteCellID: number;
  82195. /** @hidden */
  82196. _currentColorGradient: Nullable<ColorGradient>;
  82197. /** @hidden */
  82198. _currentColor1: Color4;
  82199. /** @hidden */
  82200. _currentColor2: Color4;
  82201. /** @hidden */
  82202. _currentSizeGradient: Nullable<FactorGradient>;
  82203. /** @hidden */
  82204. _currentSize1: number;
  82205. /** @hidden */
  82206. _currentSize2: number;
  82207. /** @hidden */
  82208. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82209. /** @hidden */
  82210. _currentAngularSpeed1: number;
  82211. /** @hidden */
  82212. _currentAngularSpeed2: number;
  82213. /** @hidden */
  82214. _currentVelocityGradient: Nullable<FactorGradient>;
  82215. /** @hidden */
  82216. _currentVelocity1: number;
  82217. /** @hidden */
  82218. _currentVelocity2: number;
  82219. /** @hidden */
  82220. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82221. /** @hidden */
  82222. _currentLimitVelocity1: number;
  82223. /** @hidden */
  82224. _currentLimitVelocity2: number;
  82225. /** @hidden */
  82226. _currentDragGradient: Nullable<FactorGradient>;
  82227. /** @hidden */
  82228. _currentDrag1: number;
  82229. /** @hidden */
  82230. _currentDrag2: number;
  82231. /** @hidden */
  82232. _randomNoiseCoordinates1: Vector3;
  82233. /** @hidden */
  82234. _randomNoiseCoordinates2: Vector3;
  82235. /**
  82236. * Creates a new instance Particle
  82237. * @param particleSystem the particle system the particle belongs to
  82238. */
  82239. constructor(
  82240. /**
  82241. * The particle system the particle belongs to.
  82242. */
  82243. particleSystem: ParticleSystem);
  82244. private updateCellInfoFromSystem;
  82245. /**
  82246. * Defines how the sprite cell index is updated for the particle
  82247. */
  82248. updateCellIndex(): void;
  82249. /** @hidden */
  82250. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82251. /** @hidden */
  82252. _inheritParticleInfoToSubEmitters(): void;
  82253. /** @hidden */
  82254. _reset(): void;
  82255. /**
  82256. * Copy the properties of particle to another one.
  82257. * @param other the particle to copy the information to.
  82258. */
  82259. copyTo(other: Particle): void;
  82260. }
  82261. }
  82262. declare module BABYLON {
  82263. /**
  82264. * Particle emitter represents a volume emitting particles.
  82265. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82266. */
  82267. export interface IParticleEmitterType {
  82268. /**
  82269. * Called by the particle System when the direction is computed for the created particle.
  82270. * @param worldMatrix is the world matrix of the particle system
  82271. * @param directionToUpdate is the direction vector to update with the result
  82272. * @param particle is the particle we are computed the direction for
  82273. */
  82274. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82275. /**
  82276. * Called by the particle System when the position is computed for the created particle.
  82277. * @param worldMatrix is the world matrix of the particle system
  82278. * @param positionToUpdate is the position vector to update with the result
  82279. * @param particle is the particle we are computed the position for
  82280. */
  82281. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82282. /**
  82283. * Clones the current emitter and returns a copy of it
  82284. * @returns the new emitter
  82285. */
  82286. clone(): IParticleEmitterType;
  82287. /**
  82288. * Called by the GPUParticleSystem to setup the update shader
  82289. * @param effect defines the update shader
  82290. */
  82291. applyToShader(effect: Effect): void;
  82292. /**
  82293. * Returns a string to use to update the GPU particles update shader
  82294. * @returns the effect defines string
  82295. */
  82296. getEffectDefines(): string;
  82297. /**
  82298. * Returns a string representing the class name
  82299. * @returns a string containing the class name
  82300. */
  82301. getClassName(): string;
  82302. /**
  82303. * Serializes the particle system to a JSON object.
  82304. * @returns the JSON object
  82305. */
  82306. serialize(): any;
  82307. /**
  82308. * Parse properties from a JSON object
  82309. * @param serializationObject defines the JSON object
  82310. */
  82311. parse(serializationObject: any): void;
  82312. }
  82313. }
  82314. declare module BABYLON {
  82315. /**
  82316. * Particle emitter emitting particles from the inside of a box.
  82317. * It emits the particles randomly between 2 given directions.
  82318. */
  82319. export class BoxParticleEmitter implements IParticleEmitterType {
  82320. /**
  82321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82322. */
  82323. direction1: Vector3;
  82324. /**
  82325. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82326. */
  82327. direction2: Vector3;
  82328. /**
  82329. * 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.
  82330. */
  82331. minEmitBox: Vector3;
  82332. /**
  82333. * 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.
  82334. */
  82335. maxEmitBox: Vector3;
  82336. /**
  82337. * Creates a new instance BoxParticleEmitter
  82338. */
  82339. constructor();
  82340. /**
  82341. * Called by the particle System when the direction is computed for the created particle.
  82342. * @param worldMatrix is the world matrix of the particle system
  82343. * @param directionToUpdate is the direction vector to update with the result
  82344. * @param particle is the particle we are computed the direction for
  82345. */
  82346. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82347. /**
  82348. * Called by the particle System when the position is computed for the created particle.
  82349. * @param worldMatrix is the world matrix of the particle system
  82350. * @param positionToUpdate is the position vector to update with the result
  82351. * @param particle is the particle we are computed the position for
  82352. */
  82353. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82354. /**
  82355. * Clones the current emitter and returns a copy of it
  82356. * @returns the new emitter
  82357. */
  82358. clone(): BoxParticleEmitter;
  82359. /**
  82360. * Called by the GPUParticleSystem to setup the update shader
  82361. * @param effect defines the update shader
  82362. */
  82363. applyToShader(effect: Effect): void;
  82364. /**
  82365. * Returns a string to use to update the GPU particles update shader
  82366. * @returns a string containng the defines string
  82367. */
  82368. getEffectDefines(): string;
  82369. /**
  82370. * Returns the string "BoxParticleEmitter"
  82371. * @returns a string containing the class name
  82372. */
  82373. getClassName(): string;
  82374. /**
  82375. * Serializes the particle system to a JSON object.
  82376. * @returns the JSON object
  82377. */
  82378. serialize(): any;
  82379. /**
  82380. * Parse properties from a JSON object
  82381. * @param serializationObject defines the JSON object
  82382. */
  82383. parse(serializationObject: any): void;
  82384. }
  82385. }
  82386. declare module BABYLON {
  82387. /**
  82388. * Particle emitter emitting particles from the inside of a cone.
  82389. * It emits the particles alongside the cone volume from the base to the particle.
  82390. * The emission direction might be randomized.
  82391. */
  82392. export class ConeParticleEmitter implements IParticleEmitterType {
  82393. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82394. directionRandomizer: number;
  82395. private _radius;
  82396. private _angle;
  82397. private _height;
  82398. /**
  82399. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82400. */
  82401. radiusRange: number;
  82402. /**
  82403. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82404. */
  82405. heightRange: number;
  82406. /**
  82407. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82408. */
  82409. emitFromSpawnPointOnly: boolean;
  82410. /**
  82411. * Gets or sets the radius of the emission cone
  82412. */
  82413. radius: number;
  82414. /**
  82415. * Gets or sets the angle of the emission cone
  82416. */
  82417. angle: number;
  82418. private _buildHeight;
  82419. /**
  82420. * Creates a new instance ConeParticleEmitter
  82421. * @param radius the radius of the emission cone (1 by default)
  82422. * @param angle the cone base angle (PI by default)
  82423. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82424. */
  82425. constructor(radius?: number, angle?: number,
  82426. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82427. directionRandomizer?: number);
  82428. /**
  82429. * Called by the particle System when the direction is computed for the created particle.
  82430. * @param worldMatrix is the world matrix of the particle system
  82431. * @param directionToUpdate is the direction vector to update with the result
  82432. * @param particle is the particle we are computed the direction for
  82433. */
  82434. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82435. /**
  82436. * Called by the particle System when the position is computed for the created particle.
  82437. * @param worldMatrix is the world matrix of the particle system
  82438. * @param positionToUpdate is the position vector to update with the result
  82439. * @param particle is the particle we are computed the position for
  82440. */
  82441. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82442. /**
  82443. * Clones the current emitter and returns a copy of it
  82444. * @returns the new emitter
  82445. */
  82446. clone(): ConeParticleEmitter;
  82447. /**
  82448. * Called by the GPUParticleSystem to setup the update shader
  82449. * @param effect defines the update shader
  82450. */
  82451. applyToShader(effect: Effect): void;
  82452. /**
  82453. * Returns a string to use to update the GPU particles update shader
  82454. * @returns a string containng the defines string
  82455. */
  82456. getEffectDefines(): string;
  82457. /**
  82458. * Returns the string "ConeParticleEmitter"
  82459. * @returns a string containing the class name
  82460. */
  82461. getClassName(): string;
  82462. /**
  82463. * Serializes the particle system to a JSON object.
  82464. * @returns the JSON object
  82465. */
  82466. serialize(): any;
  82467. /**
  82468. * Parse properties from a JSON object
  82469. * @param serializationObject defines the JSON object
  82470. */
  82471. parse(serializationObject: any): void;
  82472. }
  82473. }
  82474. declare module BABYLON {
  82475. /**
  82476. * Particle emitter emitting particles from the inside of a cylinder.
  82477. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82478. */
  82479. export class CylinderParticleEmitter implements IParticleEmitterType {
  82480. /**
  82481. * The radius of the emission cylinder.
  82482. */
  82483. radius: number;
  82484. /**
  82485. * The height of the emission cylinder.
  82486. */
  82487. height: number;
  82488. /**
  82489. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82490. */
  82491. radiusRange: number;
  82492. /**
  82493. * How much to randomize the particle direction [0-1].
  82494. */
  82495. directionRandomizer: number;
  82496. /**
  82497. * Creates a new instance CylinderParticleEmitter
  82498. * @param radius the radius of the emission cylinder (1 by default)
  82499. * @param height the height of the emission cylinder (1 by default)
  82500. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82501. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82502. */
  82503. constructor(
  82504. /**
  82505. * The radius of the emission cylinder.
  82506. */
  82507. radius?: number,
  82508. /**
  82509. * The height of the emission cylinder.
  82510. */
  82511. height?: number,
  82512. /**
  82513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82514. */
  82515. radiusRange?: number,
  82516. /**
  82517. * How much to randomize the particle direction [0-1].
  82518. */
  82519. directionRandomizer?: number);
  82520. /**
  82521. * Called by the particle System when the direction is computed for the created particle.
  82522. * @param worldMatrix is the world matrix of the particle system
  82523. * @param directionToUpdate is the direction vector to update with the result
  82524. * @param particle is the particle we are computed the direction for
  82525. */
  82526. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82527. /**
  82528. * Called by the particle System when the position is computed for the created particle.
  82529. * @param worldMatrix is the world matrix of the particle system
  82530. * @param positionToUpdate is the position vector to update with the result
  82531. * @param particle is the particle we are computed the position for
  82532. */
  82533. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82534. /**
  82535. * Clones the current emitter and returns a copy of it
  82536. * @returns the new emitter
  82537. */
  82538. clone(): CylinderParticleEmitter;
  82539. /**
  82540. * Called by the GPUParticleSystem to setup the update shader
  82541. * @param effect defines the update shader
  82542. */
  82543. applyToShader(effect: Effect): void;
  82544. /**
  82545. * Returns a string to use to update the GPU particles update shader
  82546. * @returns a string containng the defines string
  82547. */
  82548. getEffectDefines(): string;
  82549. /**
  82550. * Returns the string "CylinderParticleEmitter"
  82551. * @returns a string containing the class name
  82552. */
  82553. getClassName(): string;
  82554. /**
  82555. * Serializes the particle system to a JSON object.
  82556. * @returns the JSON object
  82557. */
  82558. serialize(): any;
  82559. /**
  82560. * Parse properties from a JSON object
  82561. * @param serializationObject defines the JSON object
  82562. */
  82563. parse(serializationObject: any): void;
  82564. }
  82565. /**
  82566. * Particle emitter emitting particles from the inside of a cylinder.
  82567. * It emits the particles randomly between two vectors.
  82568. */
  82569. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82570. /**
  82571. * The min limit of the emission direction.
  82572. */
  82573. direction1: Vector3;
  82574. /**
  82575. * The max limit of the emission direction.
  82576. */
  82577. direction2: Vector3;
  82578. /**
  82579. * Creates a new instance CylinderDirectedParticleEmitter
  82580. * @param radius the radius of the emission cylinder (1 by default)
  82581. * @param height the height of the emission cylinder (1 by default)
  82582. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82583. * @param direction1 the min limit of the emission direction (up vector by default)
  82584. * @param direction2 the max limit of the emission direction (up vector by default)
  82585. */
  82586. constructor(radius?: number, height?: number, radiusRange?: number,
  82587. /**
  82588. * The min limit of the emission direction.
  82589. */
  82590. direction1?: Vector3,
  82591. /**
  82592. * The max limit of the emission direction.
  82593. */
  82594. direction2?: Vector3);
  82595. /**
  82596. * Called by the particle System when the direction is computed for the created particle.
  82597. * @param worldMatrix is the world matrix of the particle system
  82598. * @param directionToUpdate is the direction vector to update with the result
  82599. * @param particle is the particle we are computed the direction for
  82600. */
  82601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82602. /**
  82603. * Clones the current emitter and returns a copy of it
  82604. * @returns the new emitter
  82605. */
  82606. clone(): CylinderDirectedParticleEmitter;
  82607. /**
  82608. * Called by the GPUParticleSystem to setup the update shader
  82609. * @param effect defines the update shader
  82610. */
  82611. applyToShader(effect: Effect): void;
  82612. /**
  82613. * Returns a string to use to update the GPU particles update shader
  82614. * @returns a string containng the defines string
  82615. */
  82616. getEffectDefines(): string;
  82617. /**
  82618. * Returns the string "CylinderDirectedParticleEmitter"
  82619. * @returns a string containing the class name
  82620. */
  82621. getClassName(): string;
  82622. /**
  82623. * Serializes the particle system to a JSON object.
  82624. * @returns the JSON object
  82625. */
  82626. serialize(): any;
  82627. /**
  82628. * Parse properties from a JSON object
  82629. * @param serializationObject defines the JSON object
  82630. */
  82631. parse(serializationObject: any): void;
  82632. }
  82633. }
  82634. declare module BABYLON {
  82635. /**
  82636. * Particle emitter emitting particles from the inside of a hemisphere.
  82637. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82638. */
  82639. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82640. /**
  82641. * The radius of the emission hemisphere.
  82642. */
  82643. radius: number;
  82644. /**
  82645. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82646. */
  82647. radiusRange: number;
  82648. /**
  82649. * How much to randomize the particle direction [0-1].
  82650. */
  82651. directionRandomizer: number;
  82652. /**
  82653. * Creates a new instance HemisphericParticleEmitter
  82654. * @param radius the radius of the emission hemisphere (1 by default)
  82655. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82656. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82657. */
  82658. constructor(
  82659. /**
  82660. * The radius of the emission hemisphere.
  82661. */
  82662. radius?: number,
  82663. /**
  82664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82665. */
  82666. radiusRange?: number,
  82667. /**
  82668. * How much to randomize the particle direction [0-1].
  82669. */
  82670. directionRandomizer?: number);
  82671. /**
  82672. * Called by the particle System when the direction is computed for the created particle.
  82673. * @param worldMatrix is the world matrix of the particle system
  82674. * @param directionToUpdate is the direction vector to update with the result
  82675. * @param particle is the particle we are computed the direction for
  82676. */
  82677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82678. /**
  82679. * Called by the particle System when the position is computed for the created particle.
  82680. * @param worldMatrix is the world matrix of the particle system
  82681. * @param positionToUpdate is the position vector to update with the result
  82682. * @param particle is the particle we are computed the position for
  82683. */
  82684. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82685. /**
  82686. * Clones the current emitter and returns a copy of it
  82687. * @returns the new emitter
  82688. */
  82689. clone(): HemisphericParticleEmitter;
  82690. /**
  82691. * Called by the GPUParticleSystem to setup the update shader
  82692. * @param effect defines the update shader
  82693. */
  82694. applyToShader(effect: Effect): void;
  82695. /**
  82696. * Returns a string to use to update the GPU particles update shader
  82697. * @returns a string containng the defines string
  82698. */
  82699. getEffectDefines(): string;
  82700. /**
  82701. * Returns the string "HemisphericParticleEmitter"
  82702. * @returns a string containing the class name
  82703. */
  82704. getClassName(): string;
  82705. /**
  82706. * Serializes the particle system to a JSON object.
  82707. * @returns the JSON object
  82708. */
  82709. serialize(): any;
  82710. /**
  82711. * Parse properties from a JSON object
  82712. * @param serializationObject defines the JSON object
  82713. */
  82714. parse(serializationObject: any): void;
  82715. }
  82716. }
  82717. declare module BABYLON {
  82718. /**
  82719. * Particle emitter emitting particles from a point.
  82720. * It emits the particles randomly between 2 given directions.
  82721. */
  82722. export class PointParticleEmitter implements IParticleEmitterType {
  82723. /**
  82724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82725. */
  82726. direction1: Vector3;
  82727. /**
  82728. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82729. */
  82730. direction2: Vector3;
  82731. /**
  82732. * Creates a new instance PointParticleEmitter
  82733. */
  82734. constructor();
  82735. /**
  82736. * Called by the particle System when the direction is computed for the created particle.
  82737. * @param worldMatrix is the world matrix of the particle system
  82738. * @param directionToUpdate is the direction vector to update with the result
  82739. * @param particle is the particle we are computed the direction for
  82740. */
  82741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82742. /**
  82743. * Called by the particle System when the position is computed for the created particle.
  82744. * @param worldMatrix is the world matrix of the particle system
  82745. * @param positionToUpdate is the position vector to update with the result
  82746. * @param particle is the particle we are computed the position for
  82747. */
  82748. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82749. /**
  82750. * Clones the current emitter and returns a copy of it
  82751. * @returns the new emitter
  82752. */
  82753. clone(): PointParticleEmitter;
  82754. /**
  82755. * Called by the GPUParticleSystem to setup the update shader
  82756. * @param effect defines the update shader
  82757. */
  82758. applyToShader(effect: Effect): void;
  82759. /**
  82760. * Returns a string to use to update the GPU particles update shader
  82761. * @returns a string containng the defines string
  82762. */
  82763. getEffectDefines(): string;
  82764. /**
  82765. * Returns the string "PointParticleEmitter"
  82766. * @returns a string containing the class name
  82767. */
  82768. getClassName(): string;
  82769. /**
  82770. * Serializes the particle system to a JSON object.
  82771. * @returns the JSON object
  82772. */
  82773. serialize(): any;
  82774. /**
  82775. * Parse properties from a JSON object
  82776. * @param serializationObject defines the JSON object
  82777. */
  82778. parse(serializationObject: any): void;
  82779. }
  82780. }
  82781. declare module BABYLON {
  82782. /**
  82783. * Particle emitter emitting particles from the inside of a sphere.
  82784. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82785. */
  82786. export class SphereParticleEmitter implements IParticleEmitterType {
  82787. /**
  82788. * The radius of the emission sphere.
  82789. */
  82790. radius: number;
  82791. /**
  82792. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82793. */
  82794. radiusRange: number;
  82795. /**
  82796. * How much to randomize the particle direction [0-1].
  82797. */
  82798. directionRandomizer: number;
  82799. /**
  82800. * Creates a new instance SphereParticleEmitter
  82801. * @param radius the radius of the emission sphere (1 by default)
  82802. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82803. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82804. */
  82805. constructor(
  82806. /**
  82807. * The radius of the emission sphere.
  82808. */
  82809. radius?: number,
  82810. /**
  82811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82812. */
  82813. radiusRange?: number,
  82814. /**
  82815. * How much to randomize the particle direction [0-1].
  82816. */
  82817. directionRandomizer?: number);
  82818. /**
  82819. * Called by the particle System when the direction is computed for the created particle.
  82820. * @param worldMatrix is the world matrix of the particle system
  82821. * @param directionToUpdate is the direction vector to update with the result
  82822. * @param particle is the particle we are computed the direction for
  82823. */
  82824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82825. /**
  82826. * Called by the particle System when the position is computed for the created particle.
  82827. * @param worldMatrix is the world matrix of the particle system
  82828. * @param positionToUpdate is the position vector to update with the result
  82829. * @param particle is the particle we are computed the position for
  82830. */
  82831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82832. /**
  82833. * Clones the current emitter and returns a copy of it
  82834. * @returns the new emitter
  82835. */
  82836. clone(): SphereParticleEmitter;
  82837. /**
  82838. * Called by the GPUParticleSystem to setup the update shader
  82839. * @param effect defines the update shader
  82840. */
  82841. applyToShader(effect: Effect): void;
  82842. /**
  82843. * Returns a string to use to update the GPU particles update shader
  82844. * @returns a string containng the defines string
  82845. */
  82846. getEffectDefines(): string;
  82847. /**
  82848. * Returns the string "SphereParticleEmitter"
  82849. * @returns a string containing the class name
  82850. */
  82851. getClassName(): string;
  82852. /**
  82853. * Serializes the particle system to a JSON object.
  82854. * @returns the JSON object
  82855. */
  82856. serialize(): any;
  82857. /**
  82858. * Parse properties from a JSON object
  82859. * @param serializationObject defines the JSON object
  82860. */
  82861. parse(serializationObject: any): void;
  82862. }
  82863. /**
  82864. * Particle emitter emitting particles from the inside of a sphere.
  82865. * It emits the particles randomly between two vectors.
  82866. */
  82867. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  82868. /**
  82869. * The min limit of the emission direction.
  82870. */
  82871. direction1: Vector3;
  82872. /**
  82873. * The max limit of the emission direction.
  82874. */
  82875. direction2: Vector3;
  82876. /**
  82877. * Creates a new instance SphereDirectedParticleEmitter
  82878. * @param radius the radius of the emission sphere (1 by default)
  82879. * @param direction1 the min limit of the emission direction (up vector by default)
  82880. * @param direction2 the max limit of the emission direction (up vector by default)
  82881. */
  82882. constructor(radius?: number,
  82883. /**
  82884. * The min limit of the emission direction.
  82885. */
  82886. direction1?: Vector3,
  82887. /**
  82888. * The max limit of the emission direction.
  82889. */
  82890. direction2?: Vector3);
  82891. /**
  82892. * Called by the particle System when the direction is computed for the created particle.
  82893. * @param worldMatrix is the world matrix of the particle system
  82894. * @param directionToUpdate is the direction vector to update with the result
  82895. * @param particle is the particle we are computed the direction for
  82896. */
  82897. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82898. /**
  82899. * Clones the current emitter and returns a copy of it
  82900. * @returns the new emitter
  82901. */
  82902. clone(): SphereDirectedParticleEmitter;
  82903. /**
  82904. * Called by the GPUParticleSystem to setup the update shader
  82905. * @param effect defines the update shader
  82906. */
  82907. applyToShader(effect: Effect): void;
  82908. /**
  82909. * Returns a string to use to update the GPU particles update shader
  82910. * @returns a string containng the defines string
  82911. */
  82912. getEffectDefines(): string;
  82913. /**
  82914. * Returns the string "SphereDirectedParticleEmitter"
  82915. * @returns a string containing the class name
  82916. */
  82917. getClassName(): string;
  82918. /**
  82919. * Serializes the particle system to a JSON object.
  82920. * @returns the JSON object
  82921. */
  82922. serialize(): any;
  82923. /**
  82924. * Parse properties from a JSON object
  82925. * @param serializationObject defines the JSON object
  82926. */
  82927. parse(serializationObject: any): void;
  82928. }
  82929. }
  82930. declare module BABYLON {
  82931. /**
  82932. * Interface representing a particle system in Babylon.js.
  82933. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  82934. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  82935. */
  82936. export interface IParticleSystem {
  82937. /**
  82938. * List of animations used by the particle system.
  82939. */
  82940. animations: Animation[];
  82941. /**
  82942. * The id of the Particle system.
  82943. */
  82944. id: string;
  82945. /**
  82946. * The name of the Particle system.
  82947. */
  82948. name: string;
  82949. /**
  82950. * The emitter represents the Mesh or position we are attaching the particle system to.
  82951. */
  82952. emitter: Nullable<AbstractMesh | Vector3>;
  82953. /**
  82954. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82955. */
  82956. isBillboardBased: boolean;
  82957. /**
  82958. * The rendering group used by the Particle system to chose when to render.
  82959. */
  82960. renderingGroupId: number;
  82961. /**
  82962. * The layer mask we are rendering the particles through.
  82963. */
  82964. layerMask: number;
  82965. /**
  82966. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82967. */
  82968. updateSpeed: number;
  82969. /**
  82970. * The amount of time the particle system is running (depends of the overall update speed).
  82971. */
  82972. targetStopDuration: number;
  82973. /**
  82974. * The texture used to render each particle. (this can be a spritesheet)
  82975. */
  82976. particleTexture: Nullable<Texture>;
  82977. /**
  82978. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  82979. */
  82980. blendMode: number;
  82981. /**
  82982. * Minimum life time of emitting particles.
  82983. */
  82984. minLifeTime: number;
  82985. /**
  82986. * Maximum life time of emitting particles.
  82987. */
  82988. maxLifeTime: number;
  82989. /**
  82990. * Minimum Size of emitting particles.
  82991. */
  82992. minSize: number;
  82993. /**
  82994. * Maximum Size of emitting particles.
  82995. */
  82996. maxSize: number;
  82997. /**
  82998. * Minimum scale of emitting particles on X axis.
  82999. */
  83000. minScaleX: number;
  83001. /**
  83002. * Maximum scale of emitting particles on X axis.
  83003. */
  83004. maxScaleX: number;
  83005. /**
  83006. * Minimum scale of emitting particles on Y axis.
  83007. */
  83008. minScaleY: number;
  83009. /**
  83010. * Maximum scale of emitting particles on Y axis.
  83011. */
  83012. maxScaleY: number;
  83013. /**
  83014. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83015. */
  83016. color1: Color4;
  83017. /**
  83018. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83019. */
  83020. color2: Color4;
  83021. /**
  83022. * Color the particle will have at the end of its lifetime.
  83023. */
  83024. colorDead: Color4;
  83025. /**
  83026. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83027. */
  83028. emitRate: number;
  83029. /**
  83030. * You can use gravity if you want to give an orientation to your particles.
  83031. */
  83032. gravity: Vector3;
  83033. /**
  83034. * Minimum power of emitting particles.
  83035. */
  83036. minEmitPower: number;
  83037. /**
  83038. * Maximum power of emitting particles.
  83039. */
  83040. maxEmitPower: number;
  83041. /**
  83042. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83043. */
  83044. minAngularSpeed: number;
  83045. /**
  83046. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83047. */
  83048. maxAngularSpeed: number;
  83049. /**
  83050. * Gets or sets the minimal initial rotation in radians.
  83051. */
  83052. minInitialRotation: number;
  83053. /**
  83054. * Gets or sets the maximal initial rotation in radians.
  83055. */
  83056. maxInitialRotation: number;
  83057. /**
  83058. * The particle emitter type defines the emitter used by the particle system.
  83059. * It can be for example box, sphere, or cone...
  83060. */
  83061. particleEmitterType: Nullable<IParticleEmitterType>;
  83062. /**
  83063. * Defines the delay in milliseconds before starting the system (0 by default)
  83064. */
  83065. startDelay: number;
  83066. /**
  83067. * 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
  83068. */
  83069. preWarmCycles: number;
  83070. /**
  83071. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83072. */
  83073. preWarmStepOffset: number;
  83074. /**
  83075. * 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)
  83076. */
  83077. spriteCellChangeSpeed: number;
  83078. /**
  83079. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83080. */
  83081. startSpriteCellID: number;
  83082. /**
  83083. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83084. */
  83085. endSpriteCellID: number;
  83086. /**
  83087. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83088. */
  83089. spriteCellWidth: number;
  83090. /**
  83091. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83092. */
  83093. spriteCellHeight: number;
  83094. /**
  83095. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83096. */
  83097. spriteRandomStartCell: boolean;
  83098. /**
  83099. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83100. */
  83101. isAnimationSheetEnabled: boolean;
  83102. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83103. translationPivot: Vector2;
  83104. /**
  83105. * Gets or sets a texture used to add random noise to particle positions
  83106. */
  83107. noiseTexture: Nullable<BaseTexture>;
  83108. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83109. noiseStrength: Vector3;
  83110. /**
  83111. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83112. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83113. */
  83114. billboardMode: number;
  83115. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83116. limitVelocityDamping: number;
  83117. /**
  83118. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83119. */
  83120. beginAnimationOnStart: boolean;
  83121. /**
  83122. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83123. */
  83124. beginAnimationFrom: number;
  83125. /**
  83126. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83127. */
  83128. beginAnimationTo: number;
  83129. /**
  83130. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83131. */
  83132. beginAnimationLoop: boolean;
  83133. /**
  83134. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83135. */
  83136. disposeOnStop: boolean;
  83137. /**
  83138. * Gets the maximum number of particles active at the same time.
  83139. * @returns The max number of active particles.
  83140. */
  83141. getCapacity(): number;
  83142. /**
  83143. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83144. * @returns True if it has been started, otherwise false.
  83145. */
  83146. isStarted(): boolean;
  83147. /**
  83148. * Animates the particle system for this frame.
  83149. */
  83150. animate(): void;
  83151. /**
  83152. * Renders the particle system in its current state.
  83153. * @returns the current number of particles
  83154. */
  83155. render(): number;
  83156. /**
  83157. * Dispose the particle system and frees its associated resources.
  83158. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83159. */
  83160. dispose(disposeTexture?: boolean): void;
  83161. /**
  83162. * Clones the particle system.
  83163. * @param name The name of the cloned object
  83164. * @param newEmitter The new emitter to use
  83165. * @returns the cloned particle system
  83166. */
  83167. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83168. /**
  83169. * Serializes the particle system to a JSON object.
  83170. * @returns the JSON object
  83171. */
  83172. serialize(): any;
  83173. /**
  83174. * Rebuild the particle system
  83175. */
  83176. rebuild(): void;
  83177. /**
  83178. * Starts the particle system and begins to emit
  83179. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83180. */
  83181. start(delay?: number): void;
  83182. /**
  83183. * Stops the particle system.
  83184. */
  83185. stop(): void;
  83186. /**
  83187. * Remove all active particles
  83188. */
  83189. reset(): void;
  83190. /**
  83191. * Is this system ready to be used/rendered
  83192. * @return true if the system is ready
  83193. */
  83194. isReady(): boolean;
  83195. /**
  83196. * Adds a new color gradient
  83197. * @param gradient defines the gradient to use (between 0 and 1)
  83198. * @param color1 defines the color to affect to the specified gradient
  83199. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83200. * @returns the current particle system
  83201. */
  83202. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83203. /**
  83204. * Remove a specific color gradient
  83205. * @param gradient defines the gradient to remove
  83206. * @returns the current particle system
  83207. */
  83208. removeColorGradient(gradient: number): IParticleSystem;
  83209. /**
  83210. * Adds a new size gradient
  83211. * @param gradient defines the gradient to use (between 0 and 1)
  83212. * @param factor defines the size factor to affect to the specified gradient
  83213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83214. * @returns the current particle system
  83215. */
  83216. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83217. /**
  83218. * Remove a specific size gradient
  83219. * @param gradient defines the gradient to remove
  83220. * @returns the current particle system
  83221. */
  83222. removeSizeGradient(gradient: number): IParticleSystem;
  83223. /**
  83224. * Gets the current list of color gradients.
  83225. * You must use addColorGradient and removeColorGradient to udpate this list
  83226. * @returns the list of color gradients
  83227. */
  83228. getColorGradients(): Nullable<Array<ColorGradient>>;
  83229. /**
  83230. * Gets the current list of size gradients.
  83231. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83232. * @returns the list of size gradients
  83233. */
  83234. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83235. /**
  83236. * Gets the current list of angular speed gradients.
  83237. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83238. * @returns the list of angular speed gradients
  83239. */
  83240. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83241. /**
  83242. * Adds a new angular speed gradient
  83243. * @param gradient defines the gradient to use (between 0 and 1)
  83244. * @param factor defines the angular speed to affect to the specified gradient
  83245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83246. * @returns the current particle system
  83247. */
  83248. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83249. /**
  83250. * Remove a specific angular speed gradient
  83251. * @param gradient defines the gradient to remove
  83252. * @returns the current particle system
  83253. */
  83254. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83255. /**
  83256. * Gets the current list of velocity gradients.
  83257. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83258. * @returns the list of velocity gradients
  83259. */
  83260. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83261. /**
  83262. * Adds a new velocity gradient
  83263. * @param gradient defines the gradient to use (between 0 and 1)
  83264. * @param factor defines the velocity to affect to the specified gradient
  83265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83266. * @returns the current particle system
  83267. */
  83268. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83269. /**
  83270. * Remove a specific velocity gradient
  83271. * @param gradient defines the gradient to remove
  83272. * @returns the current particle system
  83273. */
  83274. removeVelocityGradient(gradient: number): IParticleSystem;
  83275. /**
  83276. * Gets the current list of limit velocity gradients.
  83277. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83278. * @returns the list of limit velocity gradients
  83279. */
  83280. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83281. /**
  83282. * Adds a new limit velocity gradient
  83283. * @param gradient defines the gradient to use (between 0 and 1)
  83284. * @param factor defines the limit velocity to affect to the specified gradient
  83285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83286. * @returns the current particle system
  83287. */
  83288. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83289. /**
  83290. * Remove a specific limit velocity gradient
  83291. * @param gradient defines the gradient to remove
  83292. * @returns the current particle system
  83293. */
  83294. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83295. /**
  83296. * Adds a new drag gradient
  83297. * @param gradient defines the gradient to use (between 0 and 1)
  83298. * @param factor defines the drag to affect to the specified gradient
  83299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83300. * @returns the current particle system
  83301. */
  83302. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83303. /**
  83304. * Remove a specific drag gradient
  83305. * @param gradient defines the gradient to remove
  83306. * @returns the current particle system
  83307. */
  83308. removeDragGradient(gradient: number): IParticleSystem;
  83309. /**
  83310. * Gets the current list of drag gradients.
  83311. * You must use addDragGradient and removeDragGradient to udpate this list
  83312. * @returns the list of drag gradients
  83313. */
  83314. getDragGradients(): Nullable<Array<FactorGradient>>;
  83315. /**
  83316. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83317. * @param gradient defines the gradient to use (between 0 and 1)
  83318. * @param factor defines the emit rate to affect to the specified gradient
  83319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83320. * @returns the current particle system
  83321. */
  83322. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83323. /**
  83324. * Remove a specific emit rate gradient
  83325. * @param gradient defines the gradient to remove
  83326. * @returns the current particle system
  83327. */
  83328. removeEmitRateGradient(gradient: number): IParticleSystem;
  83329. /**
  83330. * Gets the current list of emit rate gradients.
  83331. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83332. * @returns the list of emit rate gradients
  83333. */
  83334. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83335. /**
  83336. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83337. * @param gradient defines the gradient to use (between 0 and 1)
  83338. * @param factor defines the start size to affect to the specified gradient
  83339. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83340. * @returns the current particle system
  83341. */
  83342. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83343. /**
  83344. * Remove a specific start size gradient
  83345. * @param gradient defines the gradient to remove
  83346. * @returns the current particle system
  83347. */
  83348. removeStartSizeGradient(gradient: number): IParticleSystem;
  83349. /**
  83350. * Gets the current list of start size gradients.
  83351. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83352. * @returns the list of start size gradients
  83353. */
  83354. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83355. /**
  83356. * Adds a new life time gradient
  83357. * @param gradient defines the gradient to use (between 0 and 1)
  83358. * @param factor defines the life time factor to affect to the specified gradient
  83359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83360. * @returns the current particle system
  83361. */
  83362. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83363. /**
  83364. * Remove a specific life time gradient
  83365. * @param gradient defines the gradient to remove
  83366. * @returns the current particle system
  83367. */
  83368. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83369. /**
  83370. * Gets the current list of life time gradients.
  83371. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83372. * @returns the list of life time gradients
  83373. */
  83374. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83375. /**
  83376. * Gets the current list of color gradients.
  83377. * You must use addColorGradient and removeColorGradient to udpate this list
  83378. * @returns the list of color gradients
  83379. */
  83380. getColorGradients(): Nullable<Array<ColorGradient>>;
  83381. /**
  83382. * Adds a new ramp gradient used to remap particle colors
  83383. * @param gradient defines the gradient to use (between 0 and 1)
  83384. * @param color defines the color to affect to the specified gradient
  83385. * @returns the current particle system
  83386. */
  83387. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83388. /**
  83389. * Gets the current list of ramp gradients.
  83390. * You must use addRampGradient and removeRampGradient to udpate this list
  83391. * @returns the list of ramp gradients
  83392. */
  83393. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83394. /** Gets or sets a boolean indicating that ramp gradients must be used
  83395. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83396. */
  83397. useRampGradients: boolean;
  83398. /**
  83399. * Adds a new color remap gradient
  83400. * @param gradient defines the gradient to use (between 0 and 1)
  83401. * @param min defines the color remap minimal range
  83402. * @param max defines the color remap maximal range
  83403. * @returns the current particle system
  83404. */
  83405. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83406. /**
  83407. * Gets the current list of color remap gradients.
  83408. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83409. * @returns the list of color remap gradients
  83410. */
  83411. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83412. /**
  83413. * Adds a new alpha remap gradient
  83414. * @param gradient defines the gradient to use (between 0 and 1)
  83415. * @param min defines the alpha remap minimal range
  83416. * @param max defines the alpha remap maximal range
  83417. * @returns the current particle system
  83418. */
  83419. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83420. /**
  83421. * Gets the current list of alpha remap gradients.
  83422. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83423. * @returns the list of alpha remap gradients
  83424. */
  83425. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83426. /**
  83427. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83430. * @returns the emitter
  83431. */
  83432. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83433. /**
  83434. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83435. * @param radius The radius of the hemisphere to emit from
  83436. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83437. * @returns the emitter
  83438. */
  83439. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83440. /**
  83441. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83442. * @param radius The radius of the sphere to emit from
  83443. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83444. * @returns the emitter
  83445. */
  83446. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83447. /**
  83448. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83449. * @param radius The radius of the sphere to emit from
  83450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83452. * @returns the emitter
  83453. */
  83454. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83455. /**
  83456. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83457. * @param radius The radius of the emission cylinder
  83458. * @param height The height of the emission cylinder
  83459. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83460. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83461. * @returns the emitter
  83462. */
  83463. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83464. /**
  83465. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83466. * @param radius The radius of the cylinder to emit from
  83467. * @param height The height of the emission cylinder
  83468. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83471. * @returns the emitter
  83472. */
  83473. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83474. /**
  83475. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83476. * @param radius The radius of the cone to emit from
  83477. * @param angle The base angle of the cone
  83478. * @returns the emitter
  83479. */
  83480. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83481. /**
  83482. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83485. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83486. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83487. * @returns the emitter
  83488. */
  83489. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83490. /**
  83491. * Get hosting scene
  83492. * @returns the scene
  83493. */
  83494. getScene(): Scene;
  83495. }
  83496. }
  83497. declare module BABYLON {
  83498. /**
  83499. * Creates an instance based on a source mesh.
  83500. */
  83501. export class InstancedMesh extends AbstractMesh {
  83502. private _sourceMesh;
  83503. private _currentLOD;
  83504. /** @hidden */
  83505. _indexInSourceMeshInstanceArray: number;
  83506. constructor(name: string, source: Mesh);
  83507. /**
  83508. * Returns the string "InstancedMesh".
  83509. */
  83510. getClassName(): string;
  83511. /** Gets the list of lights affecting that mesh */
  83512. readonly lightSources: Light[];
  83513. _resyncLightSources(): void;
  83514. _resyncLighSource(light: Light): void;
  83515. _removeLightSource(light: Light, dispose: boolean): void;
  83516. /**
  83517. * If the source mesh receives shadows
  83518. */
  83519. readonly receiveShadows: boolean;
  83520. /**
  83521. * The material of the source mesh
  83522. */
  83523. readonly material: Nullable<Material>;
  83524. /**
  83525. * Visibility of the source mesh
  83526. */
  83527. readonly visibility: number;
  83528. /**
  83529. * Skeleton of the source mesh
  83530. */
  83531. readonly skeleton: Nullable<Skeleton>;
  83532. /**
  83533. * Rendering ground id of the source mesh
  83534. */
  83535. renderingGroupId: number;
  83536. /**
  83537. * Returns the total number of vertices (integer).
  83538. */
  83539. getTotalVertices(): number;
  83540. /**
  83541. * Returns a positive integer : the total number of indices in this mesh geometry.
  83542. * @returns the numner of indices or zero if the mesh has no geometry.
  83543. */
  83544. getTotalIndices(): number;
  83545. /**
  83546. * The source mesh of the instance
  83547. */
  83548. readonly sourceMesh: Mesh;
  83549. /**
  83550. * Is this node ready to be used/rendered
  83551. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83552. * @return {boolean} is it ready
  83553. */
  83554. isReady(completeCheck?: boolean): boolean;
  83555. /**
  83556. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83557. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83558. * @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.
  83559. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83560. */
  83561. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  83562. /**
  83563. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83564. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83565. * The `data` are either a numeric array either a Float32Array.
  83566. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83567. * 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).
  83568. * Note that a new underlying VertexBuffer object is created each call.
  83569. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83570. *
  83571. * Possible `kind` values :
  83572. * - VertexBuffer.PositionKind
  83573. * - VertexBuffer.UVKind
  83574. * - VertexBuffer.UV2Kind
  83575. * - VertexBuffer.UV3Kind
  83576. * - VertexBuffer.UV4Kind
  83577. * - VertexBuffer.UV5Kind
  83578. * - VertexBuffer.UV6Kind
  83579. * - VertexBuffer.ColorKind
  83580. * - VertexBuffer.MatricesIndicesKind
  83581. * - VertexBuffer.MatricesIndicesExtraKind
  83582. * - VertexBuffer.MatricesWeightsKind
  83583. * - VertexBuffer.MatricesWeightsExtraKind
  83584. *
  83585. * Returns the Mesh.
  83586. */
  83587. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83588. /**
  83589. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83590. * If the mesh has no geometry, it is simply returned as it is.
  83591. * The `data` are either a numeric array either a Float32Array.
  83592. * No new underlying VertexBuffer object is created.
  83593. * 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.
  83594. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83595. *
  83596. * Possible `kind` values :
  83597. * - VertexBuffer.PositionKind
  83598. * - VertexBuffer.UVKind
  83599. * - VertexBuffer.UV2Kind
  83600. * - VertexBuffer.UV3Kind
  83601. * - VertexBuffer.UV4Kind
  83602. * - VertexBuffer.UV5Kind
  83603. * - VertexBuffer.UV6Kind
  83604. * - VertexBuffer.ColorKind
  83605. * - VertexBuffer.MatricesIndicesKind
  83606. * - VertexBuffer.MatricesIndicesExtraKind
  83607. * - VertexBuffer.MatricesWeightsKind
  83608. * - VertexBuffer.MatricesWeightsExtraKind
  83609. *
  83610. * Returns the Mesh.
  83611. */
  83612. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83613. /**
  83614. * Sets the mesh indices.
  83615. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83616. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83617. * This method creates a new index buffer each call.
  83618. * Returns the Mesh.
  83619. */
  83620. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  83621. /**
  83622. * Boolean : True if the mesh owns the requested kind of data.
  83623. */
  83624. isVerticesDataPresent(kind: string): boolean;
  83625. /**
  83626. * Returns an array of indices (IndicesArray).
  83627. */
  83628. getIndices(): Nullable<IndicesArray>;
  83629. readonly _positions: Nullable<Vector3[]>;
  83630. /**
  83631. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83632. * This means the mesh underlying bounding box and sphere are recomputed.
  83633. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83634. * @returns the current mesh
  83635. */
  83636. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  83637. /** @hidden */
  83638. _preActivate(): InstancedMesh;
  83639. /** @hidden */
  83640. _activate(renderId: number, intermediateRendering: boolean): boolean;
  83641. /** @hidden */
  83642. _postActivate(): void;
  83643. getWorldMatrix(): Matrix;
  83644. readonly isAnInstance: boolean;
  83645. /**
  83646. * Returns the current associated LOD AbstractMesh.
  83647. */
  83648. getLOD(camera: Camera): AbstractMesh;
  83649. /** @hidden */
  83650. _syncSubMeshes(): InstancedMesh;
  83651. /** @hidden */
  83652. _generatePointsArray(): boolean;
  83653. /**
  83654. * Creates a new InstancedMesh from the current mesh.
  83655. * - name (string) : the cloned mesh name
  83656. * - newParent (optional Node) : the optional Node to parent the clone to.
  83657. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83658. *
  83659. * Returns the clone.
  83660. */
  83661. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83662. /**
  83663. * Disposes the InstancedMesh.
  83664. * Returns nothing.
  83665. */
  83666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83667. }
  83668. }
  83669. declare module BABYLON {
  83670. /**
  83671. * Defines the options associated with the creation of a shader material.
  83672. */
  83673. export interface IShaderMaterialOptions {
  83674. /**
  83675. * Does the material work in alpha blend mode
  83676. */
  83677. needAlphaBlending: boolean;
  83678. /**
  83679. * Does the material work in alpha test mode
  83680. */
  83681. needAlphaTesting: boolean;
  83682. /**
  83683. * The list of attribute names used in the shader
  83684. */
  83685. attributes: string[];
  83686. /**
  83687. * The list of unifrom names used in the shader
  83688. */
  83689. uniforms: string[];
  83690. /**
  83691. * The list of UBO names used in the shader
  83692. */
  83693. uniformBuffers: string[];
  83694. /**
  83695. * The list of sampler names used in the shader
  83696. */
  83697. samplers: string[];
  83698. /**
  83699. * The list of defines used in the shader
  83700. */
  83701. defines: string[];
  83702. }
  83703. /**
  83704. * 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.
  83705. *
  83706. * This returned material effects how the mesh will look based on the code in the shaders.
  83707. *
  83708. * @see http://doc.babylonjs.com/how_to/shader_material
  83709. */
  83710. export class ShaderMaterial extends Material {
  83711. private _shaderPath;
  83712. private _options;
  83713. private _textures;
  83714. private _textureArrays;
  83715. private _floats;
  83716. private _ints;
  83717. private _floatsArrays;
  83718. private _colors3;
  83719. private _colors3Arrays;
  83720. private _colors4;
  83721. private _colors4Arrays;
  83722. private _vectors2;
  83723. private _vectors3;
  83724. private _vectors4;
  83725. private _matrices;
  83726. private _matrices3x3;
  83727. private _matrices2x2;
  83728. private _vectors2Arrays;
  83729. private _vectors3Arrays;
  83730. private _vectors4Arrays;
  83731. private _cachedWorldViewMatrix;
  83732. private _cachedWorldViewProjectionMatrix;
  83733. private _renderId;
  83734. /**
  83735. * Instantiate a new shader material.
  83736. * 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.
  83737. * This returned material effects how the mesh will look based on the code in the shaders.
  83738. * @see http://doc.babylonjs.com/how_to/shader_material
  83739. * @param name Define the name of the material in the scene
  83740. * @param scene Define the scene the material belongs to
  83741. * @param shaderPath Defines the route to the shader code in one of three ways:
  83742. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  83743. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  83744. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  83745. * @param options Define the options used to create the shader
  83746. */
  83747. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  83748. /**
  83749. * Gets the options used to compile the shader.
  83750. * They can be modified to trigger a new compilation
  83751. */
  83752. readonly options: IShaderMaterialOptions;
  83753. /**
  83754. * Gets the current class name of the material e.g. "ShaderMaterial"
  83755. * Mainly use in serialization.
  83756. * @returns the class name
  83757. */
  83758. getClassName(): string;
  83759. /**
  83760. * Specifies if the material will require alpha blending
  83761. * @returns a boolean specifying if alpha blending is needed
  83762. */
  83763. needAlphaBlending(): boolean;
  83764. /**
  83765. * Specifies if this material should be rendered in alpha test mode
  83766. * @returns a boolean specifying if an alpha test is needed.
  83767. */
  83768. needAlphaTesting(): boolean;
  83769. private _checkUniform;
  83770. /**
  83771. * Set a texture in the shader.
  83772. * @param name Define the name of the uniform samplers as defined in the shader
  83773. * @param texture Define the texture to bind to this sampler
  83774. * @return the material itself allowing "fluent" like uniform updates
  83775. */
  83776. setTexture(name: string, texture: Texture): ShaderMaterial;
  83777. /**
  83778. * Set a texture array in the shader.
  83779. * @param name Define the name of the uniform sampler array as defined in the shader
  83780. * @param textures Define the list of textures to bind to this sampler
  83781. * @return the material itself allowing "fluent" like uniform updates
  83782. */
  83783. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83784. /**
  83785. * Set a float in the shader.
  83786. * @param name Define the name of the uniform as defined in the shader
  83787. * @param value Define the value to give to the uniform
  83788. * @return the material itself allowing "fluent" like uniform updates
  83789. */
  83790. setFloat(name: string, value: number): ShaderMaterial;
  83791. /**
  83792. * Set a int in the shader.
  83793. * @param name Define the name of the uniform as defined in the shader
  83794. * @param value Define the value to give to the uniform
  83795. * @return the material itself allowing "fluent" like uniform updates
  83796. */
  83797. setInt(name: string, value: number): ShaderMaterial;
  83798. /**
  83799. * Set an array of floats in the shader.
  83800. * @param name Define the name of the uniform as defined in the shader
  83801. * @param value Define the value to give to the uniform
  83802. * @return the material itself allowing "fluent" like uniform updates
  83803. */
  83804. setFloats(name: string, value: number[]): ShaderMaterial;
  83805. /**
  83806. * Set a vec3 in the shader from a Color3.
  83807. * @param name Define the name of the uniform as defined in the shader
  83808. * @param value Define the value to give to the uniform
  83809. * @return the material itself allowing "fluent" like uniform updates
  83810. */
  83811. setColor3(name: string, value: Color3): ShaderMaterial;
  83812. /**
  83813. * Set a vec3 array in the shader from a Color3 array.
  83814. * @param name Define the name of the uniform as defined in the shader
  83815. * @param value Define the value to give to the uniform
  83816. * @return the material itself allowing "fluent" like uniform updates
  83817. */
  83818. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83819. /**
  83820. * Set a vec4 in the shader from a Color4.
  83821. * @param name Define the name of the uniform as defined in the shader
  83822. * @param value Define the value to give to the uniform
  83823. * @return the material itself allowing "fluent" like uniform updates
  83824. */
  83825. setColor4(name: string, value: Color4): ShaderMaterial;
  83826. /**
  83827. * Set a vec4 array in the shader from a Color4 array.
  83828. * @param name Define the name of the uniform as defined in the shader
  83829. * @param value Define the value to give to the uniform
  83830. * @return the material itself allowing "fluent" like uniform updates
  83831. */
  83832. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83833. /**
  83834. * Set a vec2 in the shader from a Vector2.
  83835. * @param name Define the name of the uniform as defined in the shader
  83836. * @param value Define the value to give to the uniform
  83837. * @return the material itself allowing "fluent" like uniform updates
  83838. */
  83839. setVector2(name: string, value: Vector2): ShaderMaterial;
  83840. /**
  83841. * Set a vec3 in the shader from a Vector3.
  83842. * @param name Define the name of the uniform as defined in the shader
  83843. * @param value Define the value to give to the uniform
  83844. * @return the material itself allowing "fluent" like uniform updates
  83845. */
  83846. setVector3(name: string, value: Vector3): ShaderMaterial;
  83847. /**
  83848. * Set a vec4 in the shader from a Vector4.
  83849. * @param name Define the name of the uniform as defined in the shader
  83850. * @param value Define the value to give to the uniform
  83851. * @return the material itself allowing "fluent" like uniform updates
  83852. */
  83853. setVector4(name: string, value: Vector4): ShaderMaterial;
  83854. /**
  83855. * Set a mat4 in the shader from a Matrix.
  83856. * @param name Define the name of the uniform as defined in the shader
  83857. * @param value Define the value to give to the uniform
  83858. * @return the material itself allowing "fluent" like uniform updates
  83859. */
  83860. setMatrix(name: string, value: Matrix): ShaderMaterial;
  83861. /**
  83862. * Set a mat3 in the shader from a Float32Array.
  83863. * @param name Define the name of the uniform as defined in the shader
  83864. * @param value Define the value to give to the uniform
  83865. * @return the material itself allowing "fluent" like uniform updates
  83866. */
  83867. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  83868. /**
  83869. * Set a mat2 in the shader from a Float32Array.
  83870. * @param name Define the name of the uniform as defined in the shader
  83871. * @param value Define the value to give to the uniform
  83872. * @return the material itself allowing "fluent" like uniform updates
  83873. */
  83874. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  83875. /**
  83876. * Set a vec2 array in the shader from a number array.
  83877. * @param name Define the name of the uniform as defined in the shader
  83878. * @param value Define the value to give to the uniform
  83879. * @return the material itself allowing "fluent" like uniform updates
  83880. */
  83881. setArray2(name: string, value: number[]): ShaderMaterial;
  83882. /**
  83883. * Set a vec3 array in the shader from a number array.
  83884. * @param name Define the name of the uniform as defined in the shader
  83885. * @param value Define the value to give to the uniform
  83886. * @return the material itself allowing "fluent" like uniform updates
  83887. */
  83888. setArray3(name: string, value: number[]): ShaderMaterial;
  83889. /**
  83890. * Set a vec4 array in the shader from a number array.
  83891. * @param name Define the name of the uniform as defined in the shader
  83892. * @param value Define the value to give to the uniform
  83893. * @return the material itself allowing "fluent" like uniform updates
  83894. */
  83895. setArray4(name: string, value: number[]): ShaderMaterial;
  83896. private _checkCache;
  83897. /**
  83898. * Specifies that the submesh is ready to be used
  83899. * @param mesh defines the mesh to check
  83900. * @param subMesh defines which submesh to check
  83901. * @param useInstances specifies that instances should be used
  83902. * @returns a boolean indicating that the submesh is ready or not
  83903. */
  83904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83905. /**
  83906. * Checks if the material is ready to render the requested mesh
  83907. * @param mesh Define the mesh to render
  83908. * @param useInstances Define whether or not the material is used with instances
  83909. * @returns true if ready, otherwise false
  83910. */
  83911. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83912. /**
  83913. * Binds the world matrix to the material
  83914. * @param world defines the world transformation matrix
  83915. */
  83916. bindOnlyWorldMatrix(world: Matrix): void;
  83917. /**
  83918. * Binds the material to the mesh
  83919. * @param world defines the world transformation matrix
  83920. * @param mesh defines the mesh to bind the material to
  83921. */
  83922. bind(world: Matrix, mesh?: Mesh): void;
  83923. /**
  83924. * Gets the active textures from the material
  83925. * @returns an array of textures
  83926. */
  83927. getActiveTextures(): BaseTexture[];
  83928. /**
  83929. * Specifies if the material uses a texture
  83930. * @param texture defines the texture to check against the material
  83931. * @returns a boolean specifying if the material uses the texture
  83932. */
  83933. hasTexture(texture: BaseTexture): boolean;
  83934. /**
  83935. * Makes a duplicate of the material, and gives it a new name
  83936. * @param name defines the new name for the duplicated material
  83937. * @returns the cloned material
  83938. */
  83939. clone(name: string): ShaderMaterial;
  83940. /**
  83941. * Disposes the material
  83942. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83943. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  83944. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  83945. */
  83946. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  83947. /**
  83948. * Serializes this material in a JSON representation
  83949. * @returns the serialized material object
  83950. */
  83951. serialize(): any;
  83952. /**
  83953. * Creates a shader material from parsed shader material data
  83954. * @param source defines the JSON represnetation of the material
  83955. * @param scene defines the hosting scene
  83956. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83957. * @returns a new material
  83958. */
  83959. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  83960. }
  83961. }
  83962. declare module BABYLON {
  83963. /** @hidden */
  83964. export var colorPixelShader: {
  83965. name: string;
  83966. shader: string;
  83967. };
  83968. }
  83969. declare module BABYLON {
  83970. /** @hidden */
  83971. export var colorVertexShader: {
  83972. name: string;
  83973. shader: string;
  83974. };
  83975. }
  83976. declare module BABYLON {
  83977. /**
  83978. * Line mesh
  83979. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83980. */
  83981. export class LinesMesh extends Mesh {
  83982. /**
  83983. * If vertex color should be applied to the mesh
  83984. */
  83985. readonly useVertexColor?: boolean | undefined;
  83986. /**
  83987. * If vertex alpha should be applied to the mesh
  83988. */
  83989. readonly useVertexAlpha?: boolean | undefined;
  83990. /**
  83991. * Color of the line (Default: White)
  83992. */
  83993. color: Color3;
  83994. /**
  83995. * Alpha of the line (Default: 1)
  83996. */
  83997. alpha: number;
  83998. /**
  83999. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84000. * This margin is expressed in world space coordinates, so its value may vary.
  84001. * Default value is 0.1
  84002. */
  84003. intersectionThreshold: number;
  84004. private _colorShader;
  84005. private color4;
  84006. /**
  84007. * Creates a new LinesMesh
  84008. * @param name defines the name
  84009. * @param scene defines the hosting scene
  84010. * @param parent defines the parent mesh if any
  84011. * @param source defines the optional source LinesMesh used to clone data from
  84012. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84013. * When false, achieved by calling a clone(), also passing False.
  84014. * This will make creation of children, recursive.
  84015. * @param useVertexColor defines if this LinesMesh supports vertex color
  84016. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84017. */
  84018. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84019. /**
  84020. * If vertex color should be applied to the mesh
  84021. */
  84022. useVertexColor?: boolean | undefined,
  84023. /**
  84024. * If vertex alpha should be applied to the mesh
  84025. */
  84026. useVertexAlpha?: boolean | undefined);
  84027. private _addClipPlaneDefine;
  84028. private _removeClipPlaneDefine;
  84029. isReady(): boolean;
  84030. /**
  84031. * Returns the string "LineMesh"
  84032. */
  84033. getClassName(): string;
  84034. /**
  84035. * @hidden
  84036. */
  84037. /**
  84038. * @hidden
  84039. */
  84040. material: Material;
  84041. /**
  84042. * @hidden
  84043. */
  84044. readonly checkCollisions: boolean;
  84045. /** @hidden */
  84046. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  84047. /** @hidden */
  84048. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  84049. /**
  84050. * Disposes of the line mesh
  84051. * @param doNotRecurse If children should be disposed
  84052. */
  84053. dispose(doNotRecurse?: boolean): void;
  84054. /**
  84055. * Returns a new LineMesh object cloned from the current one.
  84056. */
  84057. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84058. /**
  84059. * Creates a new InstancedLinesMesh object from the mesh model.
  84060. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84061. * @param name defines the name of the new instance
  84062. * @returns a new InstancedLinesMesh
  84063. */
  84064. createInstance(name: string): InstancedLinesMesh;
  84065. }
  84066. /**
  84067. * Creates an instance based on a source LinesMesh
  84068. */
  84069. export class InstancedLinesMesh extends InstancedMesh {
  84070. /**
  84071. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84072. * This margin is expressed in world space coordinates, so its value may vary.
  84073. * Initilized with the intersectionThreshold value of the source LinesMesh
  84074. */
  84075. intersectionThreshold: number;
  84076. constructor(name: string, source: LinesMesh);
  84077. /**
  84078. * Returns the string "InstancedLinesMesh".
  84079. */
  84080. getClassName(): string;
  84081. }
  84082. }
  84083. declare module BABYLON {
  84084. /** @hidden */
  84085. export var linePixelShader: {
  84086. name: string;
  84087. shader: string;
  84088. };
  84089. }
  84090. declare module BABYLON {
  84091. /** @hidden */
  84092. export var lineVertexShader: {
  84093. name: string;
  84094. shader: string;
  84095. };
  84096. }
  84097. declare module BABYLON {
  84098. interface AbstractMesh {
  84099. /**
  84100. * Gets the edgesRenderer associated with the mesh
  84101. */
  84102. edgesRenderer: Nullable<EdgesRenderer>;
  84103. }
  84104. interface LinesMesh {
  84105. /**
  84106. * Enables the edge rendering mode on the mesh.
  84107. * This mode makes the mesh edges visible
  84108. * @param epsilon defines the maximal distance between two angles to detect a face
  84109. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84110. * @returns the currentAbstractMesh
  84111. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84112. */
  84113. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84114. }
  84115. interface InstancedLinesMesh {
  84116. /**
  84117. * Enables the edge rendering mode on the mesh.
  84118. * This mode makes the mesh edges visible
  84119. * @param epsilon defines the maximal distance between two angles to detect a face
  84120. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84121. * @returns the current InstancedLinesMesh
  84122. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84123. */
  84124. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84125. }
  84126. /**
  84127. * Defines the minimum contract an Edges renderer should follow.
  84128. */
  84129. export interface IEdgesRenderer extends IDisposable {
  84130. /**
  84131. * Gets or sets a boolean indicating if the edgesRenderer is active
  84132. */
  84133. isEnabled: boolean;
  84134. /**
  84135. * Renders the edges of the attached mesh,
  84136. */
  84137. render(): void;
  84138. /**
  84139. * Checks wether or not the edges renderer is ready to render.
  84140. * @return true if ready, otherwise false.
  84141. */
  84142. isReady(): boolean;
  84143. }
  84144. /**
  84145. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84146. */
  84147. export class EdgesRenderer implements IEdgesRenderer {
  84148. /**
  84149. * Define the size of the edges with an orthographic camera
  84150. */
  84151. edgesWidthScalerForOrthographic: number;
  84152. /**
  84153. * Define the size of the edges with a perspective camera
  84154. */
  84155. edgesWidthScalerForPerspective: number;
  84156. protected _source: AbstractMesh;
  84157. protected _linesPositions: number[];
  84158. protected _linesNormals: number[];
  84159. protected _linesIndices: number[];
  84160. protected _epsilon: number;
  84161. protected _indicesCount: number;
  84162. protected _lineShader: ShaderMaterial;
  84163. protected _ib: DataBuffer;
  84164. protected _buffers: {
  84165. [key: string]: Nullable<VertexBuffer>;
  84166. };
  84167. protected _checkVerticesInsteadOfIndices: boolean;
  84168. private _meshRebuildObserver;
  84169. private _meshDisposeObserver;
  84170. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84171. isEnabled: boolean;
  84172. /**
  84173. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84174. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84175. * @param source Mesh used to create edges
  84176. * @param epsilon sum of angles in adjacency to check for edge
  84177. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84178. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84179. */
  84180. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84181. protected _prepareRessources(): void;
  84182. /** @hidden */
  84183. _rebuild(): void;
  84184. /**
  84185. * Releases the required resources for the edges renderer
  84186. */
  84187. dispose(): void;
  84188. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84189. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84190. /**
  84191. * Checks if the pair of p0 and p1 is en edge
  84192. * @param faceIndex
  84193. * @param edge
  84194. * @param faceNormals
  84195. * @param p0
  84196. * @param p1
  84197. * @private
  84198. */
  84199. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84200. /**
  84201. * push line into the position, normal and index buffer
  84202. * @protected
  84203. */
  84204. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84205. /**
  84206. * Generates lines edges from adjacencjes
  84207. * @private
  84208. */
  84209. _generateEdgesLines(): void;
  84210. /**
  84211. * Checks wether or not the edges renderer is ready to render.
  84212. * @return true if ready, otherwise false.
  84213. */
  84214. isReady(): boolean;
  84215. /**
  84216. * Renders the edges of the attached mesh,
  84217. */
  84218. render(): void;
  84219. }
  84220. /**
  84221. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84222. */
  84223. export class LineEdgesRenderer extends EdgesRenderer {
  84224. /**
  84225. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84226. * @param source LineMesh used to generate edges
  84227. * @param epsilon not important (specified angle for edge detection)
  84228. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84229. */
  84230. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84231. /**
  84232. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84233. */
  84234. _generateEdgesLines(): void;
  84235. }
  84236. }
  84237. declare module BABYLON {
  84238. /**
  84239. * This represents the object necessary to create a rendering group.
  84240. * This is exclusively used and created by the rendering manager.
  84241. * To modify the behavior, you use the available helpers in your scene or meshes.
  84242. * @hidden
  84243. */
  84244. export class RenderingGroup {
  84245. index: number;
  84246. private static _zeroVector;
  84247. private _scene;
  84248. private _opaqueSubMeshes;
  84249. private _transparentSubMeshes;
  84250. private _alphaTestSubMeshes;
  84251. private _depthOnlySubMeshes;
  84252. private _particleSystems;
  84253. private _spriteManagers;
  84254. private _opaqueSortCompareFn;
  84255. private _alphaTestSortCompareFn;
  84256. private _transparentSortCompareFn;
  84257. private _renderOpaque;
  84258. private _renderAlphaTest;
  84259. private _renderTransparent;
  84260. /** @hidden */
  84261. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84262. onBeforeTransparentRendering: () => void;
  84263. /**
  84264. * Set the opaque sort comparison function.
  84265. * If null the sub meshes will be render in the order they were created
  84266. */
  84267. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84268. /**
  84269. * Set the alpha test sort comparison function.
  84270. * If null the sub meshes will be render in the order they were created
  84271. */
  84272. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84273. /**
  84274. * Set the transparent sort comparison function.
  84275. * If null the sub meshes will be render in the order they were created
  84276. */
  84277. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84278. /**
  84279. * Creates a new rendering group.
  84280. * @param index The rendering group index
  84281. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84282. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84283. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84284. */
  84285. 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>);
  84286. /**
  84287. * Render all the sub meshes contained in the group.
  84288. * @param customRenderFunction Used to override the default render behaviour of the group.
  84289. * @returns true if rendered some submeshes.
  84290. */
  84291. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84292. /**
  84293. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84294. * @param subMeshes The submeshes to render
  84295. */
  84296. private renderOpaqueSorted;
  84297. /**
  84298. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84299. * @param subMeshes The submeshes to render
  84300. */
  84301. private renderAlphaTestSorted;
  84302. /**
  84303. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84304. * @param subMeshes The submeshes to render
  84305. */
  84306. private renderTransparentSorted;
  84307. /**
  84308. * Renders the submeshes in a specified order.
  84309. * @param subMeshes The submeshes to sort before render
  84310. * @param sortCompareFn The comparison function use to sort
  84311. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84312. * @param transparent Specifies to activate blending if true
  84313. */
  84314. private static renderSorted;
  84315. /**
  84316. * Renders the submeshes in the order they were dispatched (no sort applied).
  84317. * @param subMeshes The submeshes to render
  84318. */
  84319. private static renderUnsorted;
  84320. /**
  84321. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84322. * are rendered back to front if in the same alpha index.
  84323. *
  84324. * @param a The first submesh
  84325. * @param b The second submesh
  84326. * @returns The result of the comparison
  84327. */
  84328. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84329. /**
  84330. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84331. * are rendered back to front.
  84332. *
  84333. * @param a The first submesh
  84334. * @param b The second submesh
  84335. * @returns The result of the comparison
  84336. */
  84337. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84338. /**
  84339. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84340. * are rendered front to back (prevent overdraw).
  84341. *
  84342. * @param a The first submesh
  84343. * @param b The second submesh
  84344. * @returns The result of the comparison
  84345. */
  84346. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84347. /**
  84348. * Resets the different lists of submeshes to prepare a new frame.
  84349. */
  84350. prepare(): void;
  84351. dispose(): void;
  84352. /**
  84353. * Inserts the submesh in its correct queue depending on its material.
  84354. * @param subMesh The submesh to dispatch
  84355. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84356. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84357. */
  84358. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84359. dispatchSprites(spriteManager: ISpriteManager): void;
  84360. dispatchParticles(particleSystem: IParticleSystem): void;
  84361. private _renderParticles;
  84362. private _renderSprites;
  84363. }
  84364. }
  84365. declare module BABYLON {
  84366. /**
  84367. * Interface describing the different options available in the rendering manager
  84368. * regarding Auto Clear between groups.
  84369. */
  84370. export interface IRenderingManagerAutoClearSetup {
  84371. /**
  84372. * Defines whether or not autoclear is enable.
  84373. */
  84374. autoClear: boolean;
  84375. /**
  84376. * Defines whether or not to autoclear the depth buffer.
  84377. */
  84378. depth: boolean;
  84379. /**
  84380. * Defines whether or not to autoclear the stencil buffer.
  84381. */
  84382. stencil: boolean;
  84383. }
  84384. /**
  84385. * This class is used by the onRenderingGroupObservable
  84386. */
  84387. export class RenderingGroupInfo {
  84388. /**
  84389. * The Scene that being rendered
  84390. */
  84391. scene: Scene;
  84392. /**
  84393. * The camera currently used for the rendering pass
  84394. */
  84395. camera: Nullable<Camera>;
  84396. /**
  84397. * The ID of the renderingGroup being processed
  84398. */
  84399. renderingGroupId: number;
  84400. }
  84401. /**
  84402. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84403. * It is enable to manage the different groups as well as the different necessary sort functions.
  84404. * This should not be used directly aside of the few static configurations
  84405. */
  84406. export class RenderingManager {
  84407. /**
  84408. * The max id used for rendering groups (not included)
  84409. */
  84410. static MAX_RENDERINGGROUPS: number;
  84411. /**
  84412. * The min id used for rendering groups (included)
  84413. */
  84414. static MIN_RENDERINGGROUPS: number;
  84415. /**
  84416. * Used to globally prevent autoclearing scenes.
  84417. */
  84418. static AUTOCLEAR: boolean;
  84419. /**
  84420. * @hidden
  84421. */
  84422. _useSceneAutoClearSetup: boolean;
  84423. private _scene;
  84424. private _renderingGroups;
  84425. private _depthStencilBufferAlreadyCleaned;
  84426. private _autoClearDepthStencil;
  84427. private _customOpaqueSortCompareFn;
  84428. private _customAlphaTestSortCompareFn;
  84429. private _customTransparentSortCompareFn;
  84430. private _renderingGroupInfo;
  84431. /**
  84432. * Instantiates a new rendering group for a particular scene
  84433. * @param scene Defines the scene the groups belongs to
  84434. */
  84435. constructor(scene: Scene);
  84436. private _clearDepthStencilBuffer;
  84437. /**
  84438. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84439. * @hidden
  84440. */
  84441. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84442. /**
  84443. * Resets the different information of the group to prepare a new frame
  84444. * @hidden
  84445. */
  84446. reset(): void;
  84447. /**
  84448. * Dispose and release the group and its associated resources.
  84449. * @hidden
  84450. */
  84451. dispose(): void;
  84452. /**
  84453. * Clear the info related to rendering groups preventing retention points during dispose.
  84454. */
  84455. freeRenderingGroups(): void;
  84456. private _prepareRenderingGroup;
  84457. /**
  84458. * Add a sprite manager to the rendering manager in order to render it this frame.
  84459. * @param spriteManager Define the sprite manager to render
  84460. */
  84461. dispatchSprites(spriteManager: ISpriteManager): void;
  84462. /**
  84463. * Add a particle system to the rendering manager in order to render it this frame.
  84464. * @param particleSystem Define the particle system to render
  84465. */
  84466. dispatchParticles(particleSystem: IParticleSystem): void;
  84467. /**
  84468. * Add a submesh to the manager in order to render it this frame
  84469. * @param subMesh The submesh to dispatch
  84470. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84471. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84472. */
  84473. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84474. /**
  84475. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84476. * This allowed control for front to back rendering or reversly depending of the special needs.
  84477. *
  84478. * @param renderingGroupId The rendering group id corresponding to its index
  84479. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84480. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84481. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84482. */
  84483. 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;
  84484. /**
  84485. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84486. *
  84487. * @param renderingGroupId The rendering group id corresponding to its index
  84488. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84489. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84490. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84491. */
  84492. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84493. /**
  84494. * Gets the current auto clear configuration for one rendering group of the rendering
  84495. * manager.
  84496. * @param index the rendering group index to get the information for
  84497. * @returns The auto clear setup for the requested rendering group
  84498. */
  84499. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84500. }
  84501. }
  84502. declare module BABYLON {
  84503. /**
  84504. * This Helps creating a texture that will be created from a camera in your scene.
  84505. * It is basically a dynamic texture that could be used to create special effects for instance.
  84506. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84507. */
  84508. export class RenderTargetTexture extends Texture {
  84509. isCube: boolean;
  84510. /**
  84511. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84512. */
  84513. static readonly REFRESHRATE_RENDER_ONCE: number;
  84514. /**
  84515. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84516. */
  84517. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84518. /**
  84519. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84520. * the central point of your effect and can save a lot of performances.
  84521. */
  84522. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84523. /**
  84524. * Use this predicate to dynamically define the list of mesh you want to render.
  84525. * If set, the renderList property will be overwritten.
  84526. */
  84527. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84528. private _renderList;
  84529. /**
  84530. * Use this list to define the list of mesh you want to render.
  84531. */
  84532. renderList: Nullable<Array<AbstractMesh>>;
  84533. private _hookArray;
  84534. /**
  84535. * Define if particles should be rendered in your texture.
  84536. */
  84537. renderParticles: boolean;
  84538. /**
  84539. * Define if sprites should be rendered in your texture.
  84540. */
  84541. renderSprites: boolean;
  84542. /**
  84543. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84544. */
  84545. coordinatesMode: number;
  84546. /**
  84547. * Define the camera used to render the texture.
  84548. */
  84549. activeCamera: Nullable<Camera>;
  84550. /**
  84551. * Override the render function of the texture with your own one.
  84552. */
  84553. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84554. /**
  84555. * Define if camera post processes should be use while rendering the texture.
  84556. */
  84557. useCameraPostProcesses: boolean;
  84558. /**
  84559. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84560. */
  84561. ignoreCameraViewport: boolean;
  84562. private _postProcessManager;
  84563. private _postProcesses;
  84564. private _resizeObserver;
  84565. /**
  84566. * An event triggered when the texture is unbind.
  84567. */
  84568. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84569. /**
  84570. * An event triggered when the texture is unbind.
  84571. */
  84572. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84573. private _onAfterUnbindObserver;
  84574. /**
  84575. * Set a after unbind callback in the texture.
  84576. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84577. */
  84578. onAfterUnbind: () => void;
  84579. /**
  84580. * An event triggered before rendering the texture
  84581. */
  84582. onBeforeRenderObservable: Observable<number>;
  84583. private _onBeforeRenderObserver;
  84584. /**
  84585. * Set a before render callback in the texture.
  84586. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84587. */
  84588. onBeforeRender: (faceIndex: number) => void;
  84589. /**
  84590. * An event triggered after rendering the texture
  84591. */
  84592. onAfterRenderObservable: Observable<number>;
  84593. private _onAfterRenderObserver;
  84594. /**
  84595. * Set a after render callback in the texture.
  84596. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84597. */
  84598. onAfterRender: (faceIndex: number) => void;
  84599. /**
  84600. * An event triggered after the texture clear
  84601. */
  84602. onClearObservable: Observable<Engine>;
  84603. private _onClearObserver;
  84604. /**
  84605. * Set a clear callback in the texture.
  84606. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84607. */
  84608. onClear: (Engine: Engine) => void;
  84609. /**
  84610. * An event triggered when the texture is resized.
  84611. */
  84612. onResizeObservable: Observable<RenderTargetTexture>;
  84613. /**
  84614. * Define the clear color of the Render Target if it should be different from the scene.
  84615. */
  84616. clearColor: Color4;
  84617. protected _size: number | {
  84618. width: number;
  84619. height: number;
  84620. };
  84621. protected _initialSizeParameter: number | {
  84622. width: number;
  84623. height: number;
  84624. } | {
  84625. ratio: number;
  84626. };
  84627. protected _sizeRatio: Nullable<number>;
  84628. /** @hidden */
  84629. _generateMipMaps: boolean;
  84630. protected _renderingManager: RenderingManager;
  84631. /** @hidden */
  84632. _waitingRenderList: string[];
  84633. protected _doNotChangeAspectRatio: boolean;
  84634. protected _currentRefreshId: number;
  84635. protected _refreshRate: number;
  84636. protected _textureMatrix: Matrix;
  84637. protected _samples: number;
  84638. protected _renderTargetOptions: RenderTargetCreationOptions;
  84639. /**
  84640. * Gets render target creation options that were used.
  84641. */
  84642. readonly renderTargetOptions: RenderTargetCreationOptions;
  84643. protected _engine: Engine;
  84644. protected _onRatioRescale(): void;
  84645. /**
  84646. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84647. * It must define where the camera used to render the texture is set
  84648. */
  84649. boundingBoxPosition: Vector3;
  84650. private _boundingBoxSize;
  84651. /**
  84652. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84653. * When defined, the cubemap will switch to local mode
  84654. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84655. * @example https://www.babylonjs-playground.com/#RNASML
  84656. */
  84657. boundingBoxSize: Vector3;
  84658. /**
  84659. * In case the RTT has been created with a depth texture, get the associated
  84660. * depth texture.
  84661. * Otherwise, return null.
  84662. */
  84663. depthStencilTexture: Nullable<InternalTexture>;
  84664. /**
  84665. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84666. * or used a shadow, depth texture...
  84667. * @param name The friendly name of the texture
  84668. * @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)
  84669. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84670. * @param generateMipMaps True if mip maps need to be generated after render.
  84671. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84672. * @param type The type of the buffer in the RTT (int, half float, float...)
  84673. * @param isCube True if a cube texture needs to be created
  84674. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84675. * @param generateDepthBuffer True to generate a depth buffer
  84676. * @param generateStencilBuffer True to generate a stencil buffer
  84677. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84678. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84679. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84680. */
  84681. constructor(name: string, size: number | {
  84682. width: number;
  84683. height: number;
  84684. } | {
  84685. ratio: number;
  84686. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84687. /**
  84688. * Creates a depth stencil texture.
  84689. * This is only available in WebGL 2 or with the depth texture extension available.
  84690. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84691. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84692. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84693. */
  84694. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84695. private _processSizeParameter;
  84696. /**
  84697. * Define the number of samples to use in case of MSAA.
  84698. * It defaults to one meaning no MSAA has been enabled.
  84699. */
  84700. samples: number;
  84701. /**
  84702. * Resets the refresh counter of the texture and start bak from scratch.
  84703. * Could be useful to regenerate the texture if it is setup to render only once.
  84704. */
  84705. resetRefreshCounter(): void;
  84706. /**
  84707. * Define the refresh rate of the texture or the rendering frequency.
  84708. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84709. */
  84710. refreshRate: number;
  84711. /**
  84712. * Adds a post process to the render target rendering passes.
  84713. * @param postProcess define the post process to add
  84714. */
  84715. addPostProcess(postProcess: PostProcess): void;
  84716. /**
  84717. * Clear all the post processes attached to the render target
  84718. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84719. */
  84720. clearPostProcesses(dispose?: boolean): void;
  84721. /**
  84722. * Remove one of the post process from the list of attached post processes to the texture
  84723. * @param postProcess define the post process to remove from the list
  84724. */
  84725. removePostProcess(postProcess: PostProcess): void;
  84726. /** @hidden */
  84727. _shouldRender(): boolean;
  84728. /**
  84729. * Gets the actual render size of the texture.
  84730. * @returns the width of the render size
  84731. */
  84732. getRenderSize(): number;
  84733. /**
  84734. * Gets the actual render width of the texture.
  84735. * @returns the width of the render size
  84736. */
  84737. getRenderWidth(): number;
  84738. /**
  84739. * Gets the actual render height of the texture.
  84740. * @returns the height of the render size
  84741. */
  84742. getRenderHeight(): number;
  84743. /**
  84744. * Get if the texture can be rescaled or not.
  84745. */
  84746. readonly canRescale: boolean;
  84747. /**
  84748. * Resize the texture using a ratio.
  84749. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84750. */
  84751. scale(ratio: number): void;
  84752. /**
  84753. * Get the texture reflection matrix used to rotate/transform the reflection.
  84754. * @returns the reflection matrix
  84755. */
  84756. getReflectionTextureMatrix(): Matrix;
  84757. /**
  84758. * Resize the texture to a new desired size.
  84759. * Be carrefull as it will recreate all the data in the new texture.
  84760. * @param size Define the new size. It can be:
  84761. * - a number for squared texture,
  84762. * - an object containing { width: number, height: number }
  84763. * - or an object containing a ratio { ratio: number }
  84764. */
  84765. resize(size: number | {
  84766. width: number;
  84767. height: number;
  84768. } | {
  84769. ratio: number;
  84770. }): void;
  84771. /**
  84772. * Renders all the objects from the render list into the texture.
  84773. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84774. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84775. */
  84776. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84777. private _bestReflectionRenderTargetDimension;
  84778. /**
  84779. * @hidden
  84780. * @param faceIndex face index to bind to if this is a cubetexture
  84781. */
  84782. _bindFrameBuffer(faceIndex?: number): void;
  84783. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84784. private renderToTarget;
  84785. /**
  84786. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84787. * This allowed control for front to back rendering or reversly depending of the special needs.
  84788. *
  84789. * @param renderingGroupId The rendering group id corresponding to its index
  84790. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84791. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84792. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84793. */
  84794. 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;
  84795. /**
  84796. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84797. *
  84798. * @param renderingGroupId The rendering group id corresponding to its index
  84799. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84800. */
  84801. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84802. /**
  84803. * Clones the texture.
  84804. * @returns the cloned texture
  84805. */
  84806. clone(): RenderTargetTexture;
  84807. /**
  84808. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84809. * @returns The JSON representation of the texture
  84810. */
  84811. serialize(): any;
  84812. /**
  84813. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84814. */
  84815. disposeFramebufferObjects(): void;
  84816. /**
  84817. * Dispose the texture and release its associated resources.
  84818. */
  84819. dispose(): void;
  84820. /** @hidden */
  84821. _rebuild(): void;
  84822. /**
  84823. * Clear the info related to rendering groups preventing retention point in material dispose.
  84824. */
  84825. freeRenderingGroups(): void;
  84826. /**
  84827. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84828. * @returns the view count
  84829. */
  84830. getViewCount(): number;
  84831. }
  84832. }
  84833. declare module BABYLON {
  84834. /**
  84835. * Base class for the main features of a material in Babylon.js
  84836. */
  84837. export class Material implements IAnimatable {
  84838. /**
  84839. * Returns the triangle fill mode
  84840. */
  84841. static readonly TriangleFillMode: number;
  84842. /**
  84843. * Returns the wireframe mode
  84844. */
  84845. static readonly WireFrameFillMode: number;
  84846. /**
  84847. * Returns the point fill mode
  84848. */
  84849. static readonly PointFillMode: number;
  84850. /**
  84851. * Returns the point list draw mode
  84852. */
  84853. static readonly PointListDrawMode: number;
  84854. /**
  84855. * Returns the line list draw mode
  84856. */
  84857. static readonly LineListDrawMode: number;
  84858. /**
  84859. * Returns the line loop draw mode
  84860. */
  84861. static readonly LineLoopDrawMode: number;
  84862. /**
  84863. * Returns the line strip draw mode
  84864. */
  84865. static readonly LineStripDrawMode: number;
  84866. /**
  84867. * Returns the triangle strip draw mode
  84868. */
  84869. static readonly TriangleStripDrawMode: number;
  84870. /**
  84871. * Returns the triangle fan draw mode
  84872. */
  84873. static readonly TriangleFanDrawMode: number;
  84874. /**
  84875. * Stores the clock-wise side orientation
  84876. */
  84877. static readonly ClockWiseSideOrientation: number;
  84878. /**
  84879. * Stores the counter clock-wise side orientation
  84880. */
  84881. static readonly CounterClockWiseSideOrientation: number;
  84882. /**
  84883. * The dirty texture flag value
  84884. */
  84885. static readonly TextureDirtyFlag: number;
  84886. /**
  84887. * The dirty light flag value
  84888. */
  84889. static readonly LightDirtyFlag: number;
  84890. /**
  84891. * The dirty fresnel flag value
  84892. */
  84893. static readonly FresnelDirtyFlag: number;
  84894. /**
  84895. * The dirty attribute flag value
  84896. */
  84897. static readonly AttributesDirtyFlag: number;
  84898. /**
  84899. * The dirty misc flag value
  84900. */
  84901. static readonly MiscDirtyFlag: number;
  84902. /**
  84903. * The all dirty flag value
  84904. */
  84905. static readonly AllDirtyFlag: number;
  84906. /**
  84907. * The ID of the material
  84908. */
  84909. id: string;
  84910. /**
  84911. * Gets or sets the unique id of the material
  84912. */
  84913. uniqueId: number;
  84914. /**
  84915. * The name of the material
  84916. */
  84917. name: string;
  84918. /**
  84919. * Gets or sets user defined metadata
  84920. */
  84921. metadata: any;
  84922. /**
  84923. * For internal use only. Please do not use.
  84924. */
  84925. reservedDataStore: any;
  84926. /**
  84927. * Specifies if the ready state should be checked on each call
  84928. */
  84929. checkReadyOnEveryCall: boolean;
  84930. /**
  84931. * Specifies if the ready state should be checked once
  84932. */
  84933. checkReadyOnlyOnce: boolean;
  84934. /**
  84935. * The state of the material
  84936. */
  84937. state: string;
  84938. /**
  84939. * The alpha value of the material
  84940. */
  84941. protected _alpha: number;
  84942. /**
  84943. * List of inspectable custom properties (used by the Inspector)
  84944. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84945. */
  84946. inspectableCustomProperties: IInspectable[];
  84947. /**
  84948. * Sets the alpha value of the material
  84949. */
  84950. /**
  84951. * Gets the alpha value of the material
  84952. */
  84953. alpha: number;
  84954. /**
  84955. * Specifies if back face culling is enabled
  84956. */
  84957. protected _backFaceCulling: boolean;
  84958. /**
  84959. * Sets the back-face culling state
  84960. */
  84961. /**
  84962. * Gets the back-face culling state
  84963. */
  84964. backFaceCulling: boolean;
  84965. /**
  84966. * Stores the value for side orientation
  84967. */
  84968. sideOrientation: number;
  84969. /**
  84970. * Callback triggered when the material is compiled
  84971. */
  84972. onCompiled: Nullable<(effect: Effect) => void>;
  84973. /**
  84974. * Callback triggered when an error occurs
  84975. */
  84976. onError: Nullable<(effect: Effect, errors: string) => void>;
  84977. /**
  84978. * Callback triggered to get the render target textures
  84979. */
  84980. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84981. /**
  84982. * Gets a boolean indicating that current material needs to register RTT
  84983. */
  84984. readonly hasRenderTargetTextures: boolean;
  84985. /**
  84986. * Specifies if the material should be serialized
  84987. */
  84988. doNotSerialize: boolean;
  84989. /**
  84990. * @hidden
  84991. */
  84992. _storeEffectOnSubMeshes: boolean;
  84993. /**
  84994. * Stores the animations for the material
  84995. */
  84996. animations: Nullable<Array<Animation>>;
  84997. /**
  84998. * An event triggered when the material is disposed
  84999. */
  85000. onDisposeObservable: Observable<Material>;
  85001. /**
  85002. * An observer which watches for dispose events
  85003. */
  85004. private _onDisposeObserver;
  85005. private _onUnBindObservable;
  85006. /**
  85007. * Called during a dispose event
  85008. */
  85009. onDispose: () => void;
  85010. private _onBindObservable;
  85011. /**
  85012. * An event triggered when the material is bound
  85013. */
  85014. readonly onBindObservable: Observable<AbstractMesh>;
  85015. /**
  85016. * An observer which watches for bind events
  85017. */
  85018. private _onBindObserver;
  85019. /**
  85020. * Called during a bind event
  85021. */
  85022. onBind: (Mesh: AbstractMesh) => void;
  85023. /**
  85024. * An event triggered when the material is unbound
  85025. */
  85026. readonly onUnBindObservable: Observable<Material>;
  85027. /**
  85028. * Stores the value of the alpha mode
  85029. */
  85030. private _alphaMode;
  85031. /**
  85032. * Sets the value of the alpha mode.
  85033. *
  85034. * | Value | Type | Description |
  85035. * | --- | --- | --- |
  85036. * | 0 | ALPHA_DISABLE | |
  85037. * | 1 | ALPHA_ADD | |
  85038. * | 2 | ALPHA_COMBINE | |
  85039. * | 3 | ALPHA_SUBTRACT | |
  85040. * | 4 | ALPHA_MULTIPLY | |
  85041. * | 5 | ALPHA_MAXIMIZED | |
  85042. * | 6 | ALPHA_ONEONE | |
  85043. * | 7 | ALPHA_PREMULTIPLIED | |
  85044. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85045. * | 9 | ALPHA_INTERPOLATE | |
  85046. * | 10 | ALPHA_SCREENMODE | |
  85047. *
  85048. */
  85049. /**
  85050. * Gets the value of the alpha mode
  85051. */
  85052. alphaMode: number;
  85053. /**
  85054. * Stores the state of the need depth pre-pass value
  85055. */
  85056. private _needDepthPrePass;
  85057. /**
  85058. * Sets the need depth pre-pass value
  85059. */
  85060. /**
  85061. * Gets the depth pre-pass value
  85062. */
  85063. needDepthPrePass: boolean;
  85064. /**
  85065. * Specifies if depth writing should be disabled
  85066. */
  85067. disableDepthWrite: boolean;
  85068. /**
  85069. * Specifies if depth writing should be forced
  85070. */
  85071. forceDepthWrite: boolean;
  85072. /**
  85073. * Specifies if there should be a separate pass for culling
  85074. */
  85075. separateCullingPass: boolean;
  85076. /**
  85077. * Stores the state specifing if fog should be enabled
  85078. */
  85079. private _fogEnabled;
  85080. /**
  85081. * Sets the state for enabling fog
  85082. */
  85083. /**
  85084. * Gets the value of the fog enabled state
  85085. */
  85086. fogEnabled: boolean;
  85087. /**
  85088. * Stores the size of points
  85089. */
  85090. pointSize: number;
  85091. /**
  85092. * Stores the z offset value
  85093. */
  85094. zOffset: number;
  85095. /**
  85096. * Gets a value specifying if wireframe mode is enabled
  85097. */
  85098. /**
  85099. * Sets the state of wireframe mode
  85100. */
  85101. wireframe: boolean;
  85102. /**
  85103. * Gets the value specifying if point clouds are enabled
  85104. */
  85105. /**
  85106. * Sets the state of point cloud mode
  85107. */
  85108. pointsCloud: boolean;
  85109. /**
  85110. * Gets the material fill mode
  85111. */
  85112. /**
  85113. * Sets the material fill mode
  85114. */
  85115. fillMode: number;
  85116. /**
  85117. * @hidden
  85118. * Stores the effects for the material
  85119. */
  85120. _effect: Nullable<Effect>;
  85121. /**
  85122. * @hidden
  85123. * Specifies if the material was previously ready
  85124. */
  85125. _wasPreviouslyReady: boolean;
  85126. /**
  85127. * Specifies if uniform buffers should be used
  85128. */
  85129. private _useUBO;
  85130. /**
  85131. * Stores a reference to the scene
  85132. */
  85133. private _scene;
  85134. /**
  85135. * Stores the fill mode state
  85136. */
  85137. private _fillMode;
  85138. /**
  85139. * Specifies if the depth write state should be cached
  85140. */
  85141. private _cachedDepthWriteState;
  85142. /**
  85143. * Stores the uniform buffer
  85144. */
  85145. protected _uniformBuffer: UniformBuffer;
  85146. /** @hidden */
  85147. _indexInSceneMaterialArray: number;
  85148. /** @hidden */
  85149. meshMap: Nullable<{
  85150. [id: string]: AbstractMesh | undefined;
  85151. }>;
  85152. /**
  85153. * Creates a material instance
  85154. * @param name defines the name of the material
  85155. * @param scene defines the scene to reference
  85156. * @param doNotAdd specifies if the material should be added to the scene
  85157. */
  85158. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85159. /**
  85160. * Returns a string representation of the current material
  85161. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85162. * @returns a string with material information
  85163. */
  85164. toString(fullDetails?: boolean): string;
  85165. /**
  85166. * Gets the class name of the material
  85167. * @returns a string with the class name of the material
  85168. */
  85169. getClassName(): string;
  85170. /**
  85171. * Specifies if updates for the material been locked
  85172. */
  85173. readonly isFrozen: boolean;
  85174. /**
  85175. * Locks updates for the material
  85176. */
  85177. freeze(): void;
  85178. /**
  85179. * Unlocks updates for the material
  85180. */
  85181. unfreeze(): void;
  85182. /**
  85183. * Specifies if the material is ready to be used
  85184. * @param mesh defines the mesh to check
  85185. * @param useInstances specifies if instances should be used
  85186. * @returns a boolean indicating if the material is ready to be used
  85187. */
  85188. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85189. /**
  85190. * Specifies that the submesh is ready to be used
  85191. * @param mesh defines the mesh to check
  85192. * @param subMesh defines which submesh to check
  85193. * @param useInstances specifies that instances should be used
  85194. * @returns a boolean indicating that the submesh is ready or not
  85195. */
  85196. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85197. /**
  85198. * Returns the material effect
  85199. * @returns the effect associated with the material
  85200. */
  85201. getEffect(): Nullable<Effect>;
  85202. /**
  85203. * Returns the current scene
  85204. * @returns a Scene
  85205. */
  85206. getScene(): Scene;
  85207. /**
  85208. * Specifies if the material will require alpha blending
  85209. * @returns a boolean specifying if alpha blending is needed
  85210. */
  85211. needAlphaBlending(): boolean;
  85212. /**
  85213. * Specifies if the mesh will require alpha blending
  85214. * @param mesh defines the mesh to check
  85215. * @returns a boolean specifying if alpha blending is needed for the mesh
  85216. */
  85217. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85218. /**
  85219. * Specifies if this material should be rendered in alpha test mode
  85220. * @returns a boolean specifying if an alpha test is needed.
  85221. */
  85222. needAlphaTesting(): boolean;
  85223. /**
  85224. * Gets the texture used for the alpha test
  85225. * @returns the texture to use for alpha testing
  85226. */
  85227. getAlphaTestTexture(): Nullable<BaseTexture>;
  85228. /**
  85229. * Marks the material to indicate that it needs to be re-calculated
  85230. */
  85231. markDirty(): void;
  85232. /** @hidden */
  85233. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85234. /**
  85235. * Binds the material to the mesh
  85236. * @param world defines the world transformation matrix
  85237. * @param mesh defines the mesh to bind the material to
  85238. */
  85239. bind(world: Matrix, mesh?: Mesh): void;
  85240. /**
  85241. * Binds the submesh to the material
  85242. * @param world defines the world transformation matrix
  85243. * @param mesh defines the mesh containing the submesh
  85244. * @param subMesh defines the submesh to bind the material to
  85245. */
  85246. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85247. /**
  85248. * Binds the world matrix to the material
  85249. * @param world defines the world transformation matrix
  85250. */
  85251. bindOnlyWorldMatrix(world: Matrix): void;
  85252. /**
  85253. * Binds the scene's uniform buffer to the effect.
  85254. * @param effect defines the effect to bind to the scene uniform buffer
  85255. * @param sceneUbo defines the uniform buffer storing scene data
  85256. */
  85257. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85258. /**
  85259. * Binds the view matrix to the effect
  85260. * @param effect defines the effect to bind the view matrix to
  85261. */
  85262. bindView(effect: Effect): void;
  85263. /**
  85264. * Binds the view projection matrix to the effect
  85265. * @param effect defines the effect to bind the view projection matrix to
  85266. */
  85267. bindViewProjection(effect: Effect): void;
  85268. /**
  85269. * Specifies if material alpha testing should be turned on for the mesh
  85270. * @param mesh defines the mesh to check
  85271. */
  85272. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85273. /**
  85274. * Processes to execute after binding the material to a mesh
  85275. * @param mesh defines the rendered mesh
  85276. */
  85277. protected _afterBind(mesh?: Mesh): void;
  85278. /**
  85279. * Unbinds the material from the mesh
  85280. */
  85281. unbind(): void;
  85282. /**
  85283. * Gets the active textures from the material
  85284. * @returns an array of textures
  85285. */
  85286. getActiveTextures(): BaseTexture[];
  85287. /**
  85288. * Specifies if the material uses a texture
  85289. * @param texture defines the texture to check against the material
  85290. * @returns a boolean specifying if the material uses the texture
  85291. */
  85292. hasTexture(texture: BaseTexture): boolean;
  85293. /**
  85294. * Makes a duplicate of the material, and gives it a new name
  85295. * @param name defines the new name for the duplicated material
  85296. * @returns the cloned material
  85297. */
  85298. clone(name: string): Nullable<Material>;
  85299. /**
  85300. * Gets the meshes bound to the material
  85301. * @returns an array of meshes bound to the material
  85302. */
  85303. getBindedMeshes(): AbstractMesh[];
  85304. /**
  85305. * Force shader compilation
  85306. * @param mesh defines the mesh associated with this material
  85307. * @param onCompiled defines a function to execute once the material is compiled
  85308. * @param options defines the options to configure the compilation
  85309. */
  85310. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85311. clipPlane: boolean;
  85312. }>): void;
  85313. /**
  85314. * Force shader compilation
  85315. * @param mesh defines the mesh that will use this material
  85316. * @param options defines additional options for compiling the shaders
  85317. * @returns a promise that resolves when the compilation completes
  85318. */
  85319. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85320. clipPlane: boolean;
  85321. }>): Promise<void>;
  85322. private static readonly _AllDirtyCallBack;
  85323. private static readonly _ImageProcessingDirtyCallBack;
  85324. private static readonly _TextureDirtyCallBack;
  85325. private static readonly _FresnelDirtyCallBack;
  85326. private static readonly _MiscDirtyCallBack;
  85327. private static readonly _LightsDirtyCallBack;
  85328. private static readonly _AttributeDirtyCallBack;
  85329. private static _FresnelAndMiscDirtyCallBack;
  85330. private static _TextureAndMiscDirtyCallBack;
  85331. private static readonly _DirtyCallbackArray;
  85332. private static readonly _RunDirtyCallBacks;
  85333. /**
  85334. * Marks a define in the material to indicate that it needs to be re-computed
  85335. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85336. */
  85337. markAsDirty(flag: number): void;
  85338. /**
  85339. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85340. * @param func defines a function which checks material defines against the submeshes
  85341. */
  85342. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85343. /**
  85344. * Indicates that we need to re-calculated for all submeshes
  85345. */
  85346. protected _markAllSubMeshesAsAllDirty(): void;
  85347. /**
  85348. * Indicates that image processing needs to be re-calculated for all submeshes
  85349. */
  85350. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85351. /**
  85352. * Indicates that textures need to be re-calculated for all submeshes
  85353. */
  85354. protected _markAllSubMeshesAsTexturesDirty(): void;
  85355. /**
  85356. * Indicates that fresnel needs to be re-calculated for all submeshes
  85357. */
  85358. protected _markAllSubMeshesAsFresnelDirty(): void;
  85359. /**
  85360. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85361. */
  85362. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85363. /**
  85364. * Indicates that lights need to be re-calculated for all submeshes
  85365. */
  85366. protected _markAllSubMeshesAsLightsDirty(): void;
  85367. /**
  85368. * Indicates that attributes need to be re-calculated for all submeshes
  85369. */
  85370. protected _markAllSubMeshesAsAttributesDirty(): void;
  85371. /**
  85372. * Indicates that misc needs to be re-calculated for all submeshes
  85373. */
  85374. protected _markAllSubMeshesAsMiscDirty(): void;
  85375. /**
  85376. * Indicates that textures and misc need to be re-calculated for all submeshes
  85377. */
  85378. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85379. /**
  85380. * Disposes the material
  85381. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85382. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85383. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85384. */
  85385. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85386. /** @hidden */
  85387. private releaseVertexArrayObject;
  85388. /**
  85389. * Serializes this material
  85390. * @returns the serialized material object
  85391. */
  85392. serialize(): any;
  85393. /**
  85394. * Creates a material from parsed material data
  85395. * @param parsedMaterial defines parsed material data
  85396. * @param scene defines the hosting scene
  85397. * @param rootUrl defines the root URL to use to load textures
  85398. * @returns a new material
  85399. */
  85400. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85401. }
  85402. }
  85403. declare module BABYLON {
  85404. /**
  85405. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85406. * separate meshes. This can be use to improve performances.
  85407. * @see http://doc.babylonjs.com/how_to/multi_materials
  85408. */
  85409. export class MultiMaterial extends Material {
  85410. private _subMaterials;
  85411. /**
  85412. * Gets or Sets the list of Materials used within the multi material.
  85413. * They need to be ordered according to the submeshes order in the associated mesh
  85414. */
  85415. subMaterials: Nullable<Material>[];
  85416. /**
  85417. * Function used to align with Node.getChildren()
  85418. * @returns the list of Materials used within the multi material
  85419. */
  85420. getChildren(): Nullable<Material>[];
  85421. /**
  85422. * Instantiates a new Multi Material
  85423. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85424. * separate meshes. This can be use to improve performances.
  85425. * @see http://doc.babylonjs.com/how_to/multi_materials
  85426. * @param name Define the name in the scene
  85427. * @param scene Define the scene the material belongs to
  85428. */
  85429. constructor(name: string, scene: Scene);
  85430. private _hookArray;
  85431. /**
  85432. * Get one of the submaterial by its index in the submaterials array
  85433. * @param index The index to look the sub material at
  85434. * @returns The Material if the index has been defined
  85435. */
  85436. getSubMaterial(index: number): Nullable<Material>;
  85437. /**
  85438. * Get the list of active textures for the whole sub materials list.
  85439. * @returns All the textures that will be used during the rendering
  85440. */
  85441. getActiveTextures(): BaseTexture[];
  85442. /**
  85443. * Gets the current class name of the material e.g. "MultiMaterial"
  85444. * Mainly use in serialization.
  85445. * @returns the class name
  85446. */
  85447. getClassName(): string;
  85448. /**
  85449. * Checks if the material is ready to render the requested sub mesh
  85450. * @param mesh Define the mesh the submesh belongs to
  85451. * @param subMesh Define the sub mesh to look readyness for
  85452. * @param useInstances Define whether or not the material is used with instances
  85453. * @returns true if ready, otherwise false
  85454. */
  85455. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85456. /**
  85457. * Clones the current material and its related sub materials
  85458. * @param name Define the name of the newly cloned material
  85459. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  85460. * @returns the cloned material
  85461. */
  85462. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  85463. /**
  85464. * Serializes the materials into a JSON representation.
  85465. * @returns the JSON representation
  85466. */
  85467. serialize(): any;
  85468. /**
  85469. * Dispose the material and release its associated resources
  85470. * @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)
  85471. * @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)
  85472. * @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)
  85473. */
  85474. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  85475. /**
  85476. * Creates a MultiMaterial from parsed MultiMaterial data.
  85477. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  85478. * @param scene defines the hosting scene
  85479. * @returns a new MultiMaterial
  85480. */
  85481. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  85482. }
  85483. }
  85484. declare module BABYLON {
  85485. /**
  85486. * Base class for submeshes
  85487. */
  85488. export class BaseSubMesh {
  85489. /** @hidden */
  85490. _materialDefines: Nullable<MaterialDefines>;
  85491. /** @hidden */
  85492. _materialEffect: Nullable<Effect>;
  85493. /**
  85494. * Gets associated effect
  85495. */
  85496. readonly effect: Nullable<Effect>;
  85497. /**
  85498. * Sets associated effect (effect used to render this submesh)
  85499. * @param effect defines the effect to associate with
  85500. * @param defines defines the set of defines used to compile this effect
  85501. */
  85502. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85503. }
  85504. /**
  85505. * Defines a subdivision inside a mesh
  85506. */
  85507. export class SubMesh extends BaseSubMesh implements ICullable {
  85508. /** the material index to use */
  85509. materialIndex: number;
  85510. /** vertex index start */
  85511. verticesStart: number;
  85512. /** vertices count */
  85513. verticesCount: number;
  85514. /** index start */
  85515. indexStart: number;
  85516. /** indices count */
  85517. indexCount: number;
  85518. /** @hidden */
  85519. _linesIndexCount: number;
  85520. private _mesh;
  85521. private _renderingMesh;
  85522. private _boundingInfo;
  85523. private _linesIndexBuffer;
  85524. /** @hidden */
  85525. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85526. /** @hidden */
  85527. _trianglePlanes: Plane[];
  85528. /** @hidden */
  85529. _lastColliderTransformMatrix: Nullable<Matrix>;
  85530. /** @hidden */
  85531. _renderId: number;
  85532. /** @hidden */
  85533. _alphaIndex: number;
  85534. /** @hidden */
  85535. _distanceToCamera: number;
  85536. /** @hidden */
  85537. _id: number;
  85538. private _currentMaterial;
  85539. /**
  85540. * Add a new submesh to a mesh
  85541. * @param materialIndex defines the material index to use
  85542. * @param verticesStart defines vertex index start
  85543. * @param verticesCount defines vertices count
  85544. * @param indexStart defines index start
  85545. * @param indexCount defines indices count
  85546. * @param mesh defines the parent mesh
  85547. * @param renderingMesh defines an optional rendering mesh
  85548. * @param createBoundingBox defines if bounding box should be created for this submesh
  85549. * @returns the new submesh
  85550. */
  85551. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85552. /**
  85553. * Creates a new submesh
  85554. * @param materialIndex defines the material index to use
  85555. * @param verticesStart defines vertex index start
  85556. * @param verticesCount defines vertices count
  85557. * @param indexStart defines index start
  85558. * @param indexCount defines indices count
  85559. * @param mesh defines the parent mesh
  85560. * @param renderingMesh defines an optional rendering mesh
  85561. * @param createBoundingBox defines if bounding box should be created for this submesh
  85562. */
  85563. constructor(
  85564. /** the material index to use */
  85565. materialIndex: number,
  85566. /** vertex index start */
  85567. verticesStart: number,
  85568. /** vertices count */
  85569. verticesCount: number,
  85570. /** index start */
  85571. indexStart: number,
  85572. /** indices count */
  85573. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85574. /**
  85575. * Returns true if this submesh covers the entire parent mesh
  85576. * @ignorenaming
  85577. */
  85578. readonly IsGlobal: boolean;
  85579. /**
  85580. * Returns the submesh BoudingInfo object
  85581. * @returns current bounding info (or mesh's one if the submesh is global)
  85582. */
  85583. getBoundingInfo(): BoundingInfo;
  85584. /**
  85585. * Sets the submesh BoundingInfo
  85586. * @param boundingInfo defines the new bounding info to use
  85587. * @returns the SubMesh
  85588. */
  85589. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85590. /**
  85591. * Returns the mesh of the current submesh
  85592. * @return the parent mesh
  85593. */
  85594. getMesh(): AbstractMesh;
  85595. /**
  85596. * Returns the rendering mesh of the submesh
  85597. * @returns the rendering mesh (could be different from parent mesh)
  85598. */
  85599. getRenderingMesh(): Mesh;
  85600. /**
  85601. * Returns the submesh material
  85602. * @returns null or the current material
  85603. */
  85604. getMaterial(): Nullable<Material>;
  85605. /**
  85606. * Sets a new updated BoundingInfo object to the submesh
  85607. * @param data defines an optional position array to use to determine the bounding info
  85608. * @returns the SubMesh
  85609. */
  85610. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85611. /** @hidden */
  85612. _checkCollision(collider: Collider): boolean;
  85613. /**
  85614. * Updates the submesh BoundingInfo
  85615. * @param world defines the world matrix to use to update the bounding info
  85616. * @returns the submesh
  85617. */
  85618. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85619. /**
  85620. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85621. * @param frustumPlanes defines the frustum planes
  85622. * @returns true if the submesh is intersecting with the frustum
  85623. */
  85624. isInFrustum(frustumPlanes: Plane[]): boolean;
  85625. /**
  85626. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85627. * @param frustumPlanes defines the frustum planes
  85628. * @returns true if the submesh is inside the frustum
  85629. */
  85630. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85631. /**
  85632. * Renders the submesh
  85633. * @param enableAlphaMode defines if alpha needs to be used
  85634. * @returns the submesh
  85635. */
  85636. render(enableAlphaMode: boolean): SubMesh;
  85637. /**
  85638. * @hidden
  85639. */
  85640. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85641. /**
  85642. * Checks if the submesh intersects with a ray
  85643. * @param ray defines the ray to test
  85644. * @returns true is the passed ray intersects the submesh bounding box
  85645. */
  85646. canIntersects(ray: Ray): boolean;
  85647. /**
  85648. * Intersects current submesh with a ray
  85649. * @param ray defines the ray to test
  85650. * @param positions defines mesh's positions array
  85651. * @param indices defines mesh's indices array
  85652. * @param fastCheck defines if only bounding info should be used
  85653. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85654. * @returns intersection info or null if no intersection
  85655. */
  85656. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85657. /** @hidden */
  85658. private _intersectLines;
  85659. /** @hidden */
  85660. private _intersectUnIndexedLines;
  85661. /** @hidden */
  85662. private _intersectTriangles;
  85663. /** @hidden */
  85664. private _intersectUnIndexedTriangles;
  85665. /** @hidden */
  85666. _rebuild(): void;
  85667. /**
  85668. * Creates a new submesh from the passed mesh
  85669. * @param newMesh defines the new hosting mesh
  85670. * @param newRenderingMesh defines an optional rendering mesh
  85671. * @returns the new submesh
  85672. */
  85673. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85674. /**
  85675. * Release associated resources
  85676. */
  85677. dispose(): void;
  85678. /**
  85679. * Gets the class name
  85680. * @returns the string "SubMesh".
  85681. */
  85682. getClassName(): string;
  85683. /**
  85684. * Creates a new submesh from indices data
  85685. * @param materialIndex the index of the main mesh material
  85686. * @param startIndex the index where to start the copy in the mesh indices array
  85687. * @param indexCount the number of indices to copy then from the startIndex
  85688. * @param mesh the main mesh to create the submesh from
  85689. * @param renderingMesh the optional rendering mesh
  85690. * @returns a new submesh
  85691. */
  85692. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85693. }
  85694. }
  85695. declare module BABYLON {
  85696. /**
  85697. * Class used to represent data loading progression
  85698. */
  85699. export class SceneLoaderFlags {
  85700. private static _ForceFullSceneLoadingForIncremental;
  85701. private static _ShowLoadingScreen;
  85702. private static _CleanBoneMatrixWeights;
  85703. private static _loggingLevel;
  85704. /**
  85705. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  85706. */
  85707. static ForceFullSceneLoadingForIncremental: boolean;
  85708. /**
  85709. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  85710. */
  85711. static ShowLoadingScreen: boolean;
  85712. /**
  85713. * Defines the current logging level (while loading the scene)
  85714. * @ignorenaming
  85715. */
  85716. static loggingLevel: number;
  85717. /**
  85718. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  85719. */
  85720. static CleanBoneMatrixWeights: boolean;
  85721. }
  85722. }
  85723. declare module BABYLON {
  85724. /**
  85725. * Class used to store geometry data (vertex buffers + index buffer)
  85726. */
  85727. export class Geometry implements IGetSetVerticesData {
  85728. /**
  85729. * Gets or sets the ID of the geometry
  85730. */
  85731. id: string;
  85732. /**
  85733. * Gets or sets the unique ID of the geometry
  85734. */
  85735. uniqueId: number;
  85736. /**
  85737. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85738. */
  85739. delayLoadState: number;
  85740. /**
  85741. * Gets the file containing the data to load when running in delay load state
  85742. */
  85743. delayLoadingFile: Nullable<string>;
  85744. /**
  85745. * Callback called when the geometry is updated
  85746. */
  85747. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85748. private _scene;
  85749. private _engine;
  85750. private _meshes;
  85751. private _totalVertices;
  85752. /** @hidden */
  85753. _indices: IndicesArray;
  85754. /** @hidden */
  85755. _vertexBuffers: {
  85756. [key: string]: VertexBuffer;
  85757. };
  85758. private _isDisposed;
  85759. private _extend;
  85760. private _boundingBias;
  85761. /** @hidden */
  85762. _delayInfo: Array<string>;
  85763. private _indexBuffer;
  85764. private _indexBufferIsUpdatable;
  85765. /** @hidden */
  85766. _boundingInfo: Nullable<BoundingInfo>;
  85767. /** @hidden */
  85768. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85769. /** @hidden */
  85770. _softwareSkinningFrameId: number;
  85771. private _vertexArrayObjects;
  85772. private _updatable;
  85773. /** @hidden */
  85774. _positions: Nullable<Vector3[]>;
  85775. /**
  85776. * 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
  85777. */
  85778. /**
  85779. * 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
  85780. */
  85781. boundingBias: Vector2;
  85782. /**
  85783. * Static function used to attach a new empty geometry to a mesh
  85784. * @param mesh defines the mesh to attach the geometry to
  85785. * @returns the new Geometry
  85786. */
  85787. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85788. /**
  85789. * Creates a new geometry
  85790. * @param id defines the unique ID
  85791. * @param scene defines the hosting scene
  85792. * @param vertexData defines the VertexData used to get geometry data
  85793. * @param updatable defines if geometry must be updatable (false by default)
  85794. * @param mesh defines the mesh that will be associated with the geometry
  85795. */
  85796. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85797. /**
  85798. * Gets the current extend of the geometry
  85799. */
  85800. readonly extend: {
  85801. minimum: Vector3;
  85802. maximum: Vector3;
  85803. };
  85804. /**
  85805. * Gets the hosting scene
  85806. * @returns the hosting Scene
  85807. */
  85808. getScene(): Scene;
  85809. /**
  85810. * Gets the hosting engine
  85811. * @returns the hosting Engine
  85812. */
  85813. getEngine(): Engine;
  85814. /**
  85815. * Defines if the geometry is ready to use
  85816. * @returns true if the geometry is ready to be used
  85817. */
  85818. isReady(): boolean;
  85819. /**
  85820. * Gets a value indicating that the geometry should not be serialized
  85821. */
  85822. readonly doNotSerialize: boolean;
  85823. /** @hidden */
  85824. _rebuild(): void;
  85825. /**
  85826. * Affects all geometry data in one call
  85827. * @param vertexData defines the geometry data
  85828. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85829. */
  85830. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85831. /**
  85832. * Set specific vertex data
  85833. * @param kind defines the data kind (Position, normal, etc...)
  85834. * @param data defines the vertex data to use
  85835. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85836. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85837. */
  85838. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85839. /**
  85840. * Removes a specific vertex data
  85841. * @param kind defines the data kind (Position, normal, etc...)
  85842. */
  85843. removeVerticesData(kind: string): void;
  85844. /**
  85845. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85846. * @param buffer defines the vertex buffer to use
  85847. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85848. */
  85849. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85850. /**
  85851. * Update a specific vertex buffer
  85852. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85853. * It will do nothing if the buffer is not updatable
  85854. * @param kind defines the data kind (Position, normal, etc...)
  85855. * @param data defines the data to use
  85856. * @param offset defines the offset in the target buffer where to store the data
  85857. * @param useBytes set to true if the offset is in bytes
  85858. */
  85859. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85860. /**
  85861. * Update a specific vertex buffer
  85862. * This function will create a new buffer if the current one is not updatable
  85863. * @param kind defines the data kind (Position, normal, etc...)
  85864. * @param data defines the data to use
  85865. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85866. */
  85867. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85868. private _updateBoundingInfo;
  85869. /** @hidden */
  85870. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85871. /**
  85872. * Gets total number of vertices
  85873. * @returns the total number of vertices
  85874. */
  85875. getTotalVertices(): number;
  85876. /**
  85877. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85878. * @param kind defines the data kind (Position, normal, etc...)
  85879. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85881. * @returns a float array containing vertex data
  85882. */
  85883. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85884. /**
  85885. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85886. * @param kind defines the data kind (Position, normal, etc...)
  85887. * @returns true if the vertex buffer with the specified kind is updatable
  85888. */
  85889. isVertexBufferUpdatable(kind: string): boolean;
  85890. /**
  85891. * Gets a specific vertex buffer
  85892. * @param kind defines the data kind (Position, normal, etc...)
  85893. * @returns a VertexBuffer
  85894. */
  85895. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85896. /**
  85897. * Returns all vertex buffers
  85898. * @return an object holding all vertex buffers indexed by kind
  85899. */
  85900. getVertexBuffers(): Nullable<{
  85901. [key: string]: VertexBuffer;
  85902. }>;
  85903. /**
  85904. * Gets a boolean indicating if specific vertex buffer is present
  85905. * @param kind defines the data kind (Position, normal, etc...)
  85906. * @returns true if data is present
  85907. */
  85908. isVerticesDataPresent(kind: string): boolean;
  85909. /**
  85910. * Gets a list of all attached data kinds (Position, normal, etc...)
  85911. * @returns a list of string containing all kinds
  85912. */
  85913. getVerticesDataKinds(): string[];
  85914. /**
  85915. * Update index buffer
  85916. * @param indices defines the indices to store in the index buffer
  85917. * @param offset defines the offset in the target buffer where to store the data
  85918. * @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)
  85919. */
  85920. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85921. /**
  85922. * Creates a new index buffer
  85923. * @param indices defines the indices to store in the index buffer
  85924. * @param totalVertices defines the total number of vertices (could be null)
  85925. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85926. */
  85927. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85928. /**
  85929. * Return the total number of indices
  85930. * @returns the total number of indices
  85931. */
  85932. getTotalIndices(): number;
  85933. /**
  85934. * Gets the index buffer array
  85935. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85936. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85937. * @returns the index buffer array
  85938. */
  85939. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85940. /**
  85941. * Gets the index buffer
  85942. * @return the index buffer
  85943. */
  85944. getIndexBuffer(): Nullable<DataBuffer>;
  85945. /** @hidden */
  85946. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85947. /**
  85948. * Release the associated resources for a specific mesh
  85949. * @param mesh defines the source mesh
  85950. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85951. */
  85952. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85953. /**
  85954. * Apply current geometry to a given mesh
  85955. * @param mesh defines the mesh to apply geometry to
  85956. */
  85957. applyToMesh(mesh: Mesh): void;
  85958. private _updateExtend;
  85959. private _applyToMesh;
  85960. private notifyUpdate;
  85961. /**
  85962. * Load the geometry if it was flagged as delay loaded
  85963. * @param scene defines the hosting scene
  85964. * @param onLoaded defines a callback called when the geometry is loaded
  85965. */
  85966. load(scene: Scene, onLoaded?: () => void): void;
  85967. private _queueLoad;
  85968. /**
  85969. * Invert the geometry to move from a right handed system to a left handed one.
  85970. */
  85971. toLeftHanded(): void;
  85972. /** @hidden */
  85973. _resetPointsArrayCache(): void;
  85974. /** @hidden */
  85975. _generatePointsArray(): boolean;
  85976. /**
  85977. * Gets a value indicating if the geometry is disposed
  85978. * @returns true if the geometry was disposed
  85979. */
  85980. isDisposed(): boolean;
  85981. private _disposeVertexArrayObjects;
  85982. /**
  85983. * Free all associated resources
  85984. */
  85985. dispose(): void;
  85986. /**
  85987. * Clone the current geometry into a new geometry
  85988. * @param id defines the unique ID of the new geometry
  85989. * @returns a new geometry object
  85990. */
  85991. copy(id: string): Geometry;
  85992. /**
  85993. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85994. * @return a JSON representation of the current geometry data (without the vertices data)
  85995. */
  85996. serialize(): any;
  85997. private toNumberArray;
  85998. /**
  85999. * Serialize all vertices data into a JSON oject
  86000. * @returns a JSON representation of the current geometry data
  86001. */
  86002. serializeVerticeData(): any;
  86003. /**
  86004. * Extracts a clone of a mesh geometry
  86005. * @param mesh defines the source mesh
  86006. * @param id defines the unique ID of the new geometry object
  86007. * @returns the new geometry object
  86008. */
  86009. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86010. /**
  86011. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86012. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86013. * Be aware Math.random() could cause collisions, but:
  86014. * "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"
  86015. * @returns a string containing a new GUID
  86016. */
  86017. static RandomId(): string;
  86018. /** @hidden */
  86019. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86020. private static _CleanMatricesWeights;
  86021. /**
  86022. * Create a new geometry from persisted data (Using .babylon file format)
  86023. * @param parsedVertexData defines the persisted data
  86024. * @param scene defines the hosting scene
  86025. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86026. * @returns the new geometry object
  86027. */
  86028. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86029. }
  86030. }
  86031. declare module BABYLON {
  86032. /**
  86033. * Define an interface for all classes that will get and set the data on vertices
  86034. */
  86035. export interface IGetSetVerticesData {
  86036. /**
  86037. * Gets a boolean indicating if specific vertex data is present
  86038. * @param kind defines the vertex data kind to use
  86039. * @returns true is data kind is present
  86040. */
  86041. isVerticesDataPresent(kind: string): boolean;
  86042. /**
  86043. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86044. * @param kind defines the data kind (Position, normal, etc...)
  86045. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86046. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86047. * @returns a float array containing vertex data
  86048. */
  86049. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86050. /**
  86051. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86052. * @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.
  86053. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86054. * @returns the indices array or an empty array if the mesh has no geometry
  86055. */
  86056. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86057. /**
  86058. * Set specific vertex data
  86059. * @param kind defines the data kind (Position, normal, etc...)
  86060. * @param data defines the vertex data to use
  86061. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86062. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86063. */
  86064. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86065. /**
  86066. * Update a specific associated vertex buffer
  86067. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86068. * - VertexBuffer.PositionKind
  86069. * - VertexBuffer.UVKind
  86070. * - VertexBuffer.UV2Kind
  86071. * - VertexBuffer.UV3Kind
  86072. * - VertexBuffer.UV4Kind
  86073. * - VertexBuffer.UV5Kind
  86074. * - VertexBuffer.UV6Kind
  86075. * - VertexBuffer.ColorKind
  86076. * - VertexBuffer.MatricesIndicesKind
  86077. * - VertexBuffer.MatricesIndicesExtraKind
  86078. * - VertexBuffer.MatricesWeightsKind
  86079. * - VertexBuffer.MatricesWeightsExtraKind
  86080. * @param data defines the data source
  86081. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86082. * @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)
  86083. */
  86084. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86085. /**
  86086. * Creates a new index buffer
  86087. * @param indices defines the indices to store in the index buffer
  86088. * @param totalVertices defines the total number of vertices (could be null)
  86089. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86090. */
  86091. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86092. }
  86093. /**
  86094. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86095. */
  86096. export class VertexData {
  86097. /**
  86098. * Mesh side orientation : usually the external or front surface
  86099. */
  86100. static readonly FRONTSIDE: number;
  86101. /**
  86102. * Mesh side orientation : usually the internal or back surface
  86103. */
  86104. static readonly BACKSIDE: number;
  86105. /**
  86106. * Mesh side orientation : both internal and external or front and back surfaces
  86107. */
  86108. static readonly DOUBLESIDE: number;
  86109. /**
  86110. * Mesh side orientation : by default, `FRONTSIDE`
  86111. */
  86112. static readonly DEFAULTSIDE: number;
  86113. /**
  86114. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86115. */
  86116. positions: Nullable<FloatArray>;
  86117. /**
  86118. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86119. */
  86120. normals: Nullable<FloatArray>;
  86121. /**
  86122. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86123. */
  86124. tangents: Nullable<FloatArray>;
  86125. /**
  86126. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86127. */
  86128. uvs: Nullable<FloatArray>;
  86129. /**
  86130. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86131. */
  86132. uvs2: Nullable<FloatArray>;
  86133. /**
  86134. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86135. */
  86136. uvs3: Nullable<FloatArray>;
  86137. /**
  86138. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86139. */
  86140. uvs4: Nullable<FloatArray>;
  86141. /**
  86142. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86143. */
  86144. uvs5: Nullable<FloatArray>;
  86145. /**
  86146. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86147. */
  86148. uvs6: Nullable<FloatArray>;
  86149. /**
  86150. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86151. */
  86152. colors: Nullable<FloatArray>;
  86153. /**
  86154. * 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).
  86155. */
  86156. matricesIndices: Nullable<FloatArray>;
  86157. /**
  86158. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86159. */
  86160. matricesWeights: Nullable<FloatArray>;
  86161. /**
  86162. * An array extending the number of possible indices
  86163. */
  86164. matricesIndicesExtra: Nullable<FloatArray>;
  86165. /**
  86166. * An array extending the number of possible weights when the number of indices is extended
  86167. */
  86168. matricesWeightsExtra: Nullable<FloatArray>;
  86169. /**
  86170. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86171. */
  86172. indices: Nullable<IndicesArray>;
  86173. /**
  86174. * Uses the passed data array to set the set the values for the specified kind of data
  86175. * @param data a linear array of floating numbers
  86176. * @param kind the type of data that is being set, eg positions, colors etc
  86177. */
  86178. set(data: FloatArray, kind: string): void;
  86179. /**
  86180. * Associates the vertexData to the passed Mesh.
  86181. * Sets it as updatable or not (default `false`)
  86182. * @param mesh the mesh the vertexData is applied to
  86183. * @param updatable when used and having the value true allows new data to update the vertexData
  86184. * @returns the VertexData
  86185. */
  86186. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86187. /**
  86188. * Associates the vertexData to the passed Geometry.
  86189. * Sets it as updatable or not (default `false`)
  86190. * @param geometry the geometry the vertexData is applied to
  86191. * @param updatable when used and having the value true allows new data to update the vertexData
  86192. * @returns VertexData
  86193. */
  86194. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86195. /**
  86196. * Updates the associated mesh
  86197. * @param mesh the mesh to be updated
  86198. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86199. * @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
  86200. * @returns VertexData
  86201. */
  86202. updateMesh(mesh: Mesh): VertexData;
  86203. /**
  86204. * Updates the associated geometry
  86205. * @param geometry the geometry to be updated
  86206. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86207. * @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
  86208. * @returns VertexData.
  86209. */
  86210. updateGeometry(geometry: Geometry): VertexData;
  86211. private _applyTo;
  86212. private _update;
  86213. /**
  86214. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86215. * @param matrix the transforming matrix
  86216. * @returns the VertexData
  86217. */
  86218. transform(matrix: Matrix): VertexData;
  86219. /**
  86220. * Merges the passed VertexData into the current one
  86221. * @param other the VertexData to be merged into the current one
  86222. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86223. * @returns the modified VertexData
  86224. */
  86225. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86226. private _mergeElement;
  86227. private _validate;
  86228. /**
  86229. * Serializes the VertexData
  86230. * @returns a serialized object
  86231. */
  86232. serialize(): any;
  86233. /**
  86234. * Extracts the vertexData from a mesh
  86235. * @param mesh the mesh from which to extract the VertexData
  86236. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86237. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86238. * @returns the object VertexData associated to the passed mesh
  86239. */
  86240. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86241. /**
  86242. * Extracts the vertexData from the geometry
  86243. * @param geometry the geometry from which to extract the VertexData
  86244. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86245. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86246. * @returns the object VertexData associated to the passed mesh
  86247. */
  86248. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86249. private static _ExtractFrom;
  86250. /**
  86251. * Creates the VertexData for a Ribbon
  86252. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86253. * * pathArray array of paths, each of which an array of successive Vector3
  86254. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86255. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86256. * * 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
  86257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86258. * * 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)
  86259. * * 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)
  86260. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86261. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86262. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86263. * @returns the VertexData of the ribbon
  86264. */
  86265. static CreateRibbon(options: {
  86266. pathArray: Vector3[][];
  86267. closeArray?: boolean;
  86268. closePath?: boolean;
  86269. offset?: number;
  86270. sideOrientation?: number;
  86271. frontUVs?: Vector4;
  86272. backUVs?: Vector4;
  86273. invertUV?: boolean;
  86274. uvs?: Vector2[];
  86275. colors?: Color4[];
  86276. }): VertexData;
  86277. /**
  86278. * Creates the VertexData for a box
  86279. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86280. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86281. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86282. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86283. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86284. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86285. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86287. * * 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)
  86288. * * 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)
  86289. * @returns the VertexData of the box
  86290. */
  86291. static CreateBox(options: {
  86292. size?: number;
  86293. width?: number;
  86294. height?: number;
  86295. depth?: number;
  86296. faceUV?: Vector4[];
  86297. faceColors?: Color4[];
  86298. sideOrientation?: number;
  86299. frontUVs?: Vector4;
  86300. backUVs?: Vector4;
  86301. }): VertexData;
  86302. /**
  86303. * Creates the VertexData for a tiled box
  86304. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86305. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86306. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86307. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86308. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86309. * @returns the VertexData of the box
  86310. */
  86311. static CreateTiledBox(options: {
  86312. pattern?: number;
  86313. width?: number;
  86314. height?: number;
  86315. depth?: number;
  86316. tileSize?: number;
  86317. tileWidth?: number;
  86318. tileHeight?: number;
  86319. alignHorizontal?: number;
  86320. alignVertical?: number;
  86321. faceUV?: Vector4[];
  86322. faceColors?: Color4[];
  86323. sideOrientation?: number;
  86324. }): VertexData;
  86325. /**
  86326. * Creates the VertexData for a tiled plane
  86327. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86328. * * pattern a limited pattern arrangement depending on the number
  86329. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86330. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86331. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86333. * * 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)
  86334. * * 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)
  86335. * @returns the VertexData of the tiled plane
  86336. */
  86337. static CreateTiledPlane(options: {
  86338. pattern?: number;
  86339. tileSize?: number;
  86340. tileWidth?: number;
  86341. tileHeight?: number;
  86342. size?: number;
  86343. width?: number;
  86344. height?: number;
  86345. alignHorizontal?: number;
  86346. alignVertical?: number;
  86347. sideOrientation?: number;
  86348. frontUVs?: Vector4;
  86349. backUVs?: Vector4;
  86350. }): VertexData;
  86351. /**
  86352. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86353. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86354. * * segments sets the number of horizontal strips optional, default 32
  86355. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86356. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86357. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86358. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86359. * * 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
  86360. * * 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
  86361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86362. * * 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)
  86363. * * 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)
  86364. * @returns the VertexData of the ellipsoid
  86365. */
  86366. static CreateSphere(options: {
  86367. segments?: number;
  86368. diameter?: number;
  86369. diameterX?: number;
  86370. diameterY?: number;
  86371. diameterZ?: number;
  86372. arc?: number;
  86373. slice?: number;
  86374. sideOrientation?: number;
  86375. frontUVs?: Vector4;
  86376. backUVs?: Vector4;
  86377. }): VertexData;
  86378. /**
  86379. * Creates the VertexData for a cylinder, cone or prism
  86380. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86381. * * height sets the height (y direction) of the cylinder, optional, default 2
  86382. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86383. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86384. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86385. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86386. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86387. * * 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
  86388. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86389. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86390. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86391. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86393. * * 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)
  86394. * * 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)
  86395. * @returns the VertexData of the cylinder, cone or prism
  86396. */
  86397. static CreateCylinder(options: {
  86398. height?: number;
  86399. diameterTop?: number;
  86400. diameterBottom?: number;
  86401. diameter?: number;
  86402. tessellation?: number;
  86403. subdivisions?: number;
  86404. arc?: number;
  86405. faceColors?: Color4[];
  86406. faceUV?: Vector4[];
  86407. hasRings?: boolean;
  86408. enclose?: boolean;
  86409. sideOrientation?: number;
  86410. frontUVs?: Vector4;
  86411. backUVs?: Vector4;
  86412. }): VertexData;
  86413. /**
  86414. * Creates the VertexData for a torus
  86415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86416. * * diameter the diameter of the torus, optional default 1
  86417. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86418. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86419. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86420. * * 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)
  86421. * * 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)
  86422. * @returns the VertexData of the torus
  86423. */
  86424. static CreateTorus(options: {
  86425. diameter?: number;
  86426. thickness?: number;
  86427. tessellation?: number;
  86428. sideOrientation?: number;
  86429. frontUVs?: Vector4;
  86430. backUVs?: Vector4;
  86431. }): VertexData;
  86432. /**
  86433. * Creates the VertexData of the LineSystem
  86434. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86435. * - lines an array of lines, each line being an array of successive Vector3
  86436. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86437. * @returns the VertexData of the LineSystem
  86438. */
  86439. static CreateLineSystem(options: {
  86440. lines: Vector3[][];
  86441. colors?: Nullable<Color4[][]>;
  86442. }): VertexData;
  86443. /**
  86444. * Create the VertexData for a DashedLines
  86445. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86446. * - points an array successive Vector3
  86447. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86448. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86449. * - dashNb the intended total number of dashes, optional, default 200
  86450. * @returns the VertexData for the DashedLines
  86451. */
  86452. static CreateDashedLines(options: {
  86453. points: Vector3[];
  86454. dashSize?: number;
  86455. gapSize?: number;
  86456. dashNb?: number;
  86457. }): VertexData;
  86458. /**
  86459. * Creates the VertexData for a Ground
  86460. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86461. * - width the width (x direction) of the ground, optional, default 1
  86462. * - height the height (z direction) of the ground, optional, default 1
  86463. * - subdivisions the number of subdivisions per side, optional, default 1
  86464. * @returns the VertexData of the Ground
  86465. */
  86466. static CreateGround(options: {
  86467. width?: number;
  86468. height?: number;
  86469. subdivisions?: number;
  86470. subdivisionsX?: number;
  86471. subdivisionsY?: number;
  86472. }): VertexData;
  86473. /**
  86474. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86475. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86476. * * xmin the ground minimum X coordinate, optional, default -1
  86477. * * zmin the ground minimum Z coordinate, optional, default -1
  86478. * * xmax the ground maximum X coordinate, optional, default 1
  86479. * * zmax the ground maximum Z coordinate, optional, default 1
  86480. * * 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}
  86481. * * 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}
  86482. * @returns the VertexData of the TiledGround
  86483. */
  86484. static CreateTiledGround(options: {
  86485. xmin: number;
  86486. zmin: number;
  86487. xmax: number;
  86488. zmax: number;
  86489. subdivisions?: {
  86490. w: number;
  86491. h: number;
  86492. };
  86493. precision?: {
  86494. w: number;
  86495. h: number;
  86496. };
  86497. }): VertexData;
  86498. /**
  86499. * Creates the VertexData of the Ground designed from a heightmap
  86500. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86501. * * width the width (x direction) of the ground
  86502. * * height the height (z direction) of the ground
  86503. * * subdivisions the number of subdivisions per side
  86504. * * minHeight the minimum altitude on the ground, optional, default 0
  86505. * * maxHeight the maximum altitude on the ground, optional default 1
  86506. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86507. * * buffer the array holding the image color data
  86508. * * bufferWidth the width of image
  86509. * * bufferHeight the height of image
  86510. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86511. * @returns the VertexData of the Ground designed from a heightmap
  86512. */
  86513. static CreateGroundFromHeightMap(options: {
  86514. width: number;
  86515. height: number;
  86516. subdivisions: number;
  86517. minHeight: number;
  86518. maxHeight: number;
  86519. colorFilter: Color3;
  86520. buffer: Uint8Array;
  86521. bufferWidth: number;
  86522. bufferHeight: number;
  86523. alphaFilter: number;
  86524. }): VertexData;
  86525. /**
  86526. * Creates the VertexData for a Plane
  86527. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86528. * * size sets the width and height of the plane to the value of size, optional default 1
  86529. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86530. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86531. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86532. * * 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)
  86533. * * 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)
  86534. * @returns the VertexData of the box
  86535. */
  86536. static CreatePlane(options: {
  86537. size?: number;
  86538. width?: number;
  86539. height?: number;
  86540. sideOrientation?: number;
  86541. frontUVs?: Vector4;
  86542. backUVs?: Vector4;
  86543. }): VertexData;
  86544. /**
  86545. * Creates the VertexData of the Disc or regular Polygon
  86546. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86547. * * radius the radius of the disc, optional default 0.5
  86548. * * tessellation the number of polygon sides, optional, default 64
  86549. * * 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
  86550. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86551. * * 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)
  86552. * * 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)
  86553. * @returns the VertexData of the box
  86554. */
  86555. static CreateDisc(options: {
  86556. radius?: number;
  86557. tessellation?: number;
  86558. arc?: number;
  86559. sideOrientation?: number;
  86560. frontUVs?: Vector4;
  86561. backUVs?: Vector4;
  86562. }): VertexData;
  86563. /**
  86564. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86565. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86566. * @param polygon a mesh built from polygonTriangulation.build()
  86567. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86568. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86569. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86570. * @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)
  86571. * @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)
  86572. * @returns the VertexData of the Polygon
  86573. */
  86574. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86575. /**
  86576. * Creates the VertexData of the IcoSphere
  86577. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86578. * * radius the radius of the IcoSphere, optional default 1
  86579. * * radiusX allows stretching in the x direction, optional, default radius
  86580. * * radiusY allows stretching in the y direction, optional, default radius
  86581. * * radiusZ allows stretching in the z direction, optional, default radius
  86582. * * flat when true creates a flat shaded mesh, optional, default true
  86583. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86584. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86585. * * 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)
  86586. * * 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)
  86587. * @returns the VertexData of the IcoSphere
  86588. */
  86589. static CreateIcoSphere(options: {
  86590. radius?: number;
  86591. radiusX?: number;
  86592. radiusY?: number;
  86593. radiusZ?: number;
  86594. flat?: boolean;
  86595. subdivisions?: number;
  86596. sideOrientation?: number;
  86597. frontUVs?: Vector4;
  86598. backUVs?: Vector4;
  86599. }): VertexData;
  86600. /**
  86601. * Creates the VertexData for a Polyhedron
  86602. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86603. * * type provided types are:
  86604. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86605. * * 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)
  86606. * * size the size of the IcoSphere, optional default 1
  86607. * * sizeX allows stretching in the x direction, optional, default size
  86608. * * sizeY allows stretching in the y direction, optional, default size
  86609. * * sizeZ allows stretching in the z direction, optional, default size
  86610. * * 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
  86611. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86612. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86613. * * flat when true creates a flat shaded mesh, optional, default true
  86614. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86615. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86616. * * 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)
  86617. * * 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)
  86618. * @returns the VertexData of the Polyhedron
  86619. */
  86620. static CreatePolyhedron(options: {
  86621. type?: number;
  86622. size?: number;
  86623. sizeX?: number;
  86624. sizeY?: number;
  86625. sizeZ?: number;
  86626. custom?: any;
  86627. faceUV?: Vector4[];
  86628. faceColors?: Color4[];
  86629. flat?: boolean;
  86630. sideOrientation?: number;
  86631. frontUVs?: Vector4;
  86632. backUVs?: Vector4;
  86633. }): VertexData;
  86634. /**
  86635. * Creates the VertexData for a TorusKnot
  86636. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86637. * * radius the radius of the torus knot, optional, default 2
  86638. * * tube the thickness of the tube, optional, default 0.5
  86639. * * radialSegments the number of sides on each tube segments, optional, default 32
  86640. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86641. * * p the number of windings around the z axis, optional, default 2
  86642. * * q the number of windings around the x axis, optional, default 3
  86643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86644. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  86645. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  86646. * @returns the VertexData of the Torus Knot
  86647. */
  86648. static CreateTorusKnot(options: {
  86649. radius?: number;
  86650. tube?: number;
  86651. radialSegments?: number;
  86652. tubularSegments?: number;
  86653. p?: number;
  86654. q?: number;
  86655. sideOrientation?: number;
  86656. frontUVs?: Vector4;
  86657. backUVs?: Vector4;
  86658. }): VertexData;
  86659. /**
  86660. * Compute normals for given positions and indices
  86661. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86662. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86663. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86664. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86665. * * facetNormals : optional array of facet normals (vector3)
  86666. * * facetPositions : optional array of facet positions (vector3)
  86667. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86668. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86669. * * bInfo : optional bounding info, required for facetPartitioning computation
  86670. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86671. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86672. * * useRightHandedSystem: optional boolean to for right handed system computation
  86673. * * depthSort : optional boolean to enable the facet depth sort computation
  86674. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86675. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86676. */
  86677. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86678. facetNormals?: any;
  86679. facetPositions?: any;
  86680. facetPartitioning?: any;
  86681. ratio?: number;
  86682. bInfo?: any;
  86683. bbSize?: Vector3;
  86684. subDiv?: any;
  86685. useRightHandedSystem?: boolean;
  86686. depthSort?: boolean;
  86687. distanceTo?: Vector3;
  86688. depthSortedFacets?: any;
  86689. }): void;
  86690. /** @hidden */
  86691. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86692. /**
  86693. * Applies VertexData created from the imported parameters to the geometry
  86694. * @param parsedVertexData the parsed data from an imported file
  86695. * @param geometry the geometry to apply the VertexData to
  86696. */
  86697. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86698. }
  86699. }
  86700. declare module BABYLON {
  86701. /**
  86702. * Defines a target to use with MorphTargetManager
  86703. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86704. */
  86705. export class MorphTarget implements IAnimatable {
  86706. /** defines the name of the target */
  86707. name: string;
  86708. /**
  86709. * Gets or sets the list of animations
  86710. */
  86711. animations: Animation[];
  86712. private _scene;
  86713. private _positions;
  86714. private _normals;
  86715. private _tangents;
  86716. private _uvs;
  86717. private _influence;
  86718. /**
  86719. * Observable raised when the influence changes
  86720. */
  86721. onInfluenceChanged: Observable<boolean>;
  86722. /** @hidden */
  86723. _onDataLayoutChanged: Observable<void>;
  86724. /**
  86725. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  86726. */
  86727. influence: number;
  86728. /**
  86729. * Gets or sets the id of the morph Target
  86730. */
  86731. id: string;
  86732. private _animationPropertiesOverride;
  86733. /**
  86734. * Gets or sets the animation properties override
  86735. */
  86736. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  86737. /**
  86738. * Creates a new MorphTarget
  86739. * @param name defines the name of the target
  86740. * @param influence defines the influence to use
  86741. * @param scene defines the scene the morphtarget belongs to
  86742. */
  86743. constructor(
  86744. /** defines the name of the target */
  86745. name: string, influence?: number, scene?: Nullable<Scene>);
  86746. /**
  86747. * Gets a boolean defining if the target contains position data
  86748. */
  86749. readonly hasPositions: boolean;
  86750. /**
  86751. * Gets a boolean defining if the target contains normal data
  86752. */
  86753. readonly hasNormals: boolean;
  86754. /**
  86755. * Gets a boolean defining if the target contains tangent data
  86756. */
  86757. readonly hasTangents: boolean;
  86758. /**
  86759. * Gets a boolean defining if the target contains texture coordinates data
  86760. */
  86761. readonly hasUVs: boolean;
  86762. /**
  86763. * Affects position data to this target
  86764. * @param data defines the position data to use
  86765. */
  86766. setPositions(data: Nullable<FloatArray>): void;
  86767. /**
  86768. * Gets the position data stored in this target
  86769. * @returns a FloatArray containing the position data (or null if not present)
  86770. */
  86771. getPositions(): Nullable<FloatArray>;
  86772. /**
  86773. * Affects normal data to this target
  86774. * @param data defines the normal data to use
  86775. */
  86776. setNormals(data: Nullable<FloatArray>): void;
  86777. /**
  86778. * Gets the normal data stored in this target
  86779. * @returns a FloatArray containing the normal data (or null if not present)
  86780. */
  86781. getNormals(): Nullable<FloatArray>;
  86782. /**
  86783. * Affects tangent data to this target
  86784. * @param data defines the tangent data to use
  86785. */
  86786. setTangents(data: Nullable<FloatArray>): void;
  86787. /**
  86788. * Gets the tangent data stored in this target
  86789. * @returns a FloatArray containing the tangent data (or null if not present)
  86790. */
  86791. getTangents(): Nullable<FloatArray>;
  86792. /**
  86793. * Affects texture coordinates data to this target
  86794. * @param data defines the texture coordinates data to use
  86795. */
  86796. setUVs(data: Nullable<FloatArray>): void;
  86797. /**
  86798. * Gets the texture coordinates data stored in this target
  86799. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86800. */
  86801. getUVs(): Nullable<FloatArray>;
  86802. /**
  86803. * Serializes the current target into a Serialization object
  86804. * @returns the serialized object
  86805. */
  86806. serialize(): any;
  86807. /**
  86808. * Returns the string "MorphTarget"
  86809. * @returns "MorphTarget"
  86810. */
  86811. getClassName(): string;
  86812. /**
  86813. * Creates a new target from serialized data
  86814. * @param serializationObject defines the serialized data to use
  86815. * @returns a new MorphTarget
  86816. */
  86817. static Parse(serializationObject: any): MorphTarget;
  86818. /**
  86819. * Creates a MorphTarget from mesh data
  86820. * @param mesh defines the source mesh
  86821. * @param name defines the name to use for the new target
  86822. * @param influence defines the influence to attach to the target
  86823. * @returns a new MorphTarget
  86824. */
  86825. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86826. }
  86827. }
  86828. declare module BABYLON {
  86829. /**
  86830. * This class is used to deform meshes using morphing between different targets
  86831. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86832. */
  86833. export class MorphTargetManager {
  86834. private _targets;
  86835. private _targetInfluenceChangedObservers;
  86836. private _targetDataLayoutChangedObservers;
  86837. private _activeTargets;
  86838. private _scene;
  86839. private _influences;
  86840. private _supportsNormals;
  86841. private _supportsTangents;
  86842. private _supportsUVs;
  86843. private _vertexCount;
  86844. private _uniqueId;
  86845. private _tempInfluences;
  86846. /**
  86847. * Gets or sets a boolean indicating if normals must be morphed
  86848. */
  86849. enableNormalMorphing: boolean;
  86850. /**
  86851. * Gets or sets a boolean indicating if tangents must be morphed
  86852. */
  86853. enableTangentMorphing: boolean;
  86854. /**
  86855. * Gets or sets a boolean indicating if UV must be morphed
  86856. */
  86857. enableUVMorphing: boolean;
  86858. /**
  86859. * Creates a new MorphTargetManager
  86860. * @param scene defines the current scene
  86861. */
  86862. constructor(scene?: Nullable<Scene>);
  86863. /**
  86864. * Gets the unique ID of this manager
  86865. */
  86866. readonly uniqueId: number;
  86867. /**
  86868. * Gets the number of vertices handled by this manager
  86869. */
  86870. readonly vertexCount: number;
  86871. /**
  86872. * Gets a boolean indicating if this manager supports morphing of normals
  86873. */
  86874. readonly supportsNormals: boolean;
  86875. /**
  86876. * Gets a boolean indicating if this manager supports morphing of tangents
  86877. */
  86878. readonly supportsTangents: boolean;
  86879. /**
  86880. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  86881. */
  86882. readonly supportsUVs: boolean;
  86883. /**
  86884. * Gets the number of targets stored in this manager
  86885. */
  86886. readonly numTargets: number;
  86887. /**
  86888. * Gets the number of influencers (ie. the number of targets with influences > 0)
  86889. */
  86890. readonly numInfluencers: number;
  86891. /**
  86892. * Gets the list of influences (one per target)
  86893. */
  86894. readonly influences: Float32Array;
  86895. /**
  86896. * Gets the active target at specified index. An active target is a target with an influence > 0
  86897. * @param index defines the index to check
  86898. * @returns the requested target
  86899. */
  86900. getActiveTarget(index: number): MorphTarget;
  86901. /**
  86902. * Gets the target at specified index
  86903. * @param index defines the index to check
  86904. * @returns the requested target
  86905. */
  86906. getTarget(index: number): MorphTarget;
  86907. /**
  86908. * Add a new target to this manager
  86909. * @param target defines the target to add
  86910. */
  86911. addTarget(target: MorphTarget): void;
  86912. /**
  86913. * Removes a target from the manager
  86914. * @param target defines the target to remove
  86915. */
  86916. removeTarget(target: MorphTarget): void;
  86917. /**
  86918. * Serializes the current manager into a Serialization object
  86919. * @returns the serialized object
  86920. */
  86921. serialize(): any;
  86922. private _syncActiveTargets;
  86923. /**
  86924. * Syncrhonize the targets with all the meshes using this morph target manager
  86925. */
  86926. synchronize(): void;
  86927. /**
  86928. * Creates a new MorphTargetManager from serialized data
  86929. * @param serializationObject defines the serialized data
  86930. * @param scene defines the hosting scene
  86931. * @returns the new MorphTargetManager
  86932. */
  86933. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  86934. }
  86935. }
  86936. declare module BABYLON {
  86937. /**
  86938. * Class used to represent a specific level of detail of a mesh
  86939. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86940. */
  86941. export class MeshLODLevel {
  86942. /** Defines the distance where this level should star being displayed */
  86943. distance: number;
  86944. /** Defines the mesh to use to render this level */
  86945. mesh: Nullable<Mesh>;
  86946. /**
  86947. * Creates a new LOD level
  86948. * @param distance defines the distance where this level should star being displayed
  86949. * @param mesh defines the mesh to use to render this level
  86950. */
  86951. constructor(
  86952. /** Defines the distance where this level should star being displayed */
  86953. distance: number,
  86954. /** Defines the mesh to use to render this level */
  86955. mesh: Nullable<Mesh>);
  86956. }
  86957. }
  86958. declare module BABYLON {
  86959. /**
  86960. * Mesh representing the gorund
  86961. */
  86962. export class GroundMesh extends Mesh {
  86963. /** If octree should be generated */
  86964. generateOctree: boolean;
  86965. private _heightQuads;
  86966. /** @hidden */
  86967. _subdivisionsX: number;
  86968. /** @hidden */
  86969. _subdivisionsY: number;
  86970. /** @hidden */
  86971. _width: number;
  86972. /** @hidden */
  86973. _height: number;
  86974. /** @hidden */
  86975. _minX: number;
  86976. /** @hidden */
  86977. _maxX: number;
  86978. /** @hidden */
  86979. _minZ: number;
  86980. /** @hidden */
  86981. _maxZ: number;
  86982. constructor(name: string, scene: Scene);
  86983. /**
  86984. * "GroundMesh"
  86985. * @returns "GroundMesh"
  86986. */
  86987. getClassName(): string;
  86988. /**
  86989. * The minimum of x and y subdivisions
  86990. */
  86991. readonly subdivisions: number;
  86992. /**
  86993. * X subdivisions
  86994. */
  86995. readonly subdivisionsX: number;
  86996. /**
  86997. * Y subdivisions
  86998. */
  86999. readonly subdivisionsY: number;
  87000. /**
  87001. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87002. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87003. * @param chunksCount the number of subdivisions for x and y
  87004. * @param octreeBlocksSize (Default: 32)
  87005. */
  87006. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87007. /**
  87008. * Returns a height (y) value in the Worl system :
  87009. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87010. * @param x x coordinate
  87011. * @param z z coordinate
  87012. * @returns the ground y position if (x, z) are outside the ground surface.
  87013. */
  87014. getHeightAtCoordinates(x: number, z: number): number;
  87015. /**
  87016. * Returns a normalized vector (Vector3) orthogonal to the ground
  87017. * at the ground coordinates (x, z) expressed in the World system.
  87018. * @param x x coordinate
  87019. * @param z z coordinate
  87020. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87021. */
  87022. getNormalAtCoordinates(x: number, z: number): Vector3;
  87023. /**
  87024. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  87025. * at the ground coordinates (x, z) expressed in the World system.
  87026. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  87027. * @param x x coordinate
  87028. * @param z z coordinate
  87029. * @param ref vector to store the result
  87030. * @returns the GroundMesh.
  87031. */
  87032. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  87033. /**
  87034. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  87035. * if the ground has been updated.
  87036. * This can be used in the render loop.
  87037. * @returns the GroundMesh.
  87038. */
  87039. updateCoordinateHeights(): GroundMesh;
  87040. private _getFacetAt;
  87041. private _initHeightQuads;
  87042. private _computeHeightQuads;
  87043. /**
  87044. * Serializes this ground mesh
  87045. * @param serializationObject object to write serialization to
  87046. */
  87047. serialize(serializationObject: any): void;
  87048. /**
  87049. * Parses a serialized ground mesh
  87050. * @param parsedMesh the serialized mesh
  87051. * @param scene the scene to create the ground mesh in
  87052. * @returns the created ground mesh
  87053. */
  87054. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  87055. }
  87056. }
  87057. declare module BABYLON {
  87058. /**
  87059. * Interface for Physics-Joint data
  87060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87061. */
  87062. export interface PhysicsJointData {
  87063. /**
  87064. * The main pivot of the joint
  87065. */
  87066. mainPivot?: Vector3;
  87067. /**
  87068. * The connected pivot of the joint
  87069. */
  87070. connectedPivot?: Vector3;
  87071. /**
  87072. * The main axis of the joint
  87073. */
  87074. mainAxis?: Vector3;
  87075. /**
  87076. * The connected axis of the joint
  87077. */
  87078. connectedAxis?: Vector3;
  87079. /**
  87080. * The collision of the joint
  87081. */
  87082. collision?: boolean;
  87083. /**
  87084. * Native Oimo/Cannon/Energy data
  87085. */
  87086. nativeParams?: any;
  87087. }
  87088. /**
  87089. * This is a holder class for the physics joint created by the physics plugin
  87090. * It holds a set of functions to control the underlying joint
  87091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87092. */
  87093. export class PhysicsJoint {
  87094. /**
  87095. * The type of the physics joint
  87096. */
  87097. type: number;
  87098. /**
  87099. * The data for the physics joint
  87100. */
  87101. jointData: PhysicsJointData;
  87102. private _physicsJoint;
  87103. protected _physicsPlugin: IPhysicsEnginePlugin;
  87104. /**
  87105. * Initializes the physics joint
  87106. * @param type The type of the physics joint
  87107. * @param jointData The data for the physics joint
  87108. */
  87109. constructor(
  87110. /**
  87111. * The type of the physics joint
  87112. */
  87113. type: number,
  87114. /**
  87115. * The data for the physics joint
  87116. */
  87117. jointData: PhysicsJointData);
  87118. /**
  87119. * Gets the physics joint
  87120. */
  87121. /**
  87122. * Sets the physics joint
  87123. */
  87124. physicsJoint: any;
  87125. /**
  87126. * Sets the physics plugin
  87127. */
  87128. physicsPlugin: IPhysicsEnginePlugin;
  87129. /**
  87130. * Execute a function that is physics-plugin specific.
  87131. * @param {Function} func the function that will be executed.
  87132. * It accepts two parameters: the physics world and the physics joint
  87133. */
  87134. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  87135. /**
  87136. * Distance-Joint type
  87137. */
  87138. static DistanceJoint: number;
  87139. /**
  87140. * Hinge-Joint type
  87141. */
  87142. static HingeJoint: number;
  87143. /**
  87144. * Ball-and-Socket joint type
  87145. */
  87146. static BallAndSocketJoint: number;
  87147. /**
  87148. * Wheel-Joint type
  87149. */
  87150. static WheelJoint: number;
  87151. /**
  87152. * Slider-Joint type
  87153. */
  87154. static SliderJoint: number;
  87155. /**
  87156. * Prismatic-Joint type
  87157. */
  87158. static PrismaticJoint: number;
  87159. /**
  87160. * Universal-Joint type
  87161. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  87162. */
  87163. static UniversalJoint: number;
  87164. /**
  87165. * Hinge-Joint 2 type
  87166. */
  87167. static Hinge2Joint: number;
  87168. /**
  87169. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  87170. */
  87171. static PointToPointJoint: number;
  87172. /**
  87173. * Spring-Joint type
  87174. */
  87175. static SpringJoint: number;
  87176. /**
  87177. * Lock-Joint type
  87178. */
  87179. static LockJoint: number;
  87180. }
  87181. /**
  87182. * A class representing a physics distance joint
  87183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87184. */
  87185. export class DistanceJoint extends PhysicsJoint {
  87186. /**
  87187. *
  87188. * @param jointData The data for the Distance-Joint
  87189. */
  87190. constructor(jointData: DistanceJointData);
  87191. /**
  87192. * Update the predefined distance.
  87193. * @param maxDistance The maximum preferred distance
  87194. * @param minDistance The minimum preferred distance
  87195. */
  87196. updateDistance(maxDistance: number, minDistance?: number): void;
  87197. }
  87198. /**
  87199. * Represents a Motor-Enabled Joint
  87200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87201. */
  87202. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  87203. /**
  87204. * Initializes the Motor-Enabled Joint
  87205. * @param type The type of the joint
  87206. * @param jointData The physica joint data for the joint
  87207. */
  87208. constructor(type: number, jointData: PhysicsJointData);
  87209. /**
  87210. * Set the motor values.
  87211. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87212. * @param force the force to apply
  87213. * @param maxForce max force for this motor.
  87214. */
  87215. setMotor(force?: number, maxForce?: number): void;
  87216. /**
  87217. * Set the motor's limits.
  87218. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87219. * @param upperLimit The upper limit of the motor
  87220. * @param lowerLimit The lower limit of the motor
  87221. */
  87222. setLimit(upperLimit: number, lowerLimit?: number): void;
  87223. }
  87224. /**
  87225. * This class represents a single physics Hinge-Joint
  87226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87227. */
  87228. export class HingeJoint extends MotorEnabledJoint {
  87229. /**
  87230. * Initializes the Hinge-Joint
  87231. * @param jointData The joint data for the Hinge-Joint
  87232. */
  87233. constructor(jointData: PhysicsJointData);
  87234. /**
  87235. * Set the motor values.
  87236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87237. * @param {number} force the force to apply
  87238. * @param {number} maxForce max force for this motor.
  87239. */
  87240. setMotor(force?: number, maxForce?: number): void;
  87241. /**
  87242. * Set the motor's limits.
  87243. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87244. * @param upperLimit The upper limit of the motor
  87245. * @param lowerLimit The lower limit of the motor
  87246. */
  87247. setLimit(upperLimit: number, lowerLimit?: number): void;
  87248. }
  87249. /**
  87250. * This class represents a dual hinge physics joint (same as wheel joint)
  87251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87252. */
  87253. export class Hinge2Joint extends MotorEnabledJoint {
  87254. /**
  87255. * Initializes the Hinge2-Joint
  87256. * @param jointData The joint data for the Hinge2-Joint
  87257. */
  87258. constructor(jointData: PhysicsJointData);
  87259. /**
  87260. * Set the motor values.
  87261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87262. * @param {number} targetSpeed the speed the motor is to reach
  87263. * @param {number} maxForce max force for this motor.
  87264. * @param {motorIndex} the motor's index, 0 or 1.
  87265. */
  87266. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  87267. /**
  87268. * Set the motor limits.
  87269. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87270. * @param {number} upperLimit the upper limit
  87271. * @param {number} lowerLimit lower limit
  87272. * @param {motorIndex} the motor's index, 0 or 1.
  87273. */
  87274. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87275. }
  87276. /**
  87277. * Interface for a motor enabled joint
  87278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87279. */
  87280. export interface IMotorEnabledJoint {
  87281. /**
  87282. * Physics joint
  87283. */
  87284. physicsJoint: any;
  87285. /**
  87286. * Sets the motor of the motor-enabled joint
  87287. * @param force The force of the motor
  87288. * @param maxForce The maximum force of the motor
  87289. * @param motorIndex The index of the motor
  87290. */
  87291. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  87292. /**
  87293. * Sets the limit of the motor
  87294. * @param upperLimit The upper limit of the motor
  87295. * @param lowerLimit The lower limit of the motor
  87296. * @param motorIndex The index of the motor
  87297. */
  87298. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87299. }
  87300. /**
  87301. * Joint data for a Distance-Joint
  87302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87303. */
  87304. export interface DistanceJointData extends PhysicsJointData {
  87305. /**
  87306. * Max distance the 2 joint objects can be apart
  87307. */
  87308. maxDistance: number;
  87309. }
  87310. /**
  87311. * Joint data from a spring joint
  87312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87313. */
  87314. export interface SpringJointData extends PhysicsJointData {
  87315. /**
  87316. * Length of the spring
  87317. */
  87318. length: number;
  87319. /**
  87320. * Stiffness of the spring
  87321. */
  87322. stiffness: number;
  87323. /**
  87324. * Damping of the spring
  87325. */
  87326. damping: number;
  87327. /** this callback will be called when applying the force to the impostors. */
  87328. forceApplicationCallback: () => void;
  87329. }
  87330. }
  87331. declare module BABYLON {
  87332. /**
  87333. * Holds the data for the raycast result
  87334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87335. */
  87336. export class PhysicsRaycastResult {
  87337. private _hasHit;
  87338. private _hitDistance;
  87339. private _hitNormalWorld;
  87340. private _hitPointWorld;
  87341. private _rayFromWorld;
  87342. private _rayToWorld;
  87343. /**
  87344. * Gets if there was a hit
  87345. */
  87346. readonly hasHit: boolean;
  87347. /**
  87348. * Gets the distance from the hit
  87349. */
  87350. readonly hitDistance: number;
  87351. /**
  87352. * Gets the hit normal/direction in the world
  87353. */
  87354. readonly hitNormalWorld: Vector3;
  87355. /**
  87356. * Gets the hit point in the world
  87357. */
  87358. readonly hitPointWorld: Vector3;
  87359. /**
  87360. * Gets the ray "start point" of the ray in the world
  87361. */
  87362. readonly rayFromWorld: Vector3;
  87363. /**
  87364. * Gets the ray "end point" of the ray in the world
  87365. */
  87366. readonly rayToWorld: Vector3;
  87367. /**
  87368. * Sets the hit data (normal & point in world space)
  87369. * @param hitNormalWorld defines the normal in world space
  87370. * @param hitPointWorld defines the point in world space
  87371. */
  87372. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  87373. /**
  87374. * Sets the distance from the start point to the hit point
  87375. * @param distance
  87376. */
  87377. setHitDistance(distance: number): void;
  87378. /**
  87379. * Calculates the distance manually
  87380. */
  87381. calculateHitDistance(): void;
  87382. /**
  87383. * Resets all the values to default
  87384. * @param from The from point on world space
  87385. * @param to The to point on world space
  87386. */
  87387. reset(from?: Vector3, to?: Vector3): void;
  87388. }
  87389. /**
  87390. * Interface for the size containing width and height
  87391. */
  87392. interface IXYZ {
  87393. /**
  87394. * X
  87395. */
  87396. x: number;
  87397. /**
  87398. * Y
  87399. */
  87400. y: number;
  87401. /**
  87402. * Z
  87403. */
  87404. z: number;
  87405. }
  87406. }
  87407. declare module BABYLON {
  87408. /**
  87409. * Interface used to describe a physics joint
  87410. */
  87411. export interface PhysicsImpostorJoint {
  87412. /** Defines the main impostor to which the joint is linked */
  87413. mainImpostor: PhysicsImpostor;
  87414. /** Defines the impostor that is connected to the main impostor using this joint */
  87415. connectedImpostor: PhysicsImpostor;
  87416. /** Defines the joint itself */
  87417. joint: PhysicsJoint;
  87418. }
  87419. /** @hidden */
  87420. export interface IPhysicsEnginePlugin {
  87421. world: any;
  87422. name: string;
  87423. setGravity(gravity: Vector3): void;
  87424. setTimeStep(timeStep: number): void;
  87425. getTimeStep(): number;
  87426. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  87427. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87428. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87429. generatePhysicsBody(impostor: PhysicsImpostor): void;
  87430. removePhysicsBody(impostor: PhysicsImpostor): void;
  87431. generateJoint(joint: PhysicsImpostorJoint): void;
  87432. removeJoint(joint: PhysicsImpostorJoint): void;
  87433. isSupported(): boolean;
  87434. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  87435. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  87436. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87437. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87438. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87439. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87440. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  87441. getBodyMass(impostor: PhysicsImpostor): number;
  87442. getBodyFriction(impostor: PhysicsImpostor): number;
  87443. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  87444. getBodyRestitution(impostor: PhysicsImpostor): number;
  87445. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  87446. getBodyPressure?(impostor: PhysicsImpostor): number;
  87447. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  87448. getBodyStiffness?(impostor: PhysicsImpostor): number;
  87449. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  87450. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  87451. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  87452. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  87453. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  87454. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87455. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87456. sleepBody(impostor: PhysicsImpostor): void;
  87457. wakeUpBody(impostor: PhysicsImpostor): void;
  87458. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87459. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  87460. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  87461. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87462. getRadius(impostor: PhysicsImpostor): number;
  87463. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  87464. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  87465. dispose(): void;
  87466. }
  87467. /**
  87468. * Interface used to define a physics engine
  87469. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  87470. */
  87471. export interface IPhysicsEngine {
  87472. /**
  87473. * Gets the gravity vector used by the simulation
  87474. */
  87475. gravity: Vector3;
  87476. /**
  87477. * Sets the gravity vector used by the simulation
  87478. * @param gravity defines the gravity vector to use
  87479. */
  87480. setGravity(gravity: Vector3): void;
  87481. /**
  87482. * Set the time step of the physics engine.
  87483. * Default is 1/60.
  87484. * To slow it down, enter 1/600 for example.
  87485. * To speed it up, 1/30
  87486. * @param newTimeStep the new timestep to apply to this world.
  87487. */
  87488. setTimeStep(newTimeStep: number): void;
  87489. /**
  87490. * Get the time step of the physics engine.
  87491. * @returns the current time step
  87492. */
  87493. getTimeStep(): number;
  87494. /**
  87495. * Release all resources
  87496. */
  87497. dispose(): void;
  87498. /**
  87499. * Gets the name of the current physics plugin
  87500. * @returns the name of the plugin
  87501. */
  87502. getPhysicsPluginName(): string;
  87503. /**
  87504. * Adding a new impostor for the impostor tracking.
  87505. * This will be done by the impostor itself.
  87506. * @param impostor the impostor to add
  87507. */
  87508. addImpostor(impostor: PhysicsImpostor): void;
  87509. /**
  87510. * Remove an impostor from the engine.
  87511. * This impostor and its mesh will not longer be updated by the physics engine.
  87512. * @param impostor the impostor to remove
  87513. */
  87514. removeImpostor(impostor: PhysicsImpostor): void;
  87515. /**
  87516. * Add a joint to the physics engine
  87517. * @param mainImpostor defines the main impostor to which the joint is added.
  87518. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  87519. * @param joint defines the joint that will connect both impostors.
  87520. */
  87521. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87522. /**
  87523. * Removes a joint from the simulation
  87524. * @param mainImpostor defines the impostor used with the joint
  87525. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  87526. * @param joint defines the joint to remove
  87527. */
  87528. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87529. /**
  87530. * Gets the current plugin used to run the simulation
  87531. * @returns current plugin
  87532. */
  87533. getPhysicsPlugin(): IPhysicsEnginePlugin;
  87534. /**
  87535. * Gets the list of physic impostors
  87536. * @returns an array of PhysicsImpostor
  87537. */
  87538. getImpostors(): Array<PhysicsImpostor>;
  87539. /**
  87540. * Gets the impostor for a physics enabled object
  87541. * @param object defines the object impersonated by the impostor
  87542. * @returns the PhysicsImpostor or null if not found
  87543. */
  87544. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87545. /**
  87546. * Gets the impostor for a physics body object
  87547. * @param body defines physics body used by the impostor
  87548. * @returns the PhysicsImpostor or null if not found
  87549. */
  87550. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  87551. /**
  87552. * Does a raycast in the physics world
  87553. * @param from when should the ray start?
  87554. * @param to when should the ray end?
  87555. * @returns PhysicsRaycastResult
  87556. */
  87557. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87558. /**
  87559. * Called by the scene. No need to call it.
  87560. * @param delta defines the timespam between frames
  87561. */
  87562. _step(delta: number): void;
  87563. }
  87564. }
  87565. declare module BABYLON {
  87566. /**
  87567. * The interface for the physics imposter parameters
  87568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87569. */
  87570. export interface PhysicsImpostorParameters {
  87571. /**
  87572. * The mass of the physics imposter
  87573. */
  87574. mass: number;
  87575. /**
  87576. * The friction of the physics imposter
  87577. */
  87578. friction?: number;
  87579. /**
  87580. * The coefficient of restitution of the physics imposter
  87581. */
  87582. restitution?: number;
  87583. /**
  87584. * The native options of the physics imposter
  87585. */
  87586. nativeOptions?: any;
  87587. /**
  87588. * Specifies if the parent should be ignored
  87589. */
  87590. ignoreParent?: boolean;
  87591. /**
  87592. * Specifies if bi-directional transformations should be disabled
  87593. */
  87594. disableBidirectionalTransformation?: boolean;
  87595. /**
  87596. * The pressure inside the physics imposter, soft object only
  87597. */
  87598. pressure?: number;
  87599. /**
  87600. * The stiffness the physics imposter, soft object only
  87601. */
  87602. stiffness?: number;
  87603. /**
  87604. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  87605. */
  87606. velocityIterations?: number;
  87607. /**
  87608. * The number of iterations used in maintaining consistent vertex positions, soft object only
  87609. */
  87610. positionIterations?: number;
  87611. /**
  87612. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  87613. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  87614. * Add to fix multiple points
  87615. */
  87616. fixedPoints?: number;
  87617. /**
  87618. * The collision margin around a soft object
  87619. */
  87620. margin?: number;
  87621. /**
  87622. * The collision margin around a soft object
  87623. */
  87624. damping?: number;
  87625. /**
  87626. * The path for a rope based on an extrusion
  87627. */
  87628. path?: any;
  87629. /**
  87630. * The shape of an extrusion used for a rope based on an extrusion
  87631. */
  87632. shape?: any;
  87633. }
  87634. /**
  87635. * Interface for a physics-enabled object
  87636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87637. */
  87638. export interface IPhysicsEnabledObject {
  87639. /**
  87640. * The position of the physics-enabled object
  87641. */
  87642. position: Vector3;
  87643. /**
  87644. * The rotation of the physics-enabled object
  87645. */
  87646. rotationQuaternion: Nullable<Quaternion>;
  87647. /**
  87648. * The scale of the physics-enabled object
  87649. */
  87650. scaling: Vector3;
  87651. /**
  87652. * The rotation of the physics-enabled object
  87653. */
  87654. rotation?: Vector3;
  87655. /**
  87656. * The parent of the physics-enabled object
  87657. */
  87658. parent?: any;
  87659. /**
  87660. * The bounding info of the physics-enabled object
  87661. * @returns The bounding info of the physics-enabled object
  87662. */
  87663. getBoundingInfo(): BoundingInfo;
  87664. /**
  87665. * Computes the world matrix
  87666. * @param force Specifies if the world matrix should be computed by force
  87667. * @returns A world matrix
  87668. */
  87669. computeWorldMatrix(force: boolean): Matrix;
  87670. /**
  87671. * Gets the world matrix
  87672. * @returns A world matrix
  87673. */
  87674. getWorldMatrix?(): Matrix;
  87675. /**
  87676. * Gets the child meshes
  87677. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  87678. * @returns An array of abstract meshes
  87679. */
  87680. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  87681. /**
  87682. * Gets the vertex data
  87683. * @param kind The type of vertex data
  87684. * @returns A nullable array of numbers, or a float32 array
  87685. */
  87686. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  87687. /**
  87688. * Gets the indices from the mesh
  87689. * @returns A nullable array of index arrays
  87690. */
  87691. getIndices?(): Nullable<IndicesArray>;
  87692. /**
  87693. * Gets the scene from the mesh
  87694. * @returns the indices array or null
  87695. */
  87696. getScene?(): Scene;
  87697. /**
  87698. * Gets the absolute position from the mesh
  87699. * @returns the absolute position
  87700. */
  87701. getAbsolutePosition(): Vector3;
  87702. /**
  87703. * Gets the absolute pivot point from the mesh
  87704. * @returns the absolute pivot point
  87705. */
  87706. getAbsolutePivotPoint(): Vector3;
  87707. /**
  87708. * Rotates the mesh
  87709. * @param axis The axis of rotation
  87710. * @param amount The amount of rotation
  87711. * @param space The space of the rotation
  87712. * @returns The rotation transform node
  87713. */
  87714. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87715. /**
  87716. * Translates the mesh
  87717. * @param axis The axis of translation
  87718. * @param distance The distance of translation
  87719. * @param space The space of the translation
  87720. * @returns The transform node
  87721. */
  87722. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87723. /**
  87724. * Sets the absolute position of the mesh
  87725. * @param absolutePosition The absolute position of the mesh
  87726. * @returns The transform node
  87727. */
  87728. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87729. /**
  87730. * Gets the class name of the mesh
  87731. * @returns The class name
  87732. */
  87733. getClassName(): string;
  87734. }
  87735. /**
  87736. * Represents a physics imposter
  87737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87738. */
  87739. export class PhysicsImpostor {
  87740. /**
  87741. * The physics-enabled object used as the physics imposter
  87742. */
  87743. object: IPhysicsEnabledObject;
  87744. /**
  87745. * The type of the physics imposter
  87746. */
  87747. type: number;
  87748. private _options;
  87749. private _scene?;
  87750. /**
  87751. * The default object size of the imposter
  87752. */
  87753. static DEFAULT_OBJECT_SIZE: Vector3;
  87754. /**
  87755. * The identity quaternion of the imposter
  87756. */
  87757. static IDENTITY_QUATERNION: Quaternion;
  87758. /** @hidden */
  87759. _pluginData: any;
  87760. private _physicsEngine;
  87761. private _physicsBody;
  87762. private _bodyUpdateRequired;
  87763. private _onBeforePhysicsStepCallbacks;
  87764. private _onAfterPhysicsStepCallbacks;
  87765. /** @hidden */
  87766. _onPhysicsCollideCallbacks: Array<{
  87767. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  87768. otherImpostors: Array<PhysicsImpostor>;
  87769. }>;
  87770. private _deltaPosition;
  87771. private _deltaRotation;
  87772. private _deltaRotationConjugated;
  87773. /** @hidden */
  87774. _isFromLine: boolean;
  87775. private _parent;
  87776. private _isDisposed;
  87777. private static _tmpVecs;
  87778. private static _tmpQuat;
  87779. /**
  87780. * Specifies if the physics imposter is disposed
  87781. */
  87782. readonly isDisposed: boolean;
  87783. /**
  87784. * Gets the mass of the physics imposter
  87785. */
  87786. mass: number;
  87787. /**
  87788. * Gets the coefficient of friction
  87789. */
  87790. /**
  87791. * Sets the coefficient of friction
  87792. */
  87793. friction: number;
  87794. /**
  87795. * Gets the coefficient of restitution
  87796. */
  87797. /**
  87798. * Sets the coefficient of restitution
  87799. */
  87800. restitution: number;
  87801. /**
  87802. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87803. */
  87804. /**
  87805. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87806. */
  87807. pressure: number;
  87808. /**
  87809. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87810. */
  87811. /**
  87812. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87813. */
  87814. stiffness: number;
  87815. /**
  87816. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87817. */
  87818. /**
  87819. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87820. */
  87821. velocityIterations: number;
  87822. /**
  87823. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87824. */
  87825. /**
  87826. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87827. */
  87828. positionIterations: number;
  87829. /**
  87830. * The unique id of the physics imposter
  87831. * set by the physics engine when adding this impostor to the array
  87832. */
  87833. uniqueId: number;
  87834. /**
  87835. * @hidden
  87836. */
  87837. soft: boolean;
  87838. /**
  87839. * @hidden
  87840. */
  87841. segments: number;
  87842. private _joints;
  87843. /**
  87844. * Initializes the physics imposter
  87845. * @param object The physics-enabled object used as the physics imposter
  87846. * @param type The type of the physics imposter
  87847. * @param _options The options for the physics imposter
  87848. * @param _scene The Babylon scene
  87849. */
  87850. constructor(
  87851. /**
  87852. * The physics-enabled object used as the physics imposter
  87853. */
  87854. object: IPhysicsEnabledObject,
  87855. /**
  87856. * The type of the physics imposter
  87857. */
  87858. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  87859. /**
  87860. * This function will completly initialize this impostor.
  87861. * It will create a new body - but only if this mesh has no parent.
  87862. * If it has, this impostor will not be used other than to define the impostor
  87863. * of the child mesh.
  87864. * @hidden
  87865. */
  87866. _init(): void;
  87867. private _getPhysicsParent;
  87868. /**
  87869. * Should a new body be generated.
  87870. * @returns boolean specifying if body initialization is required
  87871. */
  87872. isBodyInitRequired(): boolean;
  87873. /**
  87874. * Sets the updated scaling
  87875. * @param updated Specifies if the scaling is updated
  87876. */
  87877. setScalingUpdated(): void;
  87878. /**
  87879. * Force a regeneration of this or the parent's impostor's body.
  87880. * Use under cautious - This will remove all joints already implemented.
  87881. */
  87882. forceUpdate(): void;
  87883. /**
  87884. * Gets the body that holds this impostor. Either its own, or its parent.
  87885. */
  87886. /**
  87887. * Set the physics body. Used mainly by the physics engine/plugin
  87888. */
  87889. physicsBody: any;
  87890. /**
  87891. * Get the parent of the physics imposter
  87892. * @returns Physics imposter or null
  87893. */
  87894. /**
  87895. * Sets the parent of the physics imposter
  87896. */
  87897. parent: Nullable<PhysicsImpostor>;
  87898. /**
  87899. * Resets the update flags
  87900. */
  87901. resetUpdateFlags(): void;
  87902. /**
  87903. * Gets the object extend size
  87904. * @returns the object extend size
  87905. */
  87906. getObjectExtendSize(): Vector3;
  87907. /**
  87908. * Gets the object center
  87909. * @returns The object center
  87910. */
  87911. getObjectCenter(): Vector3;
  87912. /**
  87913. * Get a specific parametes from the options parameter
  87914. * @param paramName The object parameter name
  87915. * @returns The object parameter
  87916. */
  87917. getParam(paramName: string): any;
  87918. /**
  87919. * Sets a specific parameter in the options given to the physics plugin
  87920. * @param paramName The parameter name
  87921. * @param value The value of the parameter
  87922. */
  87923. setParam(paramName: string, value: number): void;
  87924. /**
  87925. * Specifically change the body's mass option. Won't recreate the physics body object
  87926. * @param mass The mass of the physics imposter
  87927. */
  87928. setMass(mass: number): void;
  87929. /**
  87930. * Gets the linear velocity
  87931. * @returns linear velocity or null
  87932. */
  87933. getLinearVelocity(): Nullable<Vector3>;
  87934. /**
  87935. * Sets the linear velocity
  87936. * @param velocity linear velocity or null
  87937. */
  87938. setLinearVelocity(velocity: Nullable<Vector3>): void;
  87939. /**
  87940. * Gets the angular velocity
  87941. * @returns angular velocity or null
  87942. */
  87943. getAngularVelocity(): Nullable<Vector3>;
  87944. /**
  87945. * Sets the angular velocity
  87946. * @param velocity The velocity or null
  87947. */
  87948. setAngularVelocity(velocity: Nullable<Vector3>): void;
  87949. /**
  87950. * Execute a function with the physics plugin native code
  87951. * Provide a function the will have two variables - the world object and the physics body object
  87952. * @param func The function to execute with the physics plugin native code
  87953. */
  87954. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  87955. /**
  87956. * Register a function that will be executed before the physics world is stepping forward
  87957. * @param func The function to execute before the physics world is stepped forward
  87958. */
  87959. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87960. /**
  87961. * Unregister a function that will be executed before the physics world is stepping forward
  87962. * @param func The function to execute before the physics world is stepped forward
  87963. */
  87964. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87965. /**
  87966. * Register a function that will be executed after the physics step
  87967. * @param func The function to execute after physics step
  87968. */
  87969. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87970. /**
  87971. * Unregisters a function that will be executed after the physics step
  87972. * @param func The function to execute after physics step
  87973. */
  87974. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87975. /**
  87976. * register a function that will be executed when this impostor collides against a different body
  87977. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  87978. * @param func Callback that is executed on collision
  87979. */
  87980. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  87981. /**
  87982. * Unregisters the physics imposter on contact
  87983. * @param collideAgainst The physics object to collide against
  87984. * @param func Callback to execute on collision
  87985. */
  87986. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  87987. private _tmpQuat;
  87988. private _tmpQuat2;
  87989. /**
  87990. * Get the parent rotation
  87991. * @returns The parent rotation
  87992. */
  87993. getParentsRotation(): Quaternion;
  87994. /**
  87995. * this function is executed by the physics engine.
  87996. */
  87997. beforeStep: () => void;
  87998. /**
  87999. * this function is executed by the physics engine
  88000. */
  88001. afterStep: () => void;
  88002. /**
  88003. * Legacy collision detection event support
  88004. */
  88005. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88006. /**
  88007. * event and body object due to cannon's event-based architecture.
  88008. */
  88009. onCollide: (e: {
  88010. body: any;
  88011. }) => void;
  88012. /**
  88013. * Apply a force
  88014. * @param force The force to apply
  88015. * @param contactPoint The contact point for the force
  88016. * @returns The physics imposter
  88017. */
  88018. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88019. /**
  88020. * Apply an impulse
  88021. * @param force The impulse force
  88022. * @param contactPoint The contact point for the impulse force
  88023. * @returns The physics imposter
  88024. */
  88025. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88026. /**
  88027. * A help function to create a joint
  88028. * @param otherImpostor A physics imposter used to create a joint
  88029. * @param jointType The type of joint
  88030. * @param jointData The data for the joint
  88031. * @returns The physics imposter
  88032. */
  88033. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  88034. /**
  88035. * Add a joint to this impostor with a different impostor
  88036. * @param otherImpostor A physics imposter used to add a joint
  88037. * @param joint The joint to add
  88038. * @returns The physics imposter
  88039. */
  88040. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  88041. /**
  88042. * Add an anchor to a cloth impostor
  88043. * @param otherImpostor rigid impostor to anchor to
  88044. * @param width ratio across width from 0 to 1
  88045. * @param height ratio up height from 0 to 1
  88046. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  88047. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  88048. * @returns impostor the soft imposter
  88049. */
  88050. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88051. /**
  88052. * Add a hook to a rope impostor
  88053. * @param otherImpostor rigid impostor to anchor to
  88054. * @param length ratio across rope from 0 to 1
  88055. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  88056. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  88057. * @returns impostor the rope imposter
  88058. */
  88059. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88060. /**
  88061. * Will keep this body still, in a sleep mode.
  88062. * @returns the physics imposter
  88063. */
  88064. sleep(): PhysicsImpostor;
  88065. /**
  88066. * Wake the body up.
  88067. * @returns The physics imposter
  88068. */
  88069. wakeUp(): PhysicsImpostor;
  88070. /**
  88071. * Clones the physics imposter
  88072. * @param newObject The physics imposter clones to this physics-enabled object
  88073. * @returns A nullable physics imposter
  88074. */
  88075. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88076. /**
  88077. * Disposes the physics imposter
  88078. */
  88079. dispose(): void;
  88080. /**
  88081. * Sets the delta position
  88082. * @param position The delta position amount
  88083. */
  88084. setDeltaPosition(position: Vector3): void;
  88085. /**
  88086. * Sets the delta rotation
  88087. * @param rotation The delta rotation amount
  88088. */
  88089. setDeltaRotation(rotation: Quaternion): void;
  88090. /**
  88091. * Gets the box size of the physics imposter and stores the result in the input parameter
  88092. * @param result Stores the box size
  88093. * @returns The physics imposter
  88094. */
  88095. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  88096. /**
  88097. * Gets the radius of the physics imposter
  88098. * @returns Radius of the physics imposter
  88099. */
  88100. getRadius(): number;
  88101. /**
  88102. * Sync a bone with this impostor
  88103. * @param bone The bone to sync to the impostor.
  88104. * @param boneMesh The mesh that the bone is influencing.
  88105. * @param jointPivot The pivot of the joint / bone in local space.
  88106. * @param distToJoint Optional distance from the impostor to the joint.
  88107. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88108. */
  88109. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  88110. /**
  88111. * Sync impostor to a bone
  88112. * @param bone The bone that the impostor will be synced to.
  88113. * @param boneMesh The mesh that the bone is influencing.
  88114. * @param jointPivot The pivot of the joint / bone in local space.
  88115. * @param distToJoint Optional distance from the impostor to the joint.
  88116. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88117. * @param boneAxis Optional vector3 axis the bone is aligned with
  88118. */
  88119. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  88120. /**
  88121. * No-Imposter type
  88122. */
  88123. static NoImpostor: number;
  88124. /**
  88125. * Sphere-Imposter type
  88126. */
  88127. static SphereImpostor: number;
  88128. /**
  88129. * Box-Imposter type
  88130. */
  88131. static BoxImpostor: number;
  88132. /**
  88133. * Plane-Imposter type
  88134. */
  88135. static PlaneImpostor: number;
  88136. /**
  88137. * Mesh-imposter type
  88138. */
  88139. static MeshImpostor: number;
  88140. /**
  88141. * Capsule-Impostor type (Ammo.js plugin only)
  88142. */
  88143. static CapsuleImpostor: number;
  88144. /**
  88145. * Cylinder-Imposter type
  88146. */
  88147. static CylinderImpostor: number;
  88148. /**
  88149. * Particle-Imposter type
  88150. */
  88151. static ParticleImpostor: number;
  88152. /**
  88153. * Heightmap-Imposter type
  88154. */
  88155. static HeightmapImpostor: number;
  88156. /**
  88157. * ConvexHull-Impostor type (Ammo.js plugin only)
  88158. */
  88159. static ConvexHullImpostor: number;
  88160. /**
  88161. * Rope-Imposter type
  88162. */
  88163. static RopeImpostor: number;
  88164. /**
  88165. * Cloth-Imposter type
  88166. */
  88167. static ClothImpostor: number;
  88168. /**
  88169. * Softbody-Imposter type
  88170. */
  88171. static SoftbodyImpostor: number;
  88172. }
  88173. }
  88174. declare module BABYLON {
  88175. /**
  88176. * @hidden
  88177. **/
  88178. export class _CreationDataStorage {
  88179. closePath?: boolean;
  88180. closeArray?: boolean;
  88181. idx: number[];
  88182. dashSize: number;
  88183. gapSize: number;
  88184. path3D: Path3D;
  88185. pathArray: Vector3[][];
  88186. arc: number;
  88187. radius: number;
  88188. cap: number;
  88189. tessellation: number;
  88190. }
  88191. /**
  88192. * @hidden
  88193. **/
  88194. class _InstanceDataStorage {
  88195. visibleInstances: any;
  88196. batchCache: _InstancesBatch;
  88197. instancesBufferSize: number;
  88198. instancesBuffer: Nullable<Buffer>;
  88199. instancesData: Float32Array;
  88200. overridenInstanceCount: number;
  88201. isFrozen: boolean;
  88202. previousBatch: Nullable<_InstancesBatch>;
  88203. hardwareInstancedRendering: boolean;
  88204. sideOrientation: number;
  88205. }
  88206. /**
  88207. * @hidden
  88208. **/
  88209. export class _InstancesBatch {
  88210. mustReturn: boolean;
  88211. visibleInstances: Nullable<InstancedMesh[]>[];
  88212. renderSelf: boolean[];
  88213. hardwareInstancedRendering: boolean[];
  88214. }
  88215. /**
  88216. * Class used to represent renderable models
  88217. */
  88218. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  88219. /**
  88220. * Mesh side orientation : usually the external or front surface
  88221. */
  88222. static readonly FRONTSIDE: number;
  88223. /**
  88224. * Mesh side orientation : usually the internal or back surface
  88225. */
  88226. static readonly BACKSIDE: number;
  88227. /**
  88228. * Mesh side orientation : both internal and external or front and back surfaces
  88229. */
  88230. static readonly DOUBLESIDE: number;
  88231. /**
  88232. * Mesh side orientation : by default, `FRONTSIDE`
  88233. */
  88234. static readonly DEFAULTSIDE: number;
  88235. /**
  88236. * Mesh cap setting : no cap
  88237. */
  88238. static readonly NO_CAP: number;
  88239. /**
  88240. * Mesh cap setting : one cap at the beginning of the mesh
  88241. */
  88242. static readonly CAP_START: number;
  88243. /**
  88244. * Mesh cap setting : one cap at the end of the mesh
  88245. */
  88246. static readonly CAP_END: number;
  88247. /**
  88248. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  88249. */
  88250. static readonly CAP_ALL: number;
  88251. /**
  88252. * Mesh pattern setting : no flip or rotate
  88253. */
  88254. static readonly NO_FLIP: number;
  88255. /**
  88256. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  88257. */
  88258. static readonly FLIP_TILE: number;
  88259. /**
  88260. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  88261. */
  88262. static readonly ROTATE_TILE: number;
  88263. /**
  88264. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  88265. */
  88266. static readonly FLIP_ROW: number;
  88267. /**
  88268. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  88269. */
  88270. static readonly ROTATE_ROW: number;
  88271. /**
  88272. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  88273. */
  88274. static readonly FLIP_N_ROTATE_TILE: number;
  88275. /**
  88276. * Mesh pattern setting : rotate pattern and rotate
  88277. */
  88278. static readonly FLIP_N_ROTATE_ROW: number;
  88279. /**
  88280. * Mesh tile positioning : part tiles same on left/right or top/bottom
  88281. */
  88282. static readonly CENTER: number;
  88283. /**
  88284. * Mesh tile positioning : part tiles on left
  88285. */
  88286. static readonly LEFT: number;
  88287. /**
  88288. * Mesh tile positioning : part tiles on right
  88289. */
  88290. static readonly RIGHT: number;
  88291. /**
  88292. * Mesh tile positioning : part tiles on top
  88293. */
  88294. static readonly TOP: number;
  88295. /**
  88296. * Mesh tile positioning : part tiles on bottom
  88297. */
  88298. static readonly BOTTOM: number;
  88299. /**
  88300. * Gets the default side orientation.
  88301. * @param orientation the orientation to value to attempt to get
  88302. * @returns the default orientation
  88303. * @hidden
  88304. */
  88305. static _GetDefaultSideOrientation(orientation?: number): number;
  88306. private _internalMeshDataInfo;
  88307. /**
  88308. * An event triggered before rendering the mesh
  88309. */
  88310. readonly onBeforeRenderObservable: Observable<Mesh>;
  88311. /**
  88312. * An event triggered before binding the mesh
  88313. */
  88314. readonly onBeforeBindObservable: Observable<Mesh>;
  88315. /**
  88316. * An event triggered after rendering the mesh
  88317. */
  88318. readonly onAfterRenderObservable: Observable<Mesh>;
  88319. /**
  88320. * An event triggered before drawing the mesh
  88321. */
  88322. readonly onBeforeDrawObservable: Observable<Mesh>;
  88323. private _onBeforeDrawObserver;
  88324. /**
  88325. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  88326. */
  88327. onBeforeDraw: () => void;
  88328. readonly hasInstances: boolean;
  88329. /**
  88330. * Gets the delay loading state of the mesh (when delay loading is turned on)
  88331. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  88332. */
  88333. delayLoadState: number;
  88334. /**
  88335. * Gets the list of instances created from this mesh
  88336. * it is not supposed to be modified manually.
  88337. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  88338. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88339. */
  88340. instances: InstancedMesh[];
  88341. /**
  88342. * Gets the file containing delay loading data for this mesh
  88343. */
  88344. delayLoadingFile: string;
  88345. /** @hidden */
  88346. _binaryInfo: any;
  88347. /**
  88348. * User defined function used to change how LOD level selection is done
  88349. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88350. */
  88351. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  88352. /**
  88353. * Gets or sets the morph target manager
  88354. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88355. */
  88356. morphTargetManager: Nullable<MorphTargetManager>;
  88357. /** @hidden */
  88358. _creationDataStorage: Nullable<_CreationDataStorage>;
  88359. /** @hidden */
  88360. _geometry: Nullable<Geometry>;
  88361. /** @hidden */
  88362. _delayInfo: Array<string>;
  88363. /** @hidden */
  88364. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  88365. /** @hidden */
  88366. _instanceDataStorage: _InstanceDataStorage;
  88367. private _effectiveMaterial;
  88368. /** @hidden */
  88369. _shouldGenerateFlatShading: boolean;
  88370. /** @hidden */
  88371. _originalBuilderSideOrientation: number;
  88372. /**
  88373. * Use this property to change the original side orientation defined at construction time
  88374. */
  88375. overrideMaterialSideOrientation: Nullable<number>;
  88376. /**
  88377. * Gets the source mesh (the one used to clone this one from)
  88378. */
  88379. readonly source: Nullable<Mesh>;
  88380. /**
  88381. * Gets or sets a boolean indicating that this mesh does not use index buffer
  88382. */
  88383. isUnIndexed: boolean;
  88384. /**
  88385. * @constructor
  88386. * @param name The value used by scene.getMeshByName() to do a lookup.
  88387. * @param scene The scene to add this mesh to.
  88388. * @param parent The parent of this mesh, if it has one
  88389. * @param source An optional Mesh from which geometry is shared, cloned.
  88390. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88391. * When false, achieved by calling a clone(), also passing False.
  88392. * This will make creation of children, recursive.
  88393. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  88394. */
  88395. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  88396. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  88397. /**
  88398. * Gets the class name
  88399. * @returns the string "Mesh".
  88400. */
  88401. getClassName(): string;
  88402. /** @hidden */
  88403. readonly _isMesh: boolean;
  88404. /**
  88405. * Returns a description of this mesh
  88406. * @param fullDetails define if full details about this mesh must be used
  88407. * @returns a descriptive string representing this mesh
  88408. */
  88409. toString(fullDetails?: boolean): string;
  88410. /** @hidden */
  88411. _unBindEffect(): void;
  88412. /**
  88413. * Gets a boolean indicating if this mesh has LOD
  88414. */
  88415. readonly hasLODLevels: boolean;
  88416. /**
  88417. * Gets the list of MeshLODLevel associated with the current mesh
  88418. * @returns an array of MeshLODLevel
  88419. */
  88420. getLODLevels(): MeshLODLevel[];
  88421. private _sortLODLevels;
  88422. /**
  88423. * Add a mesh as LOD level triggered at the given distance.
  88424. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88425. * @param distance The distance from the center of the object to show this level
  88426. * @param mesh The mesh to be added as LOD level (can be null)
  88427. * @return This mesh (for chaining)
  88428. */
  88429. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  88430. /**
  88431. * Returns the LOD level mesh at the passed distance or null if not found.
  88432. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88433. * @param distance The distance from the center of the object to show this level
  88434. * @returns a Mesh or `null`
  88435. */
  88436. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  88437. /**
  88438. * Remove a mesh from the LOD array
  88439. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88440. * @param mesh defines the mesh to be removed
  88441. * @return This mesh (for chaining)
  88442. */
  88443. removeLODLevel(mesh: Mesh): Mesh;
  88444. /**
  88445. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  88446. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88447. * @param camera defines the camera to use to compute distance
  88448. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  88449. * @return This mesh (for chaining)
  88450. */
  88451. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  88452. /**
  88453. * Gets the mesh internal Geometry object
  88454. */
  88455. readonly geometry: Nullable<Geometry>;
  88456. /**
  88457. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  88458. * @returns the total number of vertices
  88459. */
  88460. getTotalVertices(): number;
  88461. /**
  88462. * Returns the content of an associated vertex buffer
  88463. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88464. * - VertexBuffer.PositionKind
  88465. * - VertexBuffer.UVKind
  88466. * - VertexBuffer.UV2Kind
  88467. * - VertexBuffer.UV3Kind
  88468. * - VertexBuffer.UV4Kind
  88469. * - VertexBuffer.UV5Kind
  88470. * - VertexBuffer.UV6Kind
  88471. * - VertexBuffer.ColorKind
  88472. * - VertexBuffer.MatricesIndicesKind
  88473. * - VertexBuffer.MatricesIndicesExtraKind
  88474. * - VertexBuffer.MatricesWeightsKind
  88475. * - VertexBuffer.MatricesWeightsExtraKind
  88476. * @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
  88477. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  88478. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  88479. */
  88480. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88481. /**
  88482. * Returns the mesh VertexBuffer object from the requested `kind`
  88483. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88484. * - VertexBuffer.PositionKind
  88485. * - VertexBuffer.NormalKind
  88486. * - VertexBuffer.UVKind
  88487. * - VertexBuffer.UV2Kind
  88488. * - VertexBuffer.UV3Kind
  88489. * - VertexBuffer.UV4Kind
  88490. * - VertexBuffer.UV5Kind
  88491. * - VertexBuffer.UV6Kind
  88492. * - VertexBuffer.ColorKind
  88493. * - VertexBuffer.MatricesIndicesKind
  88494. * - VertexBuffer.MatricesIndicesExtraKind
  88495. * - VertexBuffer.MatricesWeightsKind
  88496. * - VertexBuffer.MatricesWeightsExtraKind
  88497. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  88498. */
  88499. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88500. /**
  88501. * Tests if a specific vertex buffer is associated with this mesh
  88502. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88503. * - VertexBuffer.PositionKind
  88504. * - VertexBuffer.NormalKind
  88505. * - VertexBuffer.UVKind
  88506. * - VertexBuffer.UV2Kind
  88507. * - VertexBuffer.UV3Kind
  88508. * - VertexBuffer.UV4Kind
  88509. * - VertexBuffer.UV5Kind
  88510. * - VertexBuffer.UV6Kind
  88511. * - VertexBuffer.ColorKind
  88512. * - VertexBuffer.MatricesIndicesKind
  88513. * - VertexBuffer.MatricesIndicesExtraKind
  88514. * - VertexBuffer.MatricesWeightsKind
  88515. * - VertexBuffer.MatricesWeightsExtraKind
  88516. * @returns a boolean
  88517. */
  88518. isVerticesDataPresent(kind: string): boolean;
  88519. /**
  88520. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  88521. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88522. * - VertexBuffer.PositionKind
  88523. * - VertexBuffer.UVKind
  88524. * - VertexBuffer.UV2Kind
  88525. * - VertexBuffer.UV3Kind
  88526. * - VertexBuffer.UV4Kind
  88527. * - VertexBuffer.UV5Kind
  88528. * - VertexBuffer.UV6Kind
  88529. * - VertexBuffer.ColorKind
  88530. * - VertexBuffer.MatricesIndicesKind
  88531. * - VertexBuffer.MatricesIndicesExtraKind
  88532. * - VertexBuffer.MatricesWeightsKind
  88533. * - VertexBuffer.MatricesWeightsExtraKind
  88534. * @returns a boolean
  88535. */
  88536. isVertexBufferUpdatable(kind: string): boolean;
  88537. /**
  88538. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  88539. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88540. * - VertexBuffer.PositionKind
  88541. * - VertexBuffer.NormalKind
  88542. * - VertexBuffer.UVKind
  88543. * - VertexBuffer.UV2Kind
  88544. * - VertexBuffer.UV3Kind
  88545. * - VertexBuffer.UV4Kind
  88546. * - VertexBuffer.UV5Kind
  88547. * - VertexBuffer.UV6Kind
  88548. * - VertexBuffer.ColorKind
  88549. * - VertexBuffer.MatricesIndicesKind
  88550. * - VertexBuffer.MatricesIndicesExtraKind
  88551. * - VertexBuffer.MatricesWeightsKind
  88552. * - VertexBuffer.MatricesWeightsExtraKind
  88553. * @returns an array of strings
  88554. */
  88555. getVerticesDataKinds(): string[];
  88556. /**
  88557. * Returns a positive integer : the total number of indices in this mesh geometry.
  88558. * @returns the numner of indices or zero if the mesh has no geometry.
  88559. */
  88560. getTotalIndices(): number;
  88561. /**
  88562. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88563. * @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.
  88564. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88565. * @returns the indices array or an empty array if the mesh has no geometry
  88566. */
  88567. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88568. readonly isBlocked: boolean;
  88569. /**
  88570. * Determine if the current mesh is ready to be rendered
  88571. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88572. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  88573. * @returns true if all associated assets are ready (material, textures, shaders)
  88574. */
  88575. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  88576. /**
  88577. * 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.
  88578. */
  88579. readonly areNormalsFrozen: boolean;
  88580. /**
  88581. * 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.
  88582. * @returns the current mesh
  88583. */
  88584. freezeNormals(): Mesh;
  88585. /**
  88586. * 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
  88587. * @returns the current mesh
  88588. */
  88589. unfreezeNormals(): Mesh;
  88590. /**
  88591. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88592. */
  88593. overridenInstanceCount: number;
  88594. /** @hidden */
  88595. _preActivate(): Mesh;
  88596. /** @hidden */
  88597. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88598. /** @hidden */
  88599. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  88600. /**
  88601. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88602. * This means the mesh underlying bounding box and sphere are recomputed.
  88603. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88604. * @returns the current mesh
  88605. */
  88606. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  88607. /** @hidden */
  88608. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  88609. /**
  88610. * This function will subdivide the mesh into multiple submeshes
  88611. * @param count defines the expected number of submeshes
  88612. */
  88613. subdivide(count: number): void;
  88614. /**
  88615. * Copy a FloatArray into a specific associated vertex buffer
  88616. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88617. * - VertexBuffer.PositionKind
  88618. * - VertexBuffer.UVKind
  88619. * - VertexBuffer.UV2Kind
  88620. * - VertexBuffer.UV3Kind
  88621. * - VertexBuffer.UV4Kind
  88622. * - VertexBuffer.UV5Kind
  88623. * - VertexBuffer.UV6Kind
  88624. * - VertexBuffer.ColorKind
  88625. * - VertexBuffer.MatricesIndicesKind
  88626. * - VertexBuffer.MatricesIndicesExtraKind
  88627. * - VertexBuffer.MatricesWeightsKind
  88628. * - VertexBuffer.MatricesWeightsExtraKind
  88629. * @param data defines the data source
  88630. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88631. * @param stride defines the data stride size (can be null)
  88632. * @returns the current mesh
  88633. */
  88634. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88635. /**
  88636. * Flags an associated vertex buffer as updatable
  88637. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88638. * - VertexBuffer.PositionKind
  88639. * - VertexBuffer.UVKind
  88640. * - VertexBuffer.UV2Kind
  88641. * - VertexBuffer.UV3Kind
  88642. * - VertexBuffer.UV4Kind
  88643. * - VertexBuffer.UV5Kind
  88644. * - VertexBuffer.UV6Kind
  88645. * - VertexBuffer.ColorKind
  88646. * - VertexBuffer.MatricesIndicesKind
  88647. * - VertexBuffer.MatricesIndicesExtraKind
  88648. * - VertexBuffer.MatricesWeightsKind
  88649. * - VertexBuffer.MatricesWeightsExtraKind
  88650. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88651. */
  88652. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  88653. /**
  88654. * Sets the mesh global Vertex Buffer
  88655. * @param buffer defines the buffer to use
  88656. * @returns the current mesh
  88657. */
  88658. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  88659. /**
  88660. * Update a specific associated vertex buffer
  88661. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88662. * - VertexBuffer.PositionKind
  88663. * - VertexBuffer.UVKind
  88664. * - VertexBuffer.UV2Kind
  88665. * - VertexBuffer.UV3Kind
  88666. * - VertexBuffer.UV4Kind
  88667. * - VertexBuffer.UV5Kind
  88668. * - VertexBuffer.UV6Kind
  88669. * - VertexBuffer.ColorKind
  88670. * - VertexBuffer.MatricesIndicesKind
  88671. * - VertexBuffer.MatricesIndicesExtraKind
  88672. * - VertexBuffer.MatricesWeightsKind
  88673. * - VertexBuffer.MatricesWeightsExtraKind
  88674. * @param data defines the data source
  88675. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88676. * @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)
  88677. * @returns the current mesh
  88678. */
  88679. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  88680. /**
  88681. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88682. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88683. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88684. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88685. * @returns the current mesh
  88686. */
  88687. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  88688. /**
  88689. * Creates a un-shared specific occurence of the geometry for the mesh.
  88690. * @returns the current mesh
  88691. */
  88692. makeGeometryUnique(): Mesh;
  88693. /**
  88694. * Set the index buffer of this mesh
  88695. * @param indices defines the source data
  88696. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88697. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88698. * @returns the current mesh
  88699. */
  88700. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  88701. /**
  88702. * Update the current index buffer
  88703. * @param indices defines the source data
  88704. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88705. * @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)
  88706. * @returns the current mesh
  88707. */
  88708. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88709. /**
  88710. * Invert the geometry to move from a right handed system to a left handed one.
  88711. * @returns the current mesh
  88712. */
  88713. toLeftHanded(): Mesh;
  88714. /** @hidden */
  88715. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88716. /** @hidden */
  88717. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88718. /**
  88719. * Registers for this mesh a javascript function called just before the rendering process
  88720. * @param func defines the function to call before rendering this mesh
  88721. * @returns the current mesh
  88722. */
  88723. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88724. /**
  88725. * Disposes a previously registered javascript function called before the rendering
  88726. * @param func defines the function to remove
  88727. * @returns the current mesh
  88728. */
  88729. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88730. /**
  88731. * Registers for this mesh a javascript function called just after the rendering is complete
  88732. * @param func defines the function to call after rendering this mesh
  88733. * @returns the current mesh
  88734. */
  88735. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88736. /**
  88737. * Disposes a previously registered javascript function called after the rendering.
  88738. * @param func defines the function to remove
  88739. * @returns the current mesh
  88740. */
  88741. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88742. /** @hidden */
  88743. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  88744. /** @hidden */
  88745. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  88746. /** @hidden */
  88747. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  88748. /** @hidden */
  88749. _rebuild(): void;
  88750. /** @hidden */
  88751. _freeze(): void;
  88752. /** @hidden */
  88753. _unFreeze(): void;
  88754. /**
  88755. * 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
  88756. * @param subMesh defines the subMesh to render
  88757. * @param enableAlphaMode defines if alpha mode can be changed
  88758. * @returns the current mesh
  88759. */
  88760. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  88761. private _onBeforeDraw;
  88762. /**
  88763. * Renormalize the mesh and patch it up if there are no weights
  88764. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88765. * However in the case of zero weights then we set just a single influence to 1.
  88766. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88767. */
  88768. cleanMatrixWeights(): void;
  88769. private normalizeSkinFourWeights;
  88770. private normalizeSkinWeightsAndExtra;
  88771. /**
  88772. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88773. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88774. * the user know there was an issue with importing the mesh
  88775. * @returns a validation object with skinned, valid and report string
  88776. */
  88777. validateSkinning(): {
  88778. skinned: boolean;
  88779. valid: boolean;
  88780. report: string;
  88781. };
  88782. /** @hidden */
  88783. _checkDelayState(): Mesh;
  88784. private _queueLoad;
  88785. /**
  88786. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88787. * A mesh is in the frustum if its bounding box intersects the frustum
  88788. * @param frustumPlanes defines the frustum to test
  88789. * @returns true if the mesh is in the frustum planes
  88790. */
  88791. isInFrustum(frustumPlanes: Plane[]): boolean;
  88792. /**
  88793. * Sets the mesh material by the material or multiMaterial `id` property
  88794. * @param id is a string identifying the material or the multiMaterial
  88795. * @returns the current mesh
  88796. */
  88797. setMaterialByID(id: string): Mesh;
  88798. /**
  88799. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88800. * @returns an array of IAnimatable
  88801. */
  88802. getAnimatables(): IAnimatable[];
  88803. /**
  88804. * Modifies the mesh geometry according to the passed transformation matrix.
  88805. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88806. * The mesh normals are modified using the same transformation.
  88807. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88808. * @param transform defines the transform matrix to use
  88809. * @see http://doc.babylonjs.com/resources/baking_transformations
  88810. * @returns the current mesh
  88811. */
  88812. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88813. /**
  88814. * Modifies the mesh geometry according to its own current World Matrix.
  88815. * The mesh World Matrix is then reset.
  88816. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88817. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88818. * @see http://doc.babylonjs.com/resources/baking_transformations
  88819. * @returns the current mesh
  88820. */
  88821. bakeCurrentTransformIntoVertices(): Mesh;
  88822. /** @hidden */
  88823. readonly _positions: Nullable<Vector3[]>;
  88824. /** @hidden */
  88825. _resetPointsArrayCache(): Mesh;
  88826. /** @hidden */
  88827. _generatePointsArray(): boolean;
  88828. /**
  88829. * Returns a new Mesh object generated from the current mesh properties.
  88830. * This method must not get confused with createInstance()
  88831. * @param name is a string, the name given to the new mesh
  88832. * @param newParent can be any Node object (default `null`)
  88833. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88834. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88835. * @returns a new mesh
  88836. */
  88837. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  88838. /**
  88839. * Releases resources associated with this mesh.
  88840. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88841. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88842. */
  88843. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88844. /**
  88845. * Modifies the mesh geometry according to a displacement map.
  88846. * 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.
  88847. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88848. * @param url is a string, the URL from the image file is to be downloaded.
  88849. * @param minHeight is the lower limit of the displacement.
  88850. * @param maxHeight is the upper limit of the displacement.
  88851. * @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.
  88852. * @param uvOffset is an optional vector2 used to offset UV.
  88853. * @param uvScale is an optional vector2 used to scale UV.
  88854. * @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.
  88855. * @returns the Mesh.
  88856. */
  88857. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88858. /**
  88859. * Modifies the mesh geometry according to a displacementMap buffer.
  88860. * 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.
  88861. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88862. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88863. * @param heightMapWidth is the width of the buffer image.
  88864. * @param heightMapHeight is the height of the buffer image.
  88865. * @param minHeight is the lower limit of the displacement.
  88866. * @param maxHeight is the upper limit of the displacement.
  88867. * @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.
  88868. * @param uvOffset is an optional vector2 used to offset UV.
  88869. * @param uvScale is an optional vector2 used to scale UV.
  88870. * @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.
  88871. * @returns the Mesh.
  88872. */
  88873. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88874. /**
  88875. * Modify the mesh to get a flat shading rendering.
  88876. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88877. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88878. * @returns current mesh
  88879. */
  88880. convertToFlatShadedMesh(): Mesh;
  88881. /**
  88882. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88883. * In other words, more vertices, no more indices and a single bigger VBO.
  88884. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88885. * @returns current mesh
  88886. */
  88887. convertToUnIndexedMesh(): Mesh;
  88888. /**
  88889. * Inverses facet orientations.
  88890. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88891. * @param flipNormals will also inverts the normals
  88892. * @returns current mesh
  88893. */
  88894. flipFaces(flipNormals?: boolean): Mesh;
  88895. /**
  88896. * Increase the number of facets and hence vertices in a mesh
  88897. * Vertex normals are interpolated from existing vertex normals
  88898. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88899. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88900. */
  88901. increaseVertices(numberPerEdge: number): void;
  88902. /**
  88903. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88904. * This will undo any application of covertToFlatShadedMesh
  88905. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88906. */
  88907. forceSharedVertices(): void;
  88908. /** @hidden */
  88909. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  88910. /** @hidden */
  88911. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  88912. /**
  88913. * Creates a new InstancedMesh object from the mesh model.
  88914. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88915. * @param name defines the name of the new instance
  88916. * @returns a new InstancedMesh
  88917. */
  88918. createInstance(name: string): InstancedMesh;
  88919. /**
  88920. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88921. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88922. * @returns the current mesh
  88923. */
  88924. synchronizeInstances(): Mesh;
  88925. /**
  88926. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88927. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88928. * This should be used together with the simplification to avoid disappearing triangles.
  88929. * @param successCallback an optional success callback to be called after the optimization finished.
  88930. * @returns the current mesh
  88931. */
  88932. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  88933. /**
  88934. * Serialize current mesh
  88935. * @param serializationObject defines the object which will receive the serialization data
  88936. */
  88937. serialize(serializationObject: any): void;
  88938. /** @hidden */
  88939. _syncGeometryWithMorphTargetManager(): void;
  88940. /** @hidden */
  88941. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  88942. /**
  88943. * Returns a new Mesh object parsed from the source provided.
  88944. * @param parsedMesh is the source
  88945. * @param scene defines the hosting scene
  88946. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88947. * @returns a new Mesh
  88948. */
  88949. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  88950. /**
  88951. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88952. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88953. * @param name defines the name of the mesh to create
  88954. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88955. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88956. * @param closePath creates a seam between the first and the last points of each path of the path array
  88957. * @param offset is taken in account only if the `pathArray` is containing a single path
  88958. * @param scene defines the hosting scene
  88959. * @param updatable defines if the mesh must be flagged as updatable
  88960. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88961. * @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)
  88962. * @returns a new Mesh
  88963. */
  88964. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88965. /**
  88966. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88967. * @param name defines the name of the mesh to create
  88968. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88969. * @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
  88970. * @param scene defines the hosting scene
  88971. * @param updatable defines if the mesh must be flagged as updatable
  88972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88973. * @returns a new Mesh
  88974. */
  88975. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88976. /**
  88977. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88978. * @param name defines the name of the mesh to create
  88979. * @param size sets the size (float) of each box side (default 1)
  88980. * @param scene defines the hosting scene
  88981. * @param updatable defines if the mesh must be flagged as updatable
  88982. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88983. * @returns a new Mesh
  88984. */
  88985. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88986. /**
  88987. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88988. * @param name defines the name of the mesh to create
  88989. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88990. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88991. * @param scene defines the hosting scene
  88992. * @param updatable defines if the mesh must be flagged as updatable
  88993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88994. * @returns a new Mesh
  88995. */
  88996. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88997. /**
  88998. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  88999. * @param name defines the name of the mesh to create
  89000. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89001. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89002. * @param scene defines the hosting scene
  89003. * @returns a new Mesh
  89004. */
  89005. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89006. /**
  89007. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89008. * @param name defines the name of the mesh to create
  89009. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89010. * @param diameterTop set the top cap diameter (floats, default 1)
  89011. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89012. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89013. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89014. * @param scene defines the hosting scene
  89015. * @param updatable defines if the mesh must be flagged as updatable
  89016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89017. * @returns a new Mesh
  89018. */
  89019. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89020. /**
  89021. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89022. * @param name defines the name of the mesh to create
  89023. * @param diameter sets the diameter size (float) of the torus (default 1)
  89024. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89025. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89026. * @param scene defines the hosting scene
  89027. * @param updatable defines if the mesh must be flagged as updatable
  89028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89029. * @returns a new Mesh
  89030. */
  89031. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89032. /**
  89033. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89034. * @param name defines the name of the mesh to create
  89035. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89036. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89037. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89038. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89039. * @param p the number of windings on X axis (positive integers, default 2)
  89040. * @param q the number of windings on Y axis (positive integers, default 3)
  89041. * @param scene defines the hosting scene
  89042. * @param updatable defines if the mesh must be flagged as updatable
  89043. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89044. * @returns a new Mesh
  89045. */
  89046. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89047. /**
  89048. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89049. * @param name defines the name of the mesh to create
  89050. * @param points is an array successive Vector3
  89051. * @param scene defines the hosting scene
  89052. * @param updatable defines if the mesh must be flagged as updatable
  89053. * @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).
  89054. * @returns a new Mesh
  89055. */
  89056. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  89057. /**
  89058. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89059. * @param name defines the name of the mesh to create
  89060. * @param points is an array successive Vector3
  89061. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89062. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89063. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89064. * @param scene defines the hosting scene
  89065. * @param updatable defines if the mesh must be flagged as updatable
  89066. * @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)
  89067. * @returns a new Mesh
  89068. */
  89069. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  89070. /**
  89071. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89072. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89073. * 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.
  89074. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89075. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89076. * Remember you can only change the shape positions, not their number when updating a polygon.
  89077. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89078. * @param name defines the name of the mesh to create
  89079. * @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
  89080. * @param scene defines the hosting scene
  89081. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89082. * @param updatable defines if the mesh must be flagged as updatable
  89083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89084. * @param earcutInjection can be used to inject your own earcut reference
  89085. * @returns a new Mesh
  89086. */
  89087. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89088. /**
  89089. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89091. * @param name defines the name of the mesh to create
  89092. * @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
  89093. * @param depth defines the height of extrusion
  89094. * @param scene defines the hosting scene
  89095. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89096. * @param updatable defines if the mesh must be flagged as updatable
  89097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89098. * @param earcutInjection can be used to inject your own earcut reference
  89099. * @returns a new Mesh
  89100. */
  89101. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89102. /**
  89103. * Creates an extruded shape mesh.
  89104. * 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
  89105. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89107. * @param name defines the name of the mesh to create
  89108. * @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
  89109. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89110. * @param scale is the value to scale the shape
  89111. * @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
  89112. * @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
  89113. * @param scene defines the hosting scene
  89114. * @param updatable defines if the mesh must be flagged as updatable
  89115. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89116. * @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)
  89117. * @returns a new Mesh
  89118. */
  89119. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89120. /**
  89121. * Creates an custom extruded shape mesh.
  89122. * The custom extrusion is a parametric shape.
  89123. * It has no predefined shape. Its final shape will depend on the input parameters.
  89124. * Please consider using the same method from the MeshBuilder class instead
  89125. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89126. * @param name defines the name of the mesh to create
  89127. * @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
  89128. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89129. * @param scaleFunction is a custom Javascript function called on each path point
  89130. * @param rotationFunction is a custom Javascript function called on each path point
  89131. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89132. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  89133. * @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
  89134. * @param scene defines the hosting scene
  89135. * @param updatable defines if the mesh must be flagged as updatable
  89136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89137. * @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)
  89138. * @returns a new Mesh
  89139. */
  89140. 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;
  89141. /**
  89142. * Creates lathe mesh.
  89143. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  89144. * Please consider using the same method from the MeshBuilder class instead
  89145. * @param name defines the name of the mesh to create
  89146. * @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
  89147. * @param radius is the radius value of the lathe
  89148. * @param tessellation is the side number of the lathe.
  89149. * @param scene defines the hosting scene
  89150. * @param updatable defines if the mesh must be flagged as updatable
  89151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89152. * @returns a new Mesh
  89153. */
  89154. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89155. /**
  89156. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  89157. * @param name defines the name of the mesh to create
  89158. * @param size sets the size (float) of both sides of the plane at once (default 1)
  89159. * @param scene defines the hosting scene
  89160. * @param updatable defines if the mesh must be flagged as updatable
  89161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89162. * @returns a new Mesh
  89163. */
  89164. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89165. /**
  89166. * Creates a ground mesh.
  89167. * Please consider using the same method from the MeshBuilder class instead
  89168. * @param name defines the name of the mesh to create
  89169. * @param width set the width of the ground
  89170. * @param height set the height of the ground
  89171. * @param subdivisions sets the number of subdivisions per side
  89172. * @param scene defines the hosting scene
  89173. * @param updatable defines if the mesh must be flagged as updatable
  89174. * @returns a new Mesh
  89175. */
  89176. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  89177. /**
  89178. * Creates a tiled ground mesh.
  89179. * Please consider using the same method from the MeshBuilder class instead
  89180. * @param name defines the name of the mesh to create
  89181. * @param xmin set the ground minimum X coordinate
  89182. * @param zmin set the ground minimum Y coordinate
  89183. * @param xmax set the ground maximum X coordinate
  89184. * @param zmax set the ground maximum Z coordinate
  89185. * @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
  89186. * @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
  89187. * @param scene defines the hosting scene
  89188. * @param updatable defines if the mesh must be flagged as updatable
  89189. * @returns a new Mesh
  89190. */
  89191. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  89192. w: number;
  89193. h: number;
  89194. }, precision: {
  89195. w: number;
  89196. h: number;
  89197. }, scene: Scene, updatable?: boolean): Mesh;
  89198. /**
  89199. * Creates a ground mesh from a height map.
  89200. * Please consider using the same method from the MeshBuilder class instead
  89201. * @see http://doc.babylonjs.com/babylon101/height_map
  89202. * @param name defines the name of the mesh to create
  89203. * @param url sets the URL of the height map image resource
  89204. * @param width set the ground width size
  89205. * @param height set the ground height size
  89206. * @param subdivisions sets the number of subdivision per side
  89207. * @param minHeight is the minimum altitude on the ground
  89208. * @param maxHeight is the maximum altitude on the ground
  89209. * @param scene defines the hosting scene
  89210. * @param updatable defines if the mesh must be flagged as updatable
  89211. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  89212. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89213. * @returns a new Mesh
  89214. */
  89215. 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;
  89216. /**
  89217. * Creates a tube mesh.
  89218. * The tube is a parametric shape.
  89219. * It has no predefined shape. Its final shape will depend on the input parameters.
  89220. * Please consider using the same method from the MeshBuilder class instead
  89221. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89222. * @param name defines the name of the mesh to create
  89223. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  89224. * @param radius sets the tube radius size
  89225. * @param tessellation is the number of sides on the tubular surface
  89226. * @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
  89227. * @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
  89228. * @param scene defines the hosting scene
  89229. * @param updatable defines if the mesh must be flagged as updatable
  89230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89231. * @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)
  89232. * @returns a new Mesh
  89233. */
  89234. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  89235. (i: number, distance: number): number;
  89236. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89237. /**
  89238. * Creates a polyhedron mesh.
  89239. * Please consider using the same method from the MeshBuilder class instead.
  89240. * * 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
  89241. * * The parameter `size` (positive float, default 1) sets the polygon size
  89242. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89243. * * 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`
  89244. * * 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
  89245. * * 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)`)
  89246. * * 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
  89247. * * 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
  89248. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89249. * * If you create a double-sided mesh, you can choose what parts of 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
  89250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89251. * @param name defines the name of the mesh to create
  89252. * @param options defines the options used to create the mesh
  89253. * @param scene defines the hosting scene
  89254. * @returns a new Mesh
  89255. */
  89256. static CreatePolyhedron(name: string, options: {
  89257. type?: number;
  89258. size?: number;
  89259. sizeX?: number;
  89260. sizeY?: number;
  89261. sizeZ?: number;
  89262. custom?: any;
  89263. faceUV?: Vector4[];
  89264. faceColors?: Color4[];
  89265. updatable?: boolean;
  89266. sideOrientation?: number;
  89267. }, scene: Scene): Mesh;
  89268. /**
  89269. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89270. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89271. * * 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`)
  89272. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89273. * * 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
  89274. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89275. * * If you create a double-sided mesh, you can choose what parts of 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
  89276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89277. * @param name defines the name of the mesh
  89278. * @param options defines the options used to create the mesh
  89279. * @param scene defines the hosting scene
  89280. * @returns a new Mesh
  89281. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89282. */
  89283. static CreateIcoSphere(name: string, options: {
  89284. radius?: number;
  89285. flat?: boolean;
  89286. subdivisions?: number;
  89287. sideOrientation?: number;
  89288. updatable?: boolean;
  89289. }, scene: Scene): Mesh;
  89290. /**
  89291. * Creates a decal mesh.
  89292. * Please consider using the same method from the MeshBuilder class instead.
  89293. * A decal is a mesh usually applied as a model onto the surface of another mesh
  89294. * @param name defines the name of the mesh
  89295. * @param sourceMesh defines the mesh receiving the decal
  89296. * @param position sets the position of the decal in world coordinates
  89297. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89298. * @param size sets the decal scaling
  89299. * @param angle sets the angle to rotate the decal
  89300. * @returns a new Mesh
  89301. */
  89302. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  89303. /**
  89304. * Prepare internal position array for software CPU skinning
  89305. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  89306. */
  89307. setPositionsForCPUSkinning(): Float32Array;
  89308. /**
  89309. * Prepare internal normal array for software CPU skinning
  89310. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  89311. */
  89312. setNormalsForCPUSkinning(): Float32Array;
  89313. /**
  89314. * Updates the vertex buffer by applying transformation from the bones
  89315. * @param skeleton defines the skeleton to apply to current mesh
  89316. * @returns the current mesh
  89317. */
  89318. applySkeleton(skeleton: Skeleton): Mesh;
  89319. /**
  89320. * 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
  89321. * @param meshes defines the list of meshes to scan
  89322. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89323. */
  89324. static MinMax(meshes: AbstractMesh[]): {
  89325. min: Vector3;
  89326. max: Vector3;
  89327. };
  89328. /**
  89329. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89330. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89331. * @returns a vector3
  89332. */
  89333. static Center(meshesOrMinMaxVector: {
  89334. min: Vector3;
  89335. max: Vector3;
  89336. } | AbstractMesh[]): Vector3;
  89337. /**
  89338. * Merge the array of meshes into a single mesh for performance reasons.
  89339. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89340. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89341. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89342. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89343. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89344. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89345. * @returns a new mesh
  89346. */
  89347. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  89348. /** @hidden */
  89349. addInstance(instance: InstancedMesh): void;
  89350. /** @hidden */
  89351. removeInstance(instance: InstancedMesh): void;
  89352. }
  89353. }
  89354. declare module BABYLON {
  89355. /**
  89356. * This is the base class of all the camera used in the application.
  89357. * @see http://doc.babylonjs.com/features/cameras
  89358. */
  89359. export class Camera extends Node {
  89360. /** @hidden */
  89361. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89362. /**
  89363. * This is the default projection mode used by the cameras.
  89364. * It helps recreating a feeling of perspective and better appreciate depth.
  89365. * This is the best way to simulate real life cameras.
  89366. */
  89367. static readonly PERSPECTIVE_CAMERA: number;
  89368. /**
  89369. * This helps creating camera with an orthographic mode.
  89370. * 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.
  89371. */
  89372. static readonly ORTHOGRAPHIC_CAMERA: number;
  89373. /**
  89374. * This is the default FOV mode for perspective cameras.
  89375. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89376. */
  89377. static readonly FOVMODE_VERTICAL_FIXED: number;
  89378. /**
  89379. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89380. */
  89381. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89382. /**
  89383. * This specifies ther is no need for a camera rig.
  89384. * Basically only one eye is rendered corresponding to the camera.
  89385. */
  89386. static readonly RIG_MODE_NONE: number;
  89387. /**
  89388. * Simulates a camera Rig with one blue eye and one red eye.
  89389. * This can be use with 3d blue and red glasses.
  89390. */
  89391. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89392. /**
  89393. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89394. */
  89395. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89396. /**
  89397. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89398. */
  89399. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89400. /**
  89401. * Defines that both eyes of the camera will be rendered over under each other.
  89402. */
  89403. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89404. /**
  89405. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89406. */
  89407. static readonly RIG_MODE_VR: number;
  89408. /**
  89409. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89410. */
  89411. static readonly RIG_MODE_WEBVR: number;
  89412. /**
  89413. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89414. */
  89415. static readonly RIG_MODE_CUSTOM: number;
  89416. /**
  89417. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89418. */
  89419. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89420. /**
  89421. * Define the input manager associated with the camera.
  89422. */
  89423. inputs: CameraInputsManager<Camera>;
  89424. /** @hidden */
  89425. _position: Vector3;
  89426. /**
  89427. * Define the current local position of the camera in the scene
  89428. */
  89429. position: Vector3;
  89430. /**
  89431. * The vector the camera should consider as up.
  89432. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89433. */
  89434. upVector: Vector3;
  89435. /**
  89436. * Define the current limit on the left side for an orthographic camera
  89437. * In scene unit
  89438. */
  89439. orthoLeft: Nullable<number>;
  89440. /**
  89441. * Define the current limit on the right side for an orthographic camera
  89442. * In scene unit
  89443. */
  89444. orthoRight: Nullable<number>;
  89445. /**
  89446. * Define the current limit on the bottom side for an orthographic camera
  89447. * In scene unit
  89448. */
  89449. orthoBottom: Nullable<number>;
  89450. /**
  89451. * Define the current limit on the top side for an orthographic camera
  89452. * In scene unit
  89453. */
  89454. orthoTop: Nullable<number>;
  89455. /**
  89456. * Field Of View is set in Radians. (default is 0.8)
  89457. */
  89458. fov: number;
  89459. /**
  89460. * Define the minimum distance the camera can see from.
  89461. * This is important to note that the depth buffer are not infinite and the closer it starts
  89462. * the more your scene might encounter depth fighting issue.
  89463. */
  89464. minZ: number;
  89465. /**
  89466. * Define the maximum distance the camera can see to.
  89467. * This is important to note that the depth buffer are not infinite and the further it end
  89468. * the more your scene might encounter depth fighting issue.
  89469. */
  89470. maxZ: number;
  89471. /**
  89472. * Define the default inertia of the camera.
  89473. * This helps giving a smooth feeling to the camera movement.
  89474. */
  89475. inertia: number;
  89476. /**
  89477. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  89478. */
  89479. mode: number;
  89480. /**
  89481. * Define wether the camera is intermediate.
  89482. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89483. */
  89484. isIntermediate: boolean;
  89485. /**
  89486. * Define the viewport of the camera.
  89487. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89488. */
  89489. viewport: Viewport;
  89490. /**
  89491. * Restricts the camera to viewing objects with the same layerMask.
  89492. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89493. */
  89494. layerMask: number;
  89495. /**
  89496. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89497. */
  89498. fovMode: number;
  89499. /**
  89500. * Rig mode of the camera.
  89501. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89502. * This is normally controlled byt the camera themselves as internal use.
  89503. */
  89504. cameraRigMode: number;
  89505. /**
  89506. * Defines the distance between both "eyes" in case of a RIG
  89507. */
  89508. interaxialDistance: number;
  89509. /**
  89510. * Defines if stereoscopic rendering is done side by side or over under.
  89511. */
  89512. isStereoscopicSideBySide: boolean;
  89513. /**
  89514. * 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
  89515. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89516. * else in the scene. (Eg. security camera)
  89517. *
  89518. * 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)
  89519. */
  89520. customRenderTargets: RenderTargetTexture[];
  89521. /**
  89522. * When set, the camera will render to this render target instead of the default canvas
  89523. *
  89524. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  89525. */
  89526. outputRenderTarget: Nullable<RenderTargetTexture>;
  89527. /**
  89528. * Observable triggered when the camera view matrix has changed.
  89529. */
  89530. onViewMatrixChangedObservable: Observable<Camera>;
  89531. /**
  89532. * Observable triggered when the camera Projection matrix has changed.
  89533. */
  89534. onProjectionMatrixChangedObservable: Observable<Camera>;
  89535. /**
  89536. * Observable triggered when the inputs have been processed.
  89537. */
  89538. onAfterCheckInputsObservable: Observable<Camera>;
  89539. /**
  89540. * Observable triggered when reset has been called and applied to the camera.
  89541. */
  89542. onRestoreStateObservable: Observable<Camera>;
  89543. /** @hidden */
  89544. _cameraRigParams: any;
  89545. /** @hidden */
  89546. _rigCameras: Camera[];
  89547. /** @hidden */
  89548. _rigPostProcess: Nullable<PostProcess>;
  89549. protected _webvrViewMatrix: Matrix;
  89550. /** @hidden */
  89551. _skipRendering: boolean;
  89552. /** @hidden */
  89553. _projectionMatrix: Matrix;
  89554. /** @hidden */
  89555. _postProcesses: Nullable<PostProcess>[];
  89556. /** @hidden */
  89557. _activeMeshes: SmartArray<AbstractMesh>;
  89558. protected _globalPosition: Vector3;
  89559. /** @hidden */
  89560. _computedViewMatrix: Matrix;
  89561. private _doNotComputeProjectionMatrix;
  89562. private _transformMatrix;
  89563. private _frustumPlanes;
  89564. private _refreshFrustumPlanes;
  89565. private _storedFov;
  89566. private _stateStored;
  89567. /**
  89568. * Instantiates a new camera object.
  89569. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89570. * @see http://doc.babylonjs.com/features/cameras
  89571. * @param name Defines the name of the camera in the scene
  89572. * @param position Defines the position of the camera
  89573. * @param scene Defines the scene the camera belongs too
  89574. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89575. */
  89576. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89577. /**
  89578. * Store current camera state (fov, position, etc..)
  89579. * @returns the camera
  89580. */
  89581. storeState(): Camera;
  89582. /**
  89583. * Restores the camera state values if it has been stored. You must call storeState() first
  89584. */
  89585. protected _restoreStateValues(): boolean;
  89586. /**
  89587. * Restored camera state. You must call storeState() first.
  89588. * @returns true if restored and false otherwise
  89589. */
  89590. restoreState(): boolean;
  89591. /**
  89592. * Gets the class name of the camera.
  89593. * @returns the class name
  89594. */
  89595. getClassName(): string;
  89596. /** @hidden */
  89597. readonly _isCamera: boolean;
  89598. /**
  89599. * Gets a string representation of the camera useful for debug purpose.
  89600. * @param fullDetails Defines that a more verboe level of logging is required
  89601. * @returns the string representation
  89602. */
  89603. toString(fullDetails?: boolean): string;
  89604. /**
  89605. * Gets the current world space position of the camera.
  89606. */
  89607. readonly globalPosition: Vector3;
  89608. /**
  89609. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89610. * @returns the active meshe list
  89611. */
  89612. getActiveMeshes(): SmartArray<AbstractMesh>;
  89613. /**
  89614. * Check wether a mesh is part of the current active mesh list of the camera
  89615. * @param mesh Defines the mesh to check
  89616. * @returns true if active, false otherwise
  89617. */
  89618. isActiveMesh(mesh: Mesh): boolean;
  89619. /**
  89620. * Is this camera ready to be used/rendered
  89621. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89622. * @return true if the camera is ready
  89623. */
  89624. isReady(completeCheck?: boolean): boolean;
  89625. /** @hidden */
  89626. _initCache(): void;
  89627. /** @hidden */
  89628. _updateCache(ignoreParentClass?: boolean): void;
  89629. /** @hidden */
  89630. _isSynchronized(): boolean;
  89631. /** @hidden */
  89632. _isSynchronizedViewMatrix(): boolean;
  89633. /** @hidden */
  89634. _isSynchronizedProjectionMatrix(): boolean;
  89635. /**
  89636. * Attach the input controls to a specific dom element to get the input from.
  89637. * @param element Defines the element the controls should be listened from
  89638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89639. */
  89640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89641. /**
  89642. * Detach the current controls from the specified dom element.
  89643. * @param element Defines the element to stop listening the inputs from
  89644. */
  89645. detachControl(element: HTMLElement): void;
  89646. /**
  89647. * Update the camera state according to the different inputs gathered during the frame.
  89648. */
  89649. update(): void;
  89650. /** @hidden */
  89651. _checkInputs(): void;
  89652. /** @hidden */
  89653. readonly rigCameras: Camera[];
  89654. /**
  89655. * Gets the post process used by the rig cameras
  89656. */
  89657. readonly rigPostProcess: Nullable<PostProcess>;
  89658. /**
  89659. * Internal, gets the first post proces.
  89660. * @returns the first post process to be run on this camera.
  89661. */
  89662. _getFirstPostProcess(): Nullable<PostProcess>;
  89663. private _cascadePostProcessesToRigCams;
  89664. /**
  89665. * Attach a post process to the camera.
  89666. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89667. * @param postProcess The post process to attach to the camera
  89668. * @param insertAt The position of the post process in case several of them are in use in the scene
  89669. * @returns the position the post process has been inserted at
  89670. */
  89671. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89672. /**
  89673. * Detach a post process to the camera.
  89674. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89675. * @param postProcess The post process to detach from the camera
  89676. */
  89677. detachPostProcess(postProcess: PostProcess): void;
  89678. /**
  89679. * Gets the current world matrix of the camera
  89680. */
  89681. getWorldMatrix(): Matrix;
  89682. /** @hidden */
  89683. _getViewMatrix(): Matrix;
  89684. /**
  89685. * Gets the current view matrix of the camera.
  89686. * @param force forces the camera to recompute the matrix without looking at the cached state
  89687. * @returns the view matrix
  89688. */
  89689. getViewMatrix(force?: boolean): Matrix;
  89690. /**
  89691. * Freeze the projection matrix.
  89692. * It will prevent the cache check of the camera projection compute and can speed up perf
  89693. * if no parameter of the camera are meant to change
  89694. * @param projection Defines manually a projection if necessary
  89695. */
  89696. freezeProjectionMatrix(projection?: Matrix): void;
  89697. /**
  89698. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89699. */
  89700. unfreezeProjectionMatrix(): void;
  89701. /**
  89702. * Gets the current projection matrix of the camera.
  89703. * @param force forces the camera to recompute the matrix without looking at the cached state
  89704. * @returns the projection matrix
  89705. */
  89706. getProjectionMatrix(force?: boolean): Matrix;
  89707. /**
  89708. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89709. * @returns a Matrix
  89710. */
  89711. getTransformationMatrix(): Matrix;
  89712. private _updateFrustumPlanes;
  89713. /**
  89714. * Checks if a cullable object (mesh...) is in the camera frustum
  89715. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89716. * @param target The object to check
  89717. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  89718. * @returns true if the object is in frustum otherwise false
  89719. */
  89720. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  89721. /**
  89722. * Checks if a cullable object (mesh...) is in the camera frustum
  89723. * Unlike isInFrustum this cheks the full bounding box
  89724. * @param target The object to check
  89725. * @returns true if the object is in frustum otherwise false
  89726. */
  89727. isCompletelyInFrustum(target: ICullable): boolean;
  89728. /**
  89729. * Gets a ray in the forward direction from the camera.
  89730. * @param length Defines the length of the ray to create
  89731. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89732. * @param origin Defines the start point of the ray which defaults to the camera position
  89733. * @returns the forward ray
  89734. */
  89735. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89736. /**
  89737. * Releases resources associated with this node.
  89738. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89739. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89740. */
  89741. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89742. /** @hidden */
  89743. _isLeftCamera: boolean;
  89744. /**
  89745. * Gets the left camera of a rig setup in case of Rigged Camera
  89746. */
  89747. readonly isLeftCamera: boolean;
  89748. /** @hidden */
  89749. _isRightCamera: boolean;
  89750. /**
  89751. * Gets the right camera of a rig setup in case of Rigged Camera
  89752. */
  89753. readonly isRightCamera: boolean;
  89754. /**
  89755. * Gets the left camera of a rig setup in case of Rigged Camera
  89756. */
  89757. readonly leftCamera: Nullable<FreeCamera>;
  89758. /**
  89759. * Gets the right camera of a rig setup in case of Rigged Camera
  89760. */
  89761. readonly rightCamera: Nullable<FreeCamera>;
  89762. /**
  89763. * Gets the left camera target of a rig setup in case of Rigged Camera
  89764. * @returns the target position
  89765. */
  89766. getLeftTarget(): Nullable<Vector3>;
  89767. /**
  89768. * Gets the right camera target of a rig setup in case of Rigged Camera
  89769. * @returns the target position
  89770. */
  89771. getRightTarget(): Nullable<Vector3>;
  89772. /**
  89773. * @hidden
  89774. */
  89775. setCameraRigMode(mode: number, rigParams: any): void;
  89776. /** @hidden */
  89777. static _setStereoscopicRigMode(camera: Camera): void;
  89778. /** @hidden */
  89779. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89780. /** @hidden */
  89781. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89782. /** @hidden */
  89783. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89784. /** @hidden */
  89785. _getVRProjectionMatrix(): Matrix;
  89786. protected _updateCameraRotationMatrix(): void;
  89787. protected _updateWebVRCameraRotationMatrix(): void;
  89788. /**
  89789. * This function MUST be overwritten by the different WebVR cameras available.
  89790. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89791. * @hidden
  89792. */
  89793. _getWebVRProjectionMatrix(): Matrix;
  89794. /**
  89795. * This function MUST be overwritten by the different WebVR cameras available.
  89796. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89797. * @hidden
  89798. */
  89799. _getWebVRViewMatrix(): Matrix;
  89800. /** @hidden */
  89801. setCameraRigParameter(name: string, value: any): void;
  89802. /**
  89803. * needs to be overridden by children so sub has required properties to be copied
  89804. * @hidden
  89805. */
  89806. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89807. /**
  89808. * May need to be overridden by children
  89809. * @hidden
  89810. */
  89811. _updateRigCameras(): void;
  89812. /** @hidden */
  89813. _setupInputs(): void;
  89814. /**
  89815. * Serialiaze the camera setup to a json represention
  89816. * @returns the JSON representation
  89817. */
  89818. serialize(): any;
  89819. /**
  89820. * Clones the current camera.
  89821. * @param name The cloned camera name
  89822. * @returns the cloned camera
  89823. */
  89824. clone(name: string): Camera;
  89825. /**
  89826. * Gets the direction of the camera relative to a given local axis.
  89827. * @param localAxis Defines the reference axis to provide a relative direction.
  89828. * @return the direction
  89829. */
  89830. getDirection(localAxis: Vector3): Vector3;
  89831. /**
  89832. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89833. * @param localAxis Defines the reference axis to provide a relative direction.
  89834. * @param result Defines the vector to store the result in
  89835. */
  89836. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89837. /**
  89838. * Gets a camera constructor for a given camera type
  89839. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89840. * @param name The name of the camera the result will be able to instantiate
  89841. * @param scene The scene the result will construct the camera in
  89842. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89843. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89844. * @returns a factory method to construc the camera
  89845. */
  89846. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89847. /**
  89848. * Compute the world matrix of the camera.
  89849. * @returns the camera workd matrix
  89850. */
  89851. computeWorldMatrix(): Matrix;
  89852. /**
  89853. * Parse a JSON and creates the camera from the parsed information
  89854. * @param parsedCamera The JSON to parse
  89855. * @param scene The scene to instantiate the camera in
  89856. * @returns the newly constructed camera
  89857. */
  89858. static Parse(parsedCamera: any, scene: Scene): Camera;
  89859. }
  89860. }
  89861. declare module BABYLON {
  89862. /**
  89863. * Class containing static functions to help procedurally build meshes
  89864. */
  89865. export class DiscBuilder {
  89866. /**
  89867. * Creates a plane polygonal mesh. By default, this is a disc
  89868. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89869. * * 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
  89870. * * 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
  89871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89874. * @param name defines the name of the mesh
  89875. * @param options defines the options used to create the mesh
  89876. * @param scene defines the hosting scene
  89877. * @returns the plane polygonal mesh
  89878. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89879. */
  89880. static CreateDisc(name: string, options: {
  89881. radius?: number;
  89882. tessellation?: number;
  89883. arc?: number;
  89884. updatable?: boolean;
  89885. sideOrientation?: number;
  89886. frontUVs?: Vector4;
  89887. backUVs?: Vector4;
  89888. }, scene?: Nullable<Scene>): Mesh;
  89889. }
  89890. }
  89891. declare module BABYLON {
  89892. /**
  89893. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  89894. *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.
  89895. * The SPS is also a particle system. It provides some methods to manage the particles.
  89896. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  89897. *
  89898. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  89899. */
  89900. export class SolidParticleSystem implements IDisposable {
  89901. /**
  89902. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  89903. * Example : var p = SPS.particles[i];
  89904. */
  89905. particles: SolidParticle[];
  89906. /**
  89907. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  89908. */
  89909. nbParticles: number;
  89910. /**
  89911. * If the particles must ever face the camera (default false). Useful for planar particles.
  89912. */
  89913. billboard: boolean;
  89914. /**
  89915. * Recompute normals when adding a shape
  89916. */
  89917. recomputeNormals: boolean;
  89918. /**
  89919. * This a counter ofr your own usage. It's not set by any SPS functions.
  89920. */
  89921. counter: number;
  89922. /**
  89923. * The SPS name. This name is also given to the underlying mesh.
  89924. */
  89925. name: string;
  89926. /**
  89927. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  89928. */
  89929. mesh: Mesh;
  89930. /**
  89931. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  89932. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  89933. */
  89934. vars: any;
  89935. /**
  89936. * This array is populated when the SPS is set as 'pickable'.
  89937. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  89938. * Each element of this array is an object `{idx: int, faceId: int}`.
  89939. * `idx` is the picked particle index in the `SPS.particles` array
  89940. * `faceId` is the picked face index counted within this particle.
  89941. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  89942. */
  89943. pickedParticles: {
  89944. idx: number;
  89945. faceId: number;
  89946. }[];
  89947. /**
  89948. * This array is populated when `enableDepthSort` is set to true.
  89949. * Each element of this array is an instance of the class DepthSortedParticle.
  89950. */
  89951. depthSortedParticles: DepthSortedParticle[];
  89952. /**
  89953. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  89954. * @hidden
  89955. */
  89956. _bSphereOnly: boolean;
  89957. /**
  89958. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  89959. * @hidden
  89960. */
  89961. _bSphereRadiusFactor: number;
  89962. private _scene;
  89963. private _positions;
  89964. private _indices;
  89965. private _normals;
  89966. private _colors;
  89967. private _uvs;
  89968. private _indices32;
  89969. private _positions32;
  89970. private _normals32;
  89971. private _fixedNormal32;
  89972. private _colors32;
  89973. private _uvs32;
  89974. private _index;
  89975. private _updatable;
  89976. private _pickable;
  89977. private _isVisibilityBoxLocked;
  89978. private _alwaysVisible;
  89979. private _depthSort;
  89980. private _shapeCounter;
  89981. private _copy;
  89982. private _color;
  89983. private _computeParticleColor;
  89984. private _computeParticleTexture;
  89985. private _computeParticleRotation;
  89986. private _computeParticleVertex;
  89987. private _computeBoundingBox;
  89988. private _depthSortParticles;
  89989. private _camera;
  89990. private _mustUnrotateFixedNormals;
  89991. private _particlesIntersect;
  89992. private _needs32Bits;
  89993. /**
  89994. * Creates a SPS (Solid Particle System) object.
  89995. * @param name (String) is the SPS name, this will be the underlying mesh name.
  89996. * @param scene (Scene) is the scene in which the SPS is added.
  89997. * @param options defines the options of the sps e.g.
  89998. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  89999. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90000. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90001. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90002. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90003. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90004. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90005. */
  90006. constructor(name: string, scene: Scene, options?: {
  90007. updatable?: boolean;
  90008. isPickable?: boolean;
  90009. enableDepthSort?: boolean;
  90010. particleIntersection?: boolean;
  90011. boundingSphereOnly?: boolean;
  90012. bSphereRadiusFactor?: number;
  90013. });
  90014. /**
  90015. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90016. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90017. * @returns the created mesh
  90018. */
  90019. buildMesh(): Mesh;
  90020. /**
  90021. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  90022. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  90023. * Thus the particles generated from `digest()` have their property `position` set yet.
  90024. * @param mesh ( Mesh ) is the mesh to be digested
  90025. * @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
  90026. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  90027. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  90028. * @returns the current SPS
  90029. */
  90030. digest(mesh: Mesh, options?: {
  90031. facetNb?: number;
  90032. number?: number;
  90033. delta?: number;
  90034. }): SolidParticleSystem;
  90035. private _unrotateFixedNormals;
  90036. private _resetCopy;
  90037. private _meshBuilder;
  90038. private _posToShape;
  90039. private _uvsToShapeUV;
  90040. private _addParticle;
  90041. /**
  90042. * Adds some particles to the SPS from the model shape. Returns the shape id.
  90043. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  90044. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  90045. * @param nb (positive integer) the number of particles to be created from this model
  90046. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  90047. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  90048. * @returns the number of shapes in the system
  90049. */
  90050. addShape(mesh: Mesh, nb: number, options?: {
  90051. positionFunction?: any;
  90052. vertexFunction?: any;
  90053. }): number;
  90054. private _rebuildParticle;
  90055. /**
  90056. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  90057. * @returns the SPS.
  90058. */
  90059. rebuildMesh(): SolidParticleSystem;
  90060. /**
  90061. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  90062. * This method calls `updateParticle()` for each particle of the SPS.
  90063. * For an animated SPS, it is usually called within the render loop.
  90064. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  90065. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  90066. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  90067. * @returns the SPS.
  90068. */
  90069. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  90070. /**
  90071. * Disposes the SPS.
  90072. */
  90073. dispose(): void;
  90074. /**
  90075. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  90076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90077. * @returns the SPS.
  90078. */
  90079. refreshVisibleSize(): SolidParticleSystem;
  90080. /**
  90081. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  90082. * @param size the size (float) of the visibility box
  90083. * note : this doesn't lock the SPS mesh bounding box.
  90084. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90085. */
  90086. setVisibilityBox(size: number): void;
  90087. /**
  90088. * Gets whether the SPS as always visible or not
  90089. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90090. */
  90091. /**
  90092. * Sets the SPS as always visible or not
  90093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90094. */
  90095. isAlwaysVisible: boolean;
  90096. /**
  90097. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90098. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90099. */
  90100. /**
  90101. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90102. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90103. */
  90104. isVisibilityBoxLocked: boolean;
  90105. /**
  90106. * Tells to `setParticles()` to compute the particle rotations or not.
  90107. * Default value : true. The SPS is faster when it's set to false.
  90108. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90109. */
  90110. /**
  90111. * Gets if `setParticles()` computes the particle rotations or not.
  90112. * Default value : true. The SPS is faster when it's set to false.
  90113. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90114. */
  90115. computeParticleRotation: boolean;
  90116. /**
  90117. * Tells to `setParticles()` to compute the particle colors or not.
  90118. * Default value : true. The SPS is faster when it's set to false.
  90119. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90120. */
  90121. /**
  90122. * Gets if `setParticles()` computes the particle colors or not.
  90123. * Default value : true. The SPS is faster when it's set to false.
  90124. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90125. */
  90126. computeParticleColor: boolean;
  90127. /**
  90128. * Gets if `setParticles()` computes the particle textures or not.
  90129. * Default value : true. The SPS is faster when it's set to false.
  90130. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  90131. */
  90132. computeParticleTexture: boolean;
  90133. /**
  90134. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  90135. * Default value : false. The SPS is faster when it's set to false.
  90136. * Note : the particle custom vertex positions aren't stored values.
  90137. */
  90138. /**
  90139. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  90140. * Default value : false. The SPS is faster when it's set to false.
  90141. * Note : the particle custom vertex positions aren't stored values.
  90142. */
  90143. computeParticleVertex: boolean;
  90144. /**
  90145. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  90146. */
  90147. /**
  90148. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  90149. */
  90150. computeBoundingBox: boolean;
  90151. /**
  90152. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  90153. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90154. * Default : `true`
  90155. */
  90156. /**
  90157. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  90158. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90159. * Default : `true`
  90160. */
  90161. depthSortParticles: boolean;
  90162. /**
  90163. * This function does nothing. It may be overwritten to set all the particle first values.
  90164. * The SPS doesn't call this function, you may have to call it by your own.
  90165. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90166. */
  90167. initParticles(): void;
  90168. /**
  90169. * This function does nothing. It may be overwritten to recycle a particle.
  90170. * The SPS doesn't call this function, you may have to call it by your own.
  90171. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90172. * @param particle The particle to recycle
  90173. * @returns the recycled particle
  90174. */
  90175. recycleParticle(particle: SolidParticle): SolidParticle;
  90176. /**
  90177. * Updates a particle : this function should be overwritten by the user.
  90178. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  90179. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90180. * @example : just set a particle position or velocity and recycle conditions
  90181. * @param particle The particle to update
  90182. * @returns the updated particle
  90183. */
  90184. updateParticle(particle: SolidParticle): SolidParticle;
  90185. /**
  90186. * Updates a vertex of a particle : it can be overwritten by the user.
  90187. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  90188. * @param particle the current particle
  90189. * @param vertex the current index of the current particle
  90190. * @param pt the index of the current vertex in the particle shape
  90191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  90192. * @example : just set a vertex particle position
  90193. * @returns the updated vertex
  90194. */
  90195. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  90196. /**
  90197. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  90198. * This does nothing and may be overwritten by the user.
  90199. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90200. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90201. * @param update the boolean update value actually passed to setParticles()
  90202. */
  90203. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90204. /**
  90205. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  90206. * This will be passed three parameters.
  90207. * This does nothing and may be overwritten by the user.
  90208. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90209. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90210. * @param update the boolean update value actually passed to setParticles()
  90211. */
  90212. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90213. }
  90214. }
  90215. declare module BABYLON {
  90216. /**
  90217. * Represents one particle of a solid particle system.
  90218. */
  90219. export class SolidParticle {
  90220. /**
  90221. * particle global index
  90222. */
  90223. idx: number;
  90224. /**
  90225. * The color of the particle
  90226. */
  90227. color: Nullable<Color4>;
  90228. /**
  90229. * The world space position of the particle.
  90230. */
  90231. position: Vector3;
  90232. /**
  90233. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  90234. */
  90235. rotation: Vector3;
  90236. /**
  90237. * The world space rotation quaternion of the particle.
  90238. */
  90239. rotationQuaternion: Nullable<Quaternion>;
  90240. /**
  90241. * The scaling of the particle.
  90242. */
  90243. scaling: Vector3;
  90244. /**
  90245. * The uvs of the particle.
  90246. */
  90247. uvs: Vector4;
  90248. /**
  90249. * The current speed of the particle.
  90250. */
  90251. velocity: Vector3;
  90252. /**
  90253. * The pivot point in the particle local space.
  90254. */
  90255. pivot: Vector3;
  90256. /**
  90257. * Must the particle be translated from its pivot point in its local space ?
  90258. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  90259. * Default : false
  90260. */
  90261. translateFromPivot: boolean;
  90262. /**
  90263. * Is the particle active or not ?
  90264. */
  90265. alive: boolean;
  90266. /**
  90267. * Is the particle visible or not ?
  90268. */
  90269. isVisible: boolean;
  90270. /**
  90271. * Index of this particle in the global "positions" array (Internal use)
  90272. * @hidden
  90273. */
  90274. _pos: number;
  90275. /**
  90276. * @hidden Index of this particle in the global "indices" array (Internal use)
  90277. */
  90278. _ind: number;
  90279. /**
  90280. * @hidden ModelShape of this particle (Internal use)
  90281. */
  90282. _model: ModelShape;
  90283. /**
  90284. * ModelShape id of this particle
  90285. */
  90286. shapeId: number;
  90287. /**
  90288. * Index of the particle in its shape id
  90289. */
  90290. idxInShape: number;
  90291. /**
  90292. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  90293. */
  90294. _modelBoundingInfo: BoundingInfo;
  90295. /**
  90296. * @hidden Particle BoundingInfo object (Internal use)
  90297. */
  90298. _boundingInfo: BoundingInfo;
  90299. /**
  90300. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  90301. */
  90302. _sps: SolidParticleSystem;
  90303. /**
  90304. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  90305. */
  90306. _stillInvisible: boolean;
  90307. /**
  90308. * @hidden Last computed particle rotation matrix
  90309. */
  90310. _rotationMatrix: number[];
  90311. /**
  90312. * Parent particle Id, if any.
  90313. * Default null.
  90314. */
  90315. parentId: Nullable<number>;
  90316. /**
  90317. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  90318. * The possible values are :
  90319. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90320. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90321. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90322. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90323. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90324. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  90325. * */
  90326. cullingStrategy: number;
  90327. /**
  90328. * @hidden Internal global position in the SPS.
  90329. */
  90330. _globalPosition: Vector3;
  90331. /**
  90332. * Creates a Solid Particle object.
  90333. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  90334. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  90335. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  90336. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  90337. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  90338. * @param shapeId (integer) is the model shape identifier in the SPS.
  90339. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  90340. * @param sps defines the sps it is associated to
  90341. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  90342. */
  90343. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  90344. /**
  90345. * Legacy support, changed scale to scaling
  90346. */
  90347. /**
  90348. * Legacy support, changed scale to scaling
  90349. */
  90350. scale: Vector3;
  90351. /**
  90352. * Legacy support, changed quaternion to rotationQuaternion
  90353. */
  90354. /**
  90355. * Legacy support, changed quaternion to rotationQuaternion
  90356. */
  90357. quaternion: Nullable<Quaternion>;
  90358. /**
  90359. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  90360. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  90361. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  90362. * @returns true if it intersects
  90363. */
  90364. intersectsMesh(target: Mesh | SolidParticle): boolean;
  90365. /**
  90366. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  90367. * A particle is in the frustum if its bounding box intersects the frustum
  90368. * @param frustumPlanes defines the frustum to test
  90369. * @returns true if the particle is in the frustum planes
  90370. */
  90371. isInFrustum(frustumPlanes: Plane[]): boolean;
  90372. /**
  90373. * get the rotation matrix of the particle
  90374. * @hidden
  90375. */
  90376. getRotationMatrix(m: Matrix): void;
  90377. }
  90378. /**
  90379. * Represents the shape of the model used by one particle of a solid particle system.
  90380. * SPS internal tool, don't use it manually.
  90381. */
  90382. export class ModelShape {
  90383. /**
  90384. * The shape id
  90385. * @hidden
  90386. */
  90387. shapeID: number;
  90388. /**
  90389. * flat array of model positions (internal use)
  90390. * @hidden
  90391. */
  90392. _shape: Vector3[];
  90393. /**
  90394. * flat array of model UVs (internal use)
  90395. * @hidden
  90396. */
  90397. _shapeUV: number[];
  90398. /**
  90399. * length of the shape in the model indices array (internal use)
  90400. * @hidden
  90401. */
  90402. _indicesLength: number;
  90403. /**
  90404. * Custom position function (internal use)
  90405. * @hidden
  90406. */
  90407. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  90408. /**
  90409. * Custom vertex function (internal use)
  90410. * @hidden
  90411. */
  90412. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  90413. /**
  90414. * 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.
  90415. * SPS internal tool, don't use it manually.
  90416. * @hidden
  90417. */
  90418. 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>);
  90419. }
  90420. /**
  90421. * Represents a Depth Sorted Particle in the solid particle system.
  90422. */
  90423. export class DepthSortedParticle {
  90424. /**
  90425. * Index of the particle in the "indices" array
  90426. */
  90427. ind: number;
  90428. /**
  90429. * Length of the particle shape in the "indices" array
  90430. */
  90431. indicesLength: number;
  90432. /**
  90433. * Squared distance from the particle to the camera
  90434. */
  90435. sqDistance: number;
  90436. }
  90437. }
  90438. declare module BABYLON {
  90439. /**
  90440. * @hidden
  90441. */
  90442. export class _MeshCollisionData {
  90443. _checkCollisions: boolean;
  90444. _collisionMask: number;
  90445. _collisionGroup: number;
  90446. _collider: Nullable<Collider>;
  90447. _oldPositionForCollisions: Vector3;
  90448. _diffPositionForCollisions: Vector3;
  90449. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  90450. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  90451. }
  90452. }
  90453. declare module BABYLON {
  90454. /** @hidden */
  90455. class _FacetDataStorage {
  90456. facetPositions: Vector3[];
  90457. facetNormals: Vector3[];
  90458. facetPartitioning: number[][];
  90459. facetNb: number;
  90460. partitioningSubdivisions: number;
  90461. partitioningBBoxRatio: number;
  90462. facetDataEnabled: boolean;
  90463. facetParameters: any;
  90464. bbSize: Vector3;
  90465. subDiv: {
  90466. max: number;
  90467. X: number;
  90468. Y: number;
  90469. Z: number;
  90470. };
  90471. facetDepthSort: boolean;
  90472. facetDepthSortEnabled: boolean;
  90473. depthSortedIndices: IndicesArray;
  90474. depthSortedFacets: {
  90475. ind: number;
  90476. sqDistance: number;
  90477. }[];
  90478. facetDepthSortFunction: (f1: {
  90479. ind: number;
  90480. sqDistance: number;
  90481. }, f2: {
  90482. ind: number;
  90483. sqDistance: number;
  90484. }) => number;
  90485. facetDepthSortFrom: Vector3;
  90486. facetDepthSortOrigin: Vector3;
  90487. invertedMatrix: Matrix;
  90488. }
  90489. /**
  90490. * @hidden
  90491. **/
  90492. class _InternalAbstractMeshDataInfo {
  90493. _hasVertexAlpha: boolean;
  90494. _useVertexColors: boolean;
  90495. _numBoneInfluencers: number;
  90496. _applyFog: boolean;
  90497. _receiveShadows: boolean;
  90498. _facetData: _FacetDataStorage;
  90499. _visibility: number;
  90500. _skeleton: Nullable<Skeleton>;
  90501. _layerMask: number;
  90502. _computeBonesUsingShaders: boolean;
  90503. _isActive: boolean;
  90504. _onlyForInstances: boolean;
  90505. _isActiveIntermediate: boolean;
  90506. _onlyForInstancesIntermediate: boolean;
  90507. }
  90508. /**
  90509. * Class used to store all common mesh properties
  90510. */
  90511. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  90512. /** No occlusion */
  90513. static OCCLUSION_TYPE_NONE: number;
  90514. /** Occlusion set to optimisitic */
  90515. static OCCLUSION_TYPE_OPTIMISTIC: number;
  90516. /** Occlusion set to strict */
  90517. static OCCLUSION_TYPE_STRICT: number;
  90518. /** Use an accurante occlusion algorithm */
  90519. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  90520. /** Use a conservative occlusion algorithm */
  90521. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  90522. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  90523. * Test order :
  90524. * Is the bounding sphere outside the frustum ?
  90525. * If not, are the bounding box vertices outside the frustum ?
  90526. * It not, then the cullable object is in the frustum.
  90527. */
  90528. static readonly CULLINGSTRATEGY_STANDARD: number;
  90529. /** Culling strategy : Bounding Sphere Only.
  90530. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  90531. * It's also less accurate than the standard because some not visible objects can still be selected.
  90532. * Test : is the bounding sphere outside the frustum ?
  90533. * If not, then the cullable object is in the frustum.
  90534. */
  90535. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  90536. /** Culling strategy : Optimistic Inclusion.
  90537. * This in an inclusion test first, then the standard exclusion test.
  90538. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  90539. * 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.
  90540. * Anyway, it's as accurate as the standard strategy.
  90541. * Test :
  90542. * Is the cullable object bounding sphere center in the frustum ?
  90543. * If not, apply the default culling strategy.
  90544. */
  90545. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  90546. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  90547. * This in an inclusion test first, then the bounding sphere only exclusion test.
  90548. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  90549. * 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.
  90550. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  90551. * Test :
  90552. * Is the cullable object bounding sphere center in the frustum ?
  90553. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  90554. */
  90555. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  90556. /**
  90557. * No billboard
  90558. */
  90559. static readonly BILLBOARDMODE_NONE: number;
  90560. /** Billboard on X axis */
  90561. static readonly BILLBOARDMODE_X: number;
  90562. /** Billboard on Y axis */
  90563. static readonly BILLBOARDMODE_Y: number;
  90564. /** Billboard on Z axis */
  90565. static readonly BILLBOARDMODE_Z: number;
  90566. /** Billboard on all axes */
  90567. static readonly BILLBOARDMODE_ALL: number;
  90568. /** Billboard on using position instead of orientation */
  90569. static readonly BILLBOARDMODE_USE_POSITION: number;
  90570. /** @hidden */
  90571. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  90572. /**
  90573. * The culling strategy to use to check whether the mesh must be rendered or not.
  90574. * This value can be changed at any time and will be used on the next render mesh selection.
  90575. * The possible values are :
  90576. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90577. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90578. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90579. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90580. * Please read each static variable documentation to get details about the culling process.
  90581. * */
  90582. cullingStrategy: number;
  90583. /**
  90584. * Gets the number of facets in the mesh
  90585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90586. */
  90587. readonly facetNb: number;
  90588. /**
  90589. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  90590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90591. */
  90592. partitioningSubdivisions: number;
  90593. /**
  90594. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  90595. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  90596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90597. */
  90598. partitioningBBoxRatio: number;
  90599. /**
  90600. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  90601. * Works only for updatable meshes.
  90602. * Doesn't work with multi-materials
  90603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90604. */
  90605. mustDepthSortFacets: boolean;
  90606. /**
  90607. * The location (Vector3) where the facet depth sort must be computed from.
  90608. * By default, the active camera position.
  90609. * Used only when facet depth sort is enabled
  90610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90611. */
  90612. facetDepthSortFrom: Vector3;
  90613. /**
  90614. * gets a boolean indicating if facetData is enabled
  90615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90616. */
  90617. readonly isFacetDataEnabled: boolean;
  90618. /** @hidden */
  90619. _updateNonUniformScalingState(value: boolean): boolean;
  90620. /**
  90621. * An event triggered when this mesh collides with another one
  90622. */
  90623. onCollideObservable: Observable<AbstractMesh>;
  90624. /** Set a function to call when this mesh collides with another one */
  90625. onCollide: () => void;
  90626. /**
  90627. * An event triggered when the collision's position changes
  90628. */
  90629. onCollisionPositionChangeObservable: Observable<Vector3>;
  90630. /** Set a function to call when the collision's position changes */
  90631. onCollisionPositionChange: () => void;
  90632. /**
  90633. * An event triggered when material is changed
  90634. */
  90635. onMaterialChangedObservable: Observable<AbstractMesh>;
  90636. /**
  90637. * Gets or sets the orientation for POV movement & rotation
  90638. */
  90639. definedFacingForward: boolean;
  90640. /** @hidden */
  90641. _occlusionQuery: Nullable<WebGLQuery>;
  90642. /** @hidden */
  90643. _renderingGroup: Nullable<RenderingGroup>;
  90644. /**
  90645. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90646. */
  90647. /**
  90648. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90649. */
  90650. visibility: number;
  90651. /** Gets or sets the alpha index used to sort transparent meshes
  90652. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  90653. */
  90654. alphaIndex: number;
  90655. /**
  90656. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  90657. */
  90658. isVisible: boolean;
  90659. /**
  90660. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90661. */
  90662. isPickable: boolean;
  90663. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  90664. showSubMeshesBoundingBox: boolean;
  90665. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  90666. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  90667. */
  90668. isBlocker: boolean;
  90669. /**
  90670. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  90671. */
  90672. enablePointerMoveEvents: boolean;
  90673. /**
  90674. * Specifies the rendering group id for this mesh (0 by default)
  90675. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90676. */
  90677. renderingGroupId: number;
  90678. private _material;
  90679. /** Gets or sets current material */
  90680. material: Nullable<Material>;
  90681. /**
  90682. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  90683. * @see http://doc.babylonjs.com/babylon101/shadows
  90684. */
  90685. receiveShadows: boolean;
  90686. /** Defines color to use when rendering outline */
  90687. outlineColor: Color3;
  90688. /** Define width to use when rendering outline */
  90689. outlineWidth: number;
  90690. /** Defines color to use when rendering overlay */
  90691. overlayColor: Color3;
  90692. /** Defines alpha to use when rendering overlay */
  90693. overlayAlpha: number;
  90694. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  90695. hasVertexAlpha: boolean;
  90696. /** 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) */
  90697. useVertexColors: boolean;
  90698. /**
  90699. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  90700. */
  90701. computeBonesUsingShaders: boolean;
  90702. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  90703. numBoneInfluencers: number;
  90704. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  90705. applyFog: boolean;
  90706. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  90707. useOctreeForRenderingSelection: boolean;
  90708. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  90709. useOctreeForPicking: boolean;
  90710. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  90711. useOctreeForCollisions: boolean;
  90712. /**
  90713. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  90714. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  90715. */
  90716. layerMask: number;
  90717. /**
  90718. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  90719. */
  90720. alwaysSelectAsActiveMesh: boolean;
  90721. /**
  90722. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  90723. */
  90724. doNotSyncBoundingInfo: boolean;
  90725. /**
  90726. * Gets or sets the current action manager
  90727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90728. */
  90729. actionManager: Nullable<AbstractActionManager>;
  90730. private _meshCollisionData;
  90731. /**
  90732. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  90733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90734. */
  90735. ellipsoid: Vector3;
  90736. /**
  90737. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  90738. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90739. */
  90740. ellipsoidOffset: Vector3;
  90741. /**
  90742. * Gets or sets a collision mask used to mask collisions (default is -1).
  90743. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90744. */
  90745. collisionMask: number;
  90746. /**
  90747. * Gets or sets the current collision group mask (-1 by default).
  90748. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90749. */
  90750. collisionGroup: number;
  90751. /**
  90752. * Defines edge width used when edgesRenderer is enabled
  90753. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90754. */
  90755. edgesWidth: number;
  90756. /**
  90757. * Defines edge color used when edgesRenderer is enabled
  90758. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90759. */
  90760. edgesColor: Color4;
  90761. /** @hidden */
  90762. _edgesRenderer: Nullable<IEdgesRenderer>;
  90763. /** @hidden */
  90764. _masterMesh: Nullable<AbstractMesh>;
  90765. /** @hidden */
  90766. _boundingInfo: Nullable<BoundingInfo>;
  90767. /** @hidden */
  90768. _renderId: number;
  90769. /**
  90770. * Gets or sets the list of subMeshes
  90771. * @see http://doc.babylonjs.com/how_to/multi_materials
  90772. */
  90773. subMeshes: SubMesh[];
  90774. /** @hidden */
  90775. _intersectionsInProgress: AbstractMesh[];
  90776. /** @hidden */
  90777. _unIndexed: boolean;
  90778. /** @hidden */
  90779. _lightSources: Light[];
  90780. /** Gets the list of lights affecting that mesh */
  90781. readonly lightSources: Light[];
  90782. /** @hidden */
  90783. readonly _positions: Nullable<Vector3[]>;
  90784. /** @hidden */
  90785. _waitingData: {
  90786. lods: Nullable<any>;
  90787. actions: Nullable<any>;
  90788. freezeWorldMatrix: Nullable<boolean>;
  90789. };
  90790. /** @hidden */
  90791. _bonesTransformMatrices: Nullable<Float32Array>;
  90792. /** @hidden */
  90793. _transformMatrixTexture: Nullable<RawTexture>;
  90794. /**
  90795. * Gets or sets a skeleton to apply skining transformations
  90796. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90797. */
  90798. skeleton: Nullable<Skeleton>;
  90799. /**
  90800. * An event triggered when the mesh is rebuilt.
  90801. */
  90802. onRebuildObservable: Observable<AbstractMesh>;
  90803. /**
  90804. * Creates a new AbstractMesh
  90805. * @param name defines the name of the mesh
  90806. * @param scene defines the hosting scene
  90807. */
  90808. constructor(name: string, scene?: Nullable<Scene>);
  90809. /**
  90810. * Returns the string "AbstractMesh"
  90811. * @returns "AbstractMesh"
  90812. */
  90813. getClassName(): string;
  90814. /**
  90815. * Gets a string representation of the current mesh
  90816. * @param fullDetails defines a boolean indicating if full details must be included
  90817. * @returns a string representation of the current mesh
  90818. */
  90819. toString(fullDetails?: boolean): string;
  90820. /**
  90821. * @hidden
  90822. */
  90823. protected _getEffectiveParent(): Nullable<Node>;
  90824. /** @hidden */
  90825. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90826. /** @hidden */
  90827. _rebuild(): void;
  90828. /** @hidden */
  90829. _resyncLightSources(): void;
  90830. /** @hidden */
  90831. _resyncLighSource(light: Light): void;
  90832. /** @hidden */
  90833. _unBindEffect(): void;
  90834. /** @hidden */
  90835. _removeLightSource(light: Light, dispose: boolean): void;
  90836. private _markSubMeshesAsDirty;
  90837. /** @hidden */
  90838. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  90839. /** @hidden */
  90840. _markSubMeshesAsAttributesDirty(): void;
  90841. /** @hidden */
  90842. _markSubMeshesAsMiscDirty(): void;
  90843. /**
  90844. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90845. */
  90846. scaling: Vector3;
  90847. /**
  90848. * Returns true if the mesh is blocked. Implemented by child classes
  90849. */
  90850. readonly isBlocked: boolean;
  90851. /**
  90852. * Returns the mesh itself by default. Implemented by child classes
  90853. * @param camera defines the camera to use to pick the right LOD level
  90854. * @returns the currentAbstractMesh
  90855. */
  90856. getLOD(camera: Camera): Nullable<AbstractMesh>;
  90857. /**
  90858. * Returns 0 by default. Implemented by child classes
  90859. * @returns an integer
  90860. */
  90861. getTotalVertices(): number;
  90862. /**
  90863. * Returns a positive integer : the total number of indices in this mesh geometry.
  90864. * @returns the numner of indices or zero if the mesh has no geometry.
  90865. */
  90866. getTotalIndices(): number;
  90867. /**
  90868. * Returns null by default. Implemented by child classes
  90869. * @returns null
  90870. */
  90871. getIndices(): Nullable<IndicesArray>;
  90872. /**
  90873. * Returns the array of the requested vertex data kind. Implemented by child classes
  90874. * @param kind defines the vertex data kind to use
  90875. * @returns null
  90876. */
  90877. getVerticesData(kind: string): Nullable<FloatArray>;
  90878. /**
  90879. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90880. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90881. * Note that a new underlying VertexBuffer object is created each call.
  90882. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90883. * @param kind defines vertex data kind:
  90884. * * VertexBuffer.PositionKind
  90885. * * VertexBuffer.UVKind
  90886. * * VertexBuffer.UV2Kind
  90887. * * VertexBuffer.UV3Kind
  90888. * * VertexBuffer.UV4Kind
  90889. * * VertexBuffer.UV5Kind
  90890. * * VertexBuffer.UV6Kind
  90891. * * VertexBuffer.ColorKind
  90892. * * VertexBuffer.MatricesIndicesKind
  90893. * * VertexBuffer.MatricesIndicesExtraKind
  90894. * * VertexBuffer.MatricesWeightsKind
  90895. * * VertexBuffer.MatricesWeightsExtraKind
  90896. * @param data defines the data source
  90897. * @param updatable defines if the data must be flagged as updatable (or static)
  90898. * @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
  90899. * @returns the current mesh
  90900. */
  90901. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90902. /**
  90903. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90904. * If the mesh has no geometry, it is simply returned as it is.
  90905. * @param kind defines vertex data kind:
  90906. * * VertexBuffer.PositionKind
  90907. * * VertexBuffer.UVKind
  90908. * * VertexBuffer.UV2Kind
  90909. * * VertexBuffer.UV3Kind
  90910. * * VertexBuffer.UV4Kind
  90911. * * VertexBuffer.UV5Kind
  90912. * * VertexBuffer.UV6Kind
  90913. * * VertexBuffer.ColorKind
  90914. * * VertexBuffer.MatricesIndicesKind
  90915. * * VertexBuffer.MatricesIndicesExtraKind
  90916. * * VertexBuffer.MatricesWeightsKind
  90917. * * VertexBuffer.MatricesWeightsExtraKind
  90918. * @param data defines the data source
  90919. * @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
  90920. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  90921. * @returns the current mesh
  90922. */
  90923. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90924. /**
  90925. * Sets the mesh indices,
  90926. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90927. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  90928. * @param totalVertices Defines the total number of vertices
  90929. * @returns the current mesh
  90930. */
  90931. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  90932. /**
  90933. * Gets a boolean indicating if specific vertex data is present
  90934. * @param kind defines the vertex data kind to use
  90935. * @returns true is data kind is present
  90936. */
  90937. isVerticesDataPresent(kind: string): boolean;
  90938. /**
  90939. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  90940. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  90941. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  90942. * @returns a BoundingInfo
  90943. */
  90944. getBoundingInfo(): BoundingInfo;
  90945. /**
  90946. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90947. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90948. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90949. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90950. * @returns the current mesh
  90951. */
  90952. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  90953. /**
  90954. * Overwrite the current bounding info
  90955. * @param boundingInfo defines the new bounding info
  90956. * @returns the current mesh
  90957. */
  90958. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  90959. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  90960. readonly useBones: boolean;
  90961. /** @hidden */
  90962. _preActivate(): void;
  90963. /** @hidden */
  90964. _preActivateForIntermediateRendering(renderId: number): void;
  90965. /** @hidden */
  90966. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90967. /** @hidden */
  90968. _postActivate(): void;
  90969. /** @hidden */
  90970. _freeze(): void;
  90971. /** @hidden */
  90972. _unFreeze(): void;
  90973. /**
  90974. * Gets the current world matrix
  90975. * @returns a Matrix
  90976. */
  90977. getWorldMatrix(): Matrix;
  90978. /** @hidden */
  90979. _getWorldMatrixDeterminant(): number;
  90980. /**
  90981. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  90982. */
  90983. readonly isAnInstance: boolean;
  90984. /**
  90985. * Gets a boolean indicating if this mesh has instances
  90986. */
  90987. readonly hasInstances: boolean;
  90988. /**
  90989. * Perform relative position change from the point of view of behind the front of the mesh.
  90990. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90991. * Supports definition of mesh facing forward or backward
  90992. * @param amountRight defines the distance on the right axis
  90993. * @param amountUp defines the distance on the up axis
  90994. * @param amountForward defines the distance on the forward axis
  90995. * @returns the current mesh
  90996. */
  90997. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  90998. /**
  90999. * Calculate relative position change from the point of view of behind the front of the mesh.
  91000. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91001. * Supports definition of mesh facing forward or backward
  91002. * @param amountRight defines the distance on the right axis
  91003. * @param amountUp defines the distance on the up axis
  91004. * @param amountForward defines the distance on the forward axis
  91005. * @returns the new displacement vector
  91006. */
  91007. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91008. /**
  91009. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91010. * Supports definition of mesh facing forward or backward
  91011. * @param flipBack defines the flip
  91012. * @param twirlClockwise defines the twirl
  91013. * @param tiltRight defines the tilt
  91014. * @returns the current mesh
  91015. */
  91016. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91017. /**
  91018. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91019. * Supports definition of mesh facing forward or backward.
  91020. * @param flipBack defines the flip
  91021. * @param twirlClockwise defines the twirl
  91022. * @param tiltRight defines the tilt
  91023. * @returns the new rotation vector
  91024. */
  91025. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  91026. /**
  91027. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91028. * This means the mesh underlying bounding box and sphere are recomputed.
  91029. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91030. * @returns the current mesh
  91031. */
  91032. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  91033. /** @hidden */
  91034. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  91035. /** @hidden */
  91036. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  91037. /** @hidden */
  91038. _updateBoundingInfo(): AbstractMesh;
  91039. /** @hidden */
  91040. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  91041. /** @hidden */
  91042. protected _afterComputeWorldMatrix(): void;
  91043. /** @hidden */
  91044. readonly _effectiveMesh: AbstractMesh;
  91045. /**
  91046. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91047. * A mesh is in the frustum if its bounding box intersects the frustum
  91048. * @param frustumPlanes defines the frustum to test
  91049. * @returns true if the mesh is in the frustum planes
  91050. */
  91051. isInFrustum(frustumPlanes: Plane[]): boolean;
  91052. /**
  91053. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  91054. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  91055. * @param frustumPlanes defines the frustum to test
  91056. * @returns true if the mesh is completely in the frustum planes
  91057. */
  91058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91059. /**
  91060. * True if the mesh intersects another mesh or a SolidParticle object
  91061. * @param mesh defines a target mesh or SolidParticle to test
  91062. * @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)
  91063. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  91064. * @returns true if there is an intersection
  91065. */
  91066. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  91067. /**
  91068. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  91069. * @param point defines the point to test
  91070. * @returns true if there is an intersection
  91071. */
  91072. intersectsPoint(point: Vector3): boolean;
  91073. /**
  91074. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  91075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91076. */
  91077. checkCollisions: boolean;
  91078. /**
  91079. * Gets Collider object used to compute collisions (not physics)
  91080. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91081. */
  91082. readonly collider: Nullable<Collider>;
  91083. /**
  91084. * Move the mesh using collision engine
  91085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91086. * @param displacement defines the requested displacement vector
  91087. * @returns the current mesh
  91088. */
  91089. moveWithCollisions(displacement: Vector3): AbstractMesh;
  91090. private _onCollisionPositionChange;
  91091. /** @hidden */
  91092. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  91093. /** @hidden */
  91094. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  91095. /** @hidden */
  91096. _checkCollision(collider: Collider): AbstractMesh;
  91097. /** @hidden */
  91098. _generatePointsArray(): boolean;
  91099. /**
  91100. * Checks if the passed Ray intersects with the mesh
  91101. * @param ray defines the ray to use
  91102. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  91103. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91104. * @returns the picking info
  91105. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  91106. */
  91107. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  91108. /**
  91109. * Clones the current mesh
  91110. * @param name defines the mesh name
  91111. * @param newParent defines the new mesh parent
  91112. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  91113. * @returns the new mesh
  91114. */
  91115. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91116. /**
  91117. * Disposes all the submeshes of the current meshnp
  91118. * @returns the current mesh
  91119. */
  91120. releaseSubMeshes(): AbstractMesh;
  91121. /**
  91122. * Releases resources associated with this abstract mesh.
  91123. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91124. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91125. */
  91126. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91127. /**
  91128. * Adds the passed mesh as a child to the current mesh
  91129. * @param mesh defines the child mesh
  91130. * @returns the current mesh
  91131. */
  91132. addChild(mesh: AbstractMesh): AbstractMesh;
  91133. /**
  91134. * Removes the passed mesh from the current mesh children list
  91135. * @param mesh defines the child mesh
  91136. * @returns the current mesh
  91137. */
  91138. removeChild(mesh: AbstractMesh): AbstractMesh;
  91139. /** @hidden */
  91140. private _initFacetData;
  91141. /**
  91142. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  91143. * This method can be called within the render loop.
  91144. * 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
  91145. * @returns the current mesh
  91146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91147. */
  91148. updateFacetData(): AbstractMesh;
  91149. /**
  91150. * Returns the facetLocalNormals array.
  91151. * The normals are expressed in the mesh local spac
  91152. * @returns an array of Vector3
  91153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91154. */
  91155. getFacetLocalNormals(): Vector3[];
  91156. /**
  91157. * Returns the facetLocalPositions array.
  91158. * The facet positions are expressed in the mesh local space
  91159. * @returns an array of Vector3
  91160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91161. */
  91162. getFacetLocalPositions(): Vector3[];
  91163. /**
  91164. * Returns the facetLocalPartioning array
  91165. * @returns an array of array of numbers
  91166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91167. */
  91168. getFacetLocalPartitioning(): number[][];
  91169. /**
  91170. * Returns the i-th facet position in the world system.
  91171. * This method allocates a new Vector3 per call
  91172. * @param i defines the facet index
  91173. * @returns a new Vector3
  91174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91175. */
  91176. getFacetPosition(i: number): Vector3;
  91177. /**
  91178. * Sets the reference Vector3 with the i-th facet position in the world system
  91179. * @param i defines the facet index
  91180. * @param ref defines the target vector
  91181. * @returns the current mesh
  91182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91183. */
  91184. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  91185. /**
  91186. * Returns the i-th facet normal in the world system.
  91187. * This method allocates a new Vector3 per call
  91188. * @param i defines the facet index
  91189. * @returns a new Vector3
  91190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91191. */
  91192. getFacetNormal(i: number): Vector3;
  91193. /**
  91194. * Sets the reference Vector3 with the i-th facet normal in the world system
  91195. * @param i defines the facet index
  91196. * @param ref defines the target vector
  91197. * @returns the current mesh
  91198. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91199. */
  91200. getFacetNormalToRef(i: number, ref: Vector3): this;
  91201. /**
  91202. * 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)
  91203. * @param x defines x coordinate
  91204. * @param y defines y coordinate
  91205. * @param z defines z coordinate
  91206. * @returns the array of facet indexes
  91207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91208. */
  91209. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  91210. /**
  91211. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  91212. * @param projected sets as the (x,y,z) world projection on the facet
  91213. * @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
  91214. * @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
  91215. * @param x defines x coordinate
  91216. * @param y defines y coordinate
  91217. * @param z defines z coordinate
  91218. * @returns the face index if found (or null instead)
  91219. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91220. */
  91221. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91222. /**
  91223. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  91224. * @param projected sets as the (x,y,z) local projection on the facet
  91225. * @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
  91226. * @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
  91227. * @param x defines x coordinate
  91228. * @param y defines y coordinate
  91229. * @param z defines z coordinate
  91230. * @returns the face index if found (or null instead)
  91231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91232. */
  91233. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91234. /**
  91235. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  91236. * @returns the parameters
  91237. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91238. */
  91239. getFacetDataParameters(): any;
  91240. /**
  91241. * Disables the feature FacetData and frees the related memory
  91242. * @returns the current mesh
  91243. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91244. */
  91245. disableFacetData(): AbstractMesh;
  91246. /**
  91247. * Updates the AbstractMesh indices array
  91248. * @param indices defines the data source
  91249. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91250. * @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)
  91251. * @returns the current mesh
  91252. */
  91253. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91254. /**
  91255. * Creates new normals data for the mesh
  91256. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  91257. * @returns the current mesh
  91258. */
  91259. createNormals(updatable: boolean): AbstractMesh;
  91260. /**
  91261. * Align the mesh with a normal
  91262. * @param normal defines the normal to use
  91263. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  91264. * @returns the current mesh
  91265. */
  91266. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  91267. /** @hidden */
  91268. _checkOcclusionQuery(): boolean;
  91269. /**
  91270. * Disables the mesh edge rendering mode
  91271. * @returns the currentAbstractMesh
  91272. */
  91273. disableEdgesRendering(): AbstractMesh;
  91274. /**
  91275. * Enables the edge rendering mode on the mesh.
  91276. * This mode makes the mesh edges visible
  91277. * @param epsilon defines the maximal distance between two angles to detect a face
  91278. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91279. * @returns the currentAbstractMesh
  91280. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91281. */
  91282. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91283. }
  91284. }
  91285. declare module BABYLON {
  91286. /**
  91287. * Interface used to define ActionEvent
  91288. */
  91289. export interface IActionEvent {
  91290. /** The mesh or sprite that triggered the action */
  91291. source: any;
  91292. /** The X mouse cursor position at the time of the event */
  91293. pointerX: number;
  91294. /** The Y mouse cursor position at the time of the event */
  91295. pointerY: number;
  91296. /** The mesh that is currently pointed at (can be null) */
  91297. meshUnderPointer: Nullable<AbstractMesh>;
  91298. /** the original (browser) event that triggered the ActionEvent */
  91299. sourceEvent?: any;
  91300. /** additional data for the event */
  91301. additionalData?: any;
  91302. }
  91303. /**
  91304. * ActionEvent is the event being sent when an action is triggered.
  91305. */
  91306. export class ActionEvent implements IActionEvent {
  91307. /** The mesh or sprite that triggered the action */
  91308. source: any;
  91309. /** The X mouse cursor position at the time of the event */
  91310. pointerX: number;
  91311. /** The Y mouse cursor position at the time of the event */
  91312. pointerY: number;
  91313. /** The mesh that is currently pointed at (can be null) */
  91314. meshUnderPointer: Nullable<AbstractMesh>;
  91315. /** the original (browser) event that triggered the ActionEvent */
  91316. sourceEvent?: any;
  91317. /** additional data for the event */
  91318. additionalData?: any;
  91319. /**
  91320. * Creates a new ActionEvent
  91321. * @param source The mesh or sprite that triggered the action
  91322. * @param pointerX The X mouse cursor position at the time of the event
  91323. * @param pointerY The Y mouse cursor position at the time of the event
  91324. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  91325. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  91326. * @param additionalData additional data for the event
  91327. */
  91328. constructor(
  91329. /** The mesh or sprite that triggered the action */
  91330. source: any,
  91331. /** The X mouse cursor position at the time of the event */
  91332. pointerX: number,
  91333. /** The Y mouse cursor position at the time of the event */
  91334. pointerY: number,
  91335. /** The mesh that is currently pointed at (can be null) */
  91336. meshUnderPointer: Nullable<AbstractMesh>,
  91337. /** the original (browser) event that triggered the ActionEvent */
  91338. sourceEvent?: any,
  91339. /** additional data for the event */
  91340. additionalData?: any);
  91341. /**
  91342. * Helper function to auto-create an ActionEvent from a source mesh.
  91343. * @param source The source mesh that triggered the event
  91344. * @param evt The original (browser) event
  91345. * @param additionalData additional data for the event
  91346. * @returns the new ActionEvent
  91347. */
  91348. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  91349. /**
  91350. * Helper function to auto-create an ActionEvent from a source sprite
  91351. * @param source The source sprite that triggered the event
  91352. * @param scene Scene associated with the sprite
  91353. * @param evt The original (browser) event
  91354. * @param additionalData additional data for the event
  91355. * @returns the new ActionEvent
  91356. */
  91357. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  91358. /**
  91359. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  91360. * @param scene the scene where the event occurred
  91361. * @param evt The original (browser) event
  91362. * @returns the new ActionEvent
  91363. */
  91364. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  91365. /**
  91366. * Helper function to auto-create an ActionEvent from a primitive
  91367. * @param prim defines the target primitive
  91368. * @param pointerPos defines the pointer position
  91369. * @param evt The original (browser) event
  91370. * @param additionalData additional data for the event
  91371. * @returns the new ActionEvent
  91372. */
  91373. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  91374. }
  91375. }
  91376. declare module BABYLON {
  91377. /**
  91378. * Abstract class used to decouple action Manager from scene and meshes.
  91379. * Do not instantiate.
  91380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91381. */
  91382. export abstract class AbstractActionManager implements IDisposable {
  91383. /** Gets the list of active triggers */
  91384. static Triggers: {
  91385. [key: string]: number;
  91386. };
  91387. /** Gets the cursor to use when hovering items */
  91388. hoverCursor: string;
  91389. /** Gets the list of actions */
  91390. actions: IAction[];
  91391. /**
  91392. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  91393. */
  91394. isRecursive: boolean;
  91395. /**
  91396. * Releases all associated resources
  91397. */
  91398. abstract dispose(): void;
  91399. /**
  91400. * Does this action manager has pointer triggers
  91401. */
  91402. abstract readonly hasPointerTriggers: boolean;
  91403. /**
  91404. * Does this action manager has pick triggers
  91405. */
  91406. abstract readonly hasPickTriggers: boolean;
  91407. /**
  91408. * Process a specific trigger
  91409. * @param trigger defines the trigger to process
  91410. * @param evt defines the event details to be processed
  91411. */
  91412. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  91413. /**
  91414. * Does this action manager handles actions of any of the given triggers
  91415. * @param triggers defines the triggers to be tested
  91416. * @return a boolean indicating whether one (or more) of the triggers is handled
  91417. */
  91418. abstract hasSpecificTriggers(triggers: number[]): boolean;
  91419. /**
  91420. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91421. * speed.
  91422. * @param triggerA defines the trigger to be tested
  91423. * @param triggerB defines the trigger to be tested
  91424. * @return a boolean indicating whether one (or more) of the triggers is handled
  91425. */
  91426. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91427. /**
  91428. * Does this action manager handles actions of a given trigger
  91429. * @param trigger defines the trigger to be tested
  91430. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91431. * @return whether the trigger is handled
  91432. */
  91433. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91434. /**
  91435. * Serialize this manager to a JSON object
  91436. * @param name defines the property name to store this manager
  91437. * @returns a JSON representation of this manager
  91438. */
  91439. abstract serialize(name: string): any;
  91440. /**
  91441. * Registers an action to this action manager
  91442. * @param action defines the action to be registered
  91443. * @return the action amended (prepared) after registration
  91444. */
  91445. abstract registerAction(action: IAction): Nullable<IAction>;
  91446. /**
  91447. * Unregisters an action to this action manager
  91448. * @param action defines the action to be unregistered
  91449. * @return a boolean indicating whether the action has been unregistered
  91450. */
  91451. abstract unregisterAction(action: IAction): Boolean;
  91452. /**
  91453. * Does exist one action manager with at least one trigger
  91454. **/
  91455. static readonly HasTriggers: boolean;
  91456. /**
  91457. * Does exist one action manager with at least one pick trigger
  91458. **/
  91459. static readonly HasPickTriggers: boolean;
  91460. /**
  91461. * Does exist one action manager that handles actions of a given trigger
  91462. * @param trigger defines the trigger to be tested
  91463. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  91464. **/
  91465. static HasSpecificTrigger(trigger: number): boolean;
  91466. }
  91467. }
  91468. declare module BABYLON {
  91469. /**
  91470. * Defines how a node can be built from a string name.
  91471. */
  91472. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  91473. /**
  91474. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  91475. */
  91476. export class Node implements IBehaviorAware<Node> {
  91477. /** @hidden */
  91478. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  91479. private static _NodeConstructors;
  91480. /**
  91481. * Add a new node constructor
  91482. * @param type defines the type name of the node to construct
  91483. * @param constructorFunc defines the constructor function
  91484. */
  91485. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  91486. /**
  91487. * Returns a node constructor based on type name
  91488. * @param type defines the type name
  91489. * @param name defines the new node name
  91490. * @param scene defines the hosting scene
  91491. * @param options defines optional options to transmit to constructors
  91492. * @returns the new constructor or null
  91493. */
  91494. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  91495. /**
  91496. * Gets or sets the name of the node
  91497. */
  91498. name: string;
  91499. /**
  91500. * Gets or sets the id of the node
  91501. */
  91502. id: string;
  91503. /**
  91504. * Gets or sets the unique id of the node
  91505. */
  91506. uniqueId: number;
  91507. /**
  91508. * Gets or sets a string used to store user defined state for the node
  91509. */
  91510. state: string;
  91511. /**
  91512. * Gets or sets an object used to store user defined information for the node
  91513. */
  91514. metadata: any;
  91515. /**
  91516. * For internal use only. Please do not use.
  91517. */
  91518. reservedDataStore: any;
  91519. /**
  91520. * List of inspectable custom properties (used by the Inspector)
  91521. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91522. */
  91523. inspectableCustomProperties: IInspectable[];
  91524. /**
  91525. * Gets or sets a boolean used to define if the node must be serialized
  91526. */
  91527. doNotSerialize: boolean;
  91528. /** @hidden */
  91529. _isDisposed: boolean;
  91530. /**
  91531. * Gets a list of Animations associated with the node
  91532. */
  91533. animations: Animation[];
  91534. protected _ranges: {
  91535. [name: string]: Nullable<AnimationRange>;
  91536. };
  91537. /**
  91538. * Callback raised when the node is ready to be used
  91539. */
  91540. onReady: Nullable<(node: Node) => void>;
  91541. private _isEnabled;
  91542. private _isParentEnabled;
  91543. private _isReady;
  91544. /** @hidden */
  91545. _currentRenderId: number;
  91546. private _parentUpdateId;
  91547. /** @hidden */
  91548. _childUpdateId: number;
  91549. /** @hidden */
  91550. _waitingParentId: Nullable<string>;
  91551. /** @hidden */
  91552. _scene: Scene;
  91553. /** @hidden */
  91554. _cache: any;
  91555. private _parentNode;
  91556. private _children;
  91557. /** @hidden */
  91558. _worldMatrix: Matrix;
  91559. /** @hidden */
  91560. _worldMatrixDeterminant: number;
  91561. /** @hidden */
  91562. _worldMatrixDeterminantIsDirty: boolean;
  91563. /** @hidden */
  91564. private _sceneRootNodesIndex;
  91565. /**
  91566. * Gets a boolean indicating if the node has been disposed
  91567. * @returns true if the node was disposed
  91568. */
  91569. isDisposed(): boolean;
  91570. /**
  91571. * Gets or sets the parent of the node (without keeping the current position in the scene)
  91572. * @see https://doc.babylonjs.com/how_to/parenting
  91573. */
  91574. parent: Nullable<Node>;
  91575. private addToSceneRootNodes;
  91576. private removeFromSceneRootNodes;
  91577. private _animationPropertiesOverride;
  91578. /**
  91579. * Gets or sets the animation properties override
  91580. */
  91581. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91582. /**
  91583. * Gets a string idenfifying the name of the class
  91584. * @returns "Node" string
  91585. */
  91586. getClassName(): string;
  91587. /** @hidden */
  91588. readonly _isNode: boolean;
  91589. /**
  91590. * An event triggered when the mesh is disposed
  91591. */
  91592. onDisposeObservable: Observable<Node>;
  91593. private _onDisposeObserver;
  91594. /**
  91595. * Sets a callback that will be raised when the node will be disposed
  91596. */
  91597. onDispose: () => void;
  91598. /**
  91599. * Creates a new Node
  91600. * @param name the name and id to be given to this node
  91601. * @param scene the scene this node will be added to
  91602. * @param addToRootNodes the node will be added to scene.rootNodes
  91603. */
  91604. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  91605. /**
  91606. * Gets the scene of the node
  91607. * @returns a scene
  91608. */
  91609. getScene(): Scene;
  91610. /**
  91611. * Gets the engine of the node
  91612. * @returns a Engine
  91613. */
  91614. getEngine(): Engine;
  91615. private _behaviors;
  91616. /**
  91617. * Attach a behavior to the node
  91618. * @see http://doc.babylonjs.com/features/behaviour
  91619. * @param behavior defines the behavior to attach
  91620. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  91621. * @returns the current Node
  91622. */
  91623. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  91624. /**
  91625. * Remove an attached behavior
  91626. * @see http://doc.babylonjs.com/features/behaviour
  91627. * @param behavior defines the behavior to attach
  91628. * @returns the current Node
  91629. */
  91630. removeBehavior(behavior: Behavior<Node>): Node;
  91631. /**
  91632. * Gets the list of attached behaviors
  91633. * @see http://doc.babylonjs.com/features/behaviour
  91634. */
  91635. readonly behaviors: Behavior<Node>[];
  91636. /**
  91637. * Gets an attached behavior by name
  91638. * @param name defines the name of the behavior to look for
  91639. * @see http://doc.babylonjs.com/features/behaviour
  91640. * @returns null if behavior was not found else the requested behavior
  91641. */
  91642. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  91643. /**
  91644. * Returns the latest update of the World matrix
  91645. * @returns a Matrix
  91646. */
  91647. getWorldMatrix(): Matrix;
  91648. /** @hidden */
  91649. _getWorldMatrixDeterminant(): number;
  91650. /**
  91651. * Returns directly the latest state of the mesh World matrix.
  91652. * A Matrix is returned.
  91653. */
  91654. readonly worldMatrixFromCache: Matrix;
  91655. /** @hidden */
  91656. _initCache(): void;
  91657. /** @hidden */
  91658. updateCache(force?: boolean): void;
  91659. /** @hidden */
  91660. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91661. /** @hidden */
  91662. _updateCache(ignoreParentClass?: boolean): void;
  91663. /** @hidden */
  91664. _isSynchronized(): boolean;
  91665. /** @hidden */
  91666. _markSyncedWithParent(): void;
  91667. /** @hidden */
  91668. isSynchronizedWithParent(): boolean;
  91669. /** @hidden */
  91670. isSynchronized(): boolean;
  91671. /**
  91672. * Is this node ready to be used/rendered
  91673. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91674. * @return true if the node is ready
  91675. */
  91676. isReady(completeCheck?: boolean): boolean;
  91677. /**
  91678. * Is this node enabled?
  91679. * 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
  91680. * @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
  91681. * @return whether this node (and its parent) is enabled
  91682. */
  91683. isEnabled(checkAncestors?: boolean): boolean;
  91684. /** @hidden */
  91685. protected _syncParentEnabledState(): void;
  91686. /**
  91687. * Set the enabled state of this node
  91688. * @param value defines the new enabled state
  91689. */
  91690. setEnabled(value: boolean): void;
  91691. /**
  91692. * Is this node a descendant of the given node?
  91693. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  91694. * @param ancestor defines the parent node to inspect
  91695. * @returns a boolean indicating if this node is a descendant of the given node
  91696. */
  91697. isDescendantOf(ancestor: Node): boolean;
  91698. /** @hidden */
  91699. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  91700. /**
  91701. * Will return all nodes that have this node as ascendant
  91702. * @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
  91703. * @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
  91704. * @return all children nodes of all types
  91705. */
  91706. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  91707. /**
  91708. * Get all child-meshes of this node
  91709. * @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)
  91710. * @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
  91711. * @returns an array of AbstractMesh
  91712. */
  91713. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  91714. /**
  91715. * Get all direct children of this node
  91716. * @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
  91717. * @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)
  91718. * @returns an array of Node
  91719. */
  91720. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  91721. /** @hidden */
  91722. _setReady(state: boolean): void;
  91723. /**
  91724. * Get an animation by name
  91725. * @param name defines the name of the animation to look for
  91726. * @returns null if not found else the requested animation
  91727. */
  91728. getAnimationByName(name: string): Nullable<Animation>;
  91729. /**
  91730. * Creates an animation range for this node
  91731. * @param name defines the name of the range
  91732. * @param from defines the starting key
  91733. * @param to defines the end key
  91734. */
  91735. createAnimationRange(name: string, from: number, to: number): void;
  91736. /**
  91737. * Delete a specific animation range
  91738. * @param name defines the name of the range to delete
  91739. * @param deleteFrames defines if animation frames from the range must be deleted as well
  91740. */
  91741. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91742. /**
  91743. * Get an animation range by name
  91744. * @param name defines the name of the animation range to look for
  91745. * @returns null if not found else the requested animation range
  91746. */
  91747. getAnimationRange(name: string): Nullable<AnimationRange>;
  91748. /**
  91749. * Gets the list of all animation ranges defined on this node
  91750. * @returns an array
  91751. */
  91752. getAnimationRanges(): Nullable<AnimationRange>[];
  91753. /**
  91754. * Will start the animation sequence
  91755. * @param name defines the range frames for animation sequence
  91756. * @param loop defines if the animation should loop (false by default)
  91757. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  91758. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  91759. * @returns the object created for this animation. If range does not exist, it will return null
  91760. */
  91761. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91762. /**
  91763. * Serialize animation ranges into a JSON compatible object
  91764. * @returns serialization object
  91765. */
  91766. serializeAnimationRanges(): any;
  91767. /**
  91768. * Computes the world matrix of the node
  91769. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91770. * @returns the world matrix
  91771. */
  91772. computeWorldMatrix(force?: boolean): Matrix;
  91773. /**
  91774. * Releases resources associated with this node.
  91775. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91776. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91777. */
  91778. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91779. /**
  91780. * Parse animation range data from a serialization object and store them into a given node
  91781. * @param node defines where to store the animation ranges
  91782. * @param parsedNode defines the serialization object to read data from
  91783. * @param scene defines the hosting scene
  91784. */
  91785. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91786. /**
  91787. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91788. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91789. * @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
  91790. * @returns the new bounding vectors
  91791. */
  91792. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91793. min: Vector3;
  91794. max: Vector3;
  91795. };
  91796. }
  91797. }
  91798. declare module BABYLON {
  91799. /**
  91800. * @hidden
  91801. */
  91802. export class _IAnimationState {
  91803. key: number;
  91804. repeatCount: number;
  91805. workValue?: any;
  91806. loopMode?: number;
  91807. offsetValue?: any;
  91808. highLimitValue?: any;
  91809. }
  91810. /**
  91811. * Class used to store any kind of animation
  91812. */
  91813. export class Animation {
  91814. /**Name of the animation */
  91815. name: string;
  91816. /**Property to animate */
  91817. targetProperty: string;
  91818. /**The frames per second of the animation */
  91819. framePerSecond: number;
  91820. /**The data type of the animation */
  91821. dataType: number;
  91822. /**The loop mode of the animation */
  91823. loopMode?: number | undefined;
  91824. /**Specifies if blending should be enabled */
  91825. enableBlending?: boolean | undefined;
  91826. /**
  91827. * Use matrix interpolation instead of using direct key value when animating matrices
  91828. */
  91829. static AllowMatricesInterpolation: boolean;
  91830. /**
  91831. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91832. */
  91833. static AllowMatrixDecomposeForInterpolation: boolean;
  91834. /**
  91835. * Stores the key frames of the animation
  91836. */
  91837. private _keys;
  91838. /**
  91839. * Stores the easing function of the animation
  91840. */
  91841. private _easingFunction;
  91842. /**
  91843. * @hidden Internal use only
  91844. */
  91845. _runtimeAnimations: RuntimeAnimation[];
  91846. /**
  91847. * The set of event that will be linked to this animation
  91848. */
  91849. private _events;
  91850. /**
  91851. * Stores an array of target property paths
  91852. */
  91853. targetPropertyPath: string[];
  91854. /**
  91855. * Stores the blending speed of the animation
  91856. */
  91857. blendingSpeed: number;
  91858. /**
  91859. * Stores the animation ranges for the animation
  91860. */
  91861. private _ranges;
  91862. /**
  91863. * @hidden Internal use
  91864. */
  91865. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  91866. /**
  91867. * Sets up an animation
  91868. * @param property The property to animate
  91869. * @param animationType The animation type to apply
  91870. * @param framePerSecond The frames per second of the animation
  91871. * @param easingFunction The easing function used in the animation
  91872. * @returns The created animation
  91873. */
  91874. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  91875. /**
  91876. * Create and start an animation on a node
  91877. * @param name defines the name of the global animation that will be run on all nodes
  91878. * @param node defines the root node where the animation will take place
  91879. * @param targetProperty defines property to animate
  91880. * @param framePerSecond defines the number of frame per second yo use
  91881. * @param totalFrame defines the number of frames in total
  91882. * @param from defines the initial value
  91883. * @param to defines the final value
  91884. * @param loopMode defines which loop mode you want to use (off by default)
  91885. * @param easingFunction defines the easing function to use (linear by default)
  91886. * @param onAnimationEnd defines the callback to call when animation end
  91887. * @returns the animatable created for this animation
  91888. */
  91889. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91890. /**
  91891. * Create and start an animation on a node and its descendants
  91892. * @param name defines the name of the global animation that will be run on all nodes
  91893. * @param node defines the root node where the animation will take place
  91894. * @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
  91895. * @param targetProperty defines property to animate
  91896. * @param framePerSecond defines the number of frame per second to use
  91897. * @param totalFrame defines the number of frames in total
  91898. * @param from defines the initial value
  91899. * @param to defines the final value
  91900. * @param loopMode defines which loop mode you want to use (off by default)
  91901. * @param easingFunction defines the easing function to use (linear by default)
  91902. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91903. * @returns the list of animatables created for all nodes
  91904. * @example https://www.babylonjs-playground.com/#MH0VLI
  91905. */
  91906. 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[]>;
  91907. /**
  91908. * Creates a new animation, merges it with the existing animations and starts it
  91909. * @param name Name of the animation
  91910. * @param node Node which contains the scene that begins the animations
  91911. * @param targetProperty Specifies which property to animate
  91912. * @param framePerSecond The frames per second of the animation
  91913. * @param totalFrame The total number of frames
  91914. * @param from The frame at the beginning of the animation
  91915. * @param to The frame at the end of the animation
  91916. * @param loopMode Specifies the loop mode of the animation
  91917. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  91918. * @param onAnimationEnd Callback to run once the animation is complete
  91919. * @returns Nullable animation
  91920. */
  91921. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91922. /**
  91923. * Transition property of an host to the target Value
  91924. * @param property The property to transition
  91925. * @param targetValue The target Value of the property
  91926. * @param host The object where the property to animate belongs
  91927. * @param scene Scene used to run the animation
  91928. * @param frameRate Framerate (in frame/s) to use
  91929. * @param transition The transition type we want to use
  91930. * @param duration The duration of the animation, in milliseconds
  91931. * @param onAnimationEnd Callback trigger at the end of the animation
  91932. * @returns Nullable animation
  91933. */
  91934. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  91935. /**
  91936. * Return the array of runtime animations currently using this animation
  91937. */
  91938. readonly runtimeAnimations: RuntimeAnimation[];
  91939. /**
  91940. * Specifies if any of the runtime animations are currently running
  91941. */
  91942. readonly hasRunningRuntimeAnimations: boolean;
  91943. /**
  91944. * Initializes the animation
  91945. * @param name Name of the animation
  91946. * @param targetProperty Property to animate
  91947. * @param framePerSecond The frames per second of the animation
  91948. * @param dataType The data type of the animation
  91949. * @param loopMode The loop mode of the animation
  91950. * @param enableBlending Specifies if blending should be enabled
  91951. */
  91952. constructor(
  91953. /**Name of the animation */
  91954. name: string,
  91955. /**Property to animate */
  91956. targetProperty: string,
  91957. /**The frames per second of the animation */
  91958. framePerSecond: number,
  91959. /**The data type of the animation */
  91960. dataType: number,
  91961. /**The loop mode of the animation */
  91962. loopMode?: number | undefined,
  91963. /**Specifies if blending should be enabled */
  91964. enableBlending?: boolean | undefined);
  91965. /**
  91966. * Converts the animation to a string
  91967. * @param fullDetails support for multiple levels of logging within scene loading
  91968. * @returns String form of the animation
  91969. */
  91970. toString(fullDetails?: boolean): string;
  91971. /**
  91972. * Add an event to this animation
  91973. * @param event Event to add
  91974. */
  91975. addEvent(event: AnimationEvent): void;
  91976. /**
  91977. * Remove all events found at the given frame
  91978. * @param frame The frame to remove events from
  91979. */
  91980. removeEvents(frame: number): void;
  91981. /**
  91982. * Retrieves all the events from the animation
  91983. * @returns Events from the animation
  91984. */
  91985. getEvents(): AnimationEvent[];
  91986. /**
  91987. * Creates an animation range
  91988. * @param name Name of the animation range
  91989. * @param from Starting frame of the animation range
  91990. * @param to Ending frame of the animation
  91991. */
  91992. createRange(name: string, from: number, to: number): void;
  91993. /**
  91994. * Deletes an animation range by name
  91995. * @param name Name of the animation range to delete
  91996. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  91997. */
  91998. deleteRange(name: string, deleteFrames?: boolean): void;
  91999. /**
  92000. * Gets the animation range by name, or null if not defined
  92001. * @param name Name of the animation range
  92002. * @returns Nullable animation range
  92003. */
  92004. getRange(name: string): Nullable<AnimationRange>;
  92005. /**
  92006. * Gets the key frames from the animation
  92007. * @returns The key frames of the animation
  92008. */
  92009. getKeys(): Array<IAnimationKey>;
  92010. /**
  92011. * Gets the highest frame rate of the animation
  92012. * @returns Highest frame rate of the animation
  92013. */
  92014. getHighestFrame(): number;
  92015. /**
  92016. * Gets the easing function of the animation
  92017. * @returns Easing function of the animation
  92018. */
  92019. getEasingFunction(): IEasingFunction;
  92020. /**
  92021. * Sets the easing function of the animation
  92022. * @param easingFunction A custom mathematical formula for animation
  92023. */
  92024. setEasingFunction(easingFunction: EasingFunction): void;
  92025. /**
  92026. * Interpolates a scalar linearly
  92027. * @param startValue Start value of the animation curve
  92028. * @param endValue End value of the animation curve
  92029. * @param gradient Scalar amount to interpolate
  92030. * @returns Interpolated scalar value
  92031. */
  92032. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  92033. /**
  92034. * Interpolates a scalar cubically
  92035. * @param startValue Start value of the animation curve
  92036. * @param outTangent End tangent of the animation
  92037. * @param endValue End value of the animation curve
  92038. * @param inTangent Start tangent of the animation curve
  92039. * @param gradient Scalar amount to interpolate
  92040. * @returns Interpolated scalar value
  92041. */
  92042. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  92043. /**
  92044. * Interpolates a quaternion using a spherical linear interpolation
  92045. * @param startValue Start value of the animation curve
  92046. * @param endValue End value of the animation curve
  92047. * @param gradient Scalar amount to interpolate
  92048. * @returns Interpolated quaternion value
  92049. */
  92050. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  92051. /**
  92052. * Interpolates a quaternion cubically
  92053. * @param startValue Start value of the animation curve
  92054. * @param outTangent End tangent of the animation curve
  92055. * @param endValue End value of the animation curve
  92056. * @param inTangent Start tangent of the animation curve
  92057. * @param gradient Scalar amount to interpolate
  92058. * @returns Interpolated quaternion value
  92059. */
  92060. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  92061. /**
  92062. * Interpolates a Vector3 linearl
  92063. * @param startValue Start value of the animation curve
  92064. * @param endValue End value of the animation curve
  92065. * @param gradient Scalar amount to interpolate
  92066. * @returns Interpolated scalar value
  92067. */
  92068. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  92069. /**
  92070. * Interpolates a Vector3 cubically
  92071. * @param startValue Start value of the animation curve
  92072. * @param outTangent End tangent of the animation
  92073. * @param endValue End value of the animation curve
  92074. * @param inTangent Start tangent of the animation curve
  92075. * @param gradient Scalar amount to interpolate
  92076. * @returns InterpolatedVector3 value
  92077. */
  92078. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  92079. /**
  92080. * Interpolates a Vector2 linearly
  92081. * @param startValue Start value of the animation curve
  92082. * @param endValue End value of the animation curve
  92083. * @param gradient Scalar amount to interpolate
  92084. * @returns Interpolated Vector2 value
  92085. */
  92086. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  92087. /**
  92088. * Interpolates a Vector2 cubically
  92089. * @param startValue Start value of the animation curve
  92090. * @param outTangent End tangent of the animation
  92091. * @param endValue End value of the animation curve
  92092. * @param inTangent Start tangent of the animation curve
  92093. * @param gradient Scalar amount to interpolate
  92094. * @returns Interpolated Vector2 value
  92095. */
  92096. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  92097. /**
  92098. * Interpolates a size linearly
  92099. * @param startValue Start value of the animation curve
  92100. * @param endValue End value of the animation curve
  92101. * @param gradient Scalar amount to interpolate
  92102. * @returns Interpolated Size value
  92103. */
  92104. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  92105. /**
  92106. * Interpolates a Color3 linearly
  92107. * @param startValue Start value of the animation curve
  92108. * @param endValue End value of the animation curve
  92109. * @param gradient Scalar amount to interpolate
  92110. * @returns Interpolated Color3 value
  92111. */
  92112. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  92113. /**
  92114. * @hidden Internal use only
  92115. */
  92116. _getKeyValue(value: any): any;
  92117. /**
  92118. * @hidden Internal use only
  92119. */
  92120. _interpolate(currentFrame: number, state: _IAnimationState): any;
  92121. /**
  92122. * Defines the function to use to interpolate matrices
  92123. * @param startValue defines the start matrix
  92124. * @param endValue defines the end matrix
  92125. * @param gradient defines the gradient between both matrices
  92126. * @param result defines an optional target matrix where to store the interpolation
  92127. * @returns the interpolated matrix
  92128. */
  92129. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  92130. /**
  92131. * Makes a copy of the animation
  92132. * @returns Cloned animation
  92133. */
  92134. clone(): Animation;
  92135. /**
  92136. * Sets the key frames of the animation
  92137. * @param values The animation key frames to set
  92138. */
  92139. setKeys(values: Array<IAnimationKey>): void;
  92140. /**
  92141. * Serializes the animation to an object
  92142. * @returns Serialized object
  92143. */
  92144. serialize(): any;
  92145. /**
  92146. * Float animation type
  92147. */
  92148. private static _ANIMATIONTYPE_FLOAT;
  92149. /**
  92150. * Vector3 animation type
  92151. */
  92152. private static _ANIMATIONTYPE_VECTOR3;
  92153. /**
  92154. * Quaternion animation type
  92155. */
  92156. private static _ANIMATIONTYPE_QUATERNION;
  92157. /**
  92158. * Matrix animation type
  92159. */
  92160. private static _ANIMATIONTYPE_MATRIX;
  92161. /**
  92162. * Color3 animation type
  92163. */
  92164. private static _ANIMATIONTYPE_COLOR3;
  92165. /**
  92166. * Vector2 animation type
  92167. */
  92168. private static _ANIMATIONTYPE_VECTOR2;
  92169. /**
  92170. * Size animation type
  92171. */
  92172. private static _ANIMATIONTYPE_SIZE;
  92173. /**
  92174. * Relative Loop Mode
  92175. */
  92176. private static _ANIMATIONLOOPMODE_RELATIVE;
  92177. /**
  92178. * Cycle Loop Mode
  92179. */
  92180. private static _ANIMATIONLOOPMODE_CYCLE;
  92181. /**
  92182. * Constant Loop Mode
  92183. */
  92184. private static _ANIMATIONLOOPMODE_CONSTANT;
  92185. /**
  92186. * Get the float animation type
  92187. */
  92188. static readonly ANIMATIONTYPE_FLOAT: number;
  92189. /**
  92190. * Get the Vector3 animation type
  92191. */
  92192. static readonly ANIMATIONTYPE_VECTOR3: number;
  92193. /**
  92194. * Get the Vector2 animation type
  92195. */
  92196. static readonly ANIMATIONTYPE_VECTOR2: number;
  92197. /**
  92198. * Get the Size animation type
  92199. */
  92200. static readonly ANIMATIONTYPE_SIZE: number;
  92201. /**
  92202. * Get the Quaternion animation type
  92203. */
  92204. static readonly ANIMATIONTYPE_QUATERNION: number;
  92205. /**
  92206. * Get the Matrix animation type
  92207. */
  92208. static readonly ANIMATIONTYPE_MATRIX: number;
  92209. /**
  92210. * Get the Color3 animation type
  92211. */
  92212. static readonly ANIMATIONTYPE_COLOR3: number;
  92213. /**
  92214. * Get the Relative Loop Mode
  92215. */
  92216. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  92217. /**
  92218. * Get the Cycle Loop Mode
  92219. */
  92220. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  92221. /**
  92222. * Get the Constant Loop Mode
  92223. */
  92224. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  92225. /** @hidden */
  92226. static _UniversalLerp(left: any, right: any, amount: number): any;
  92227. /**
  92228. * Parses an animation object and creates an animation
  92229. * @param parsedAnimation Parsed animation object
  92230. * @returns Animation object
  92231. */
  92232. static Parse(parsedAnimation: any): Animation;
  92233. /**
  92234. * Appends the serialized animations from the source animations
  92235. * @param source Source containing the animations
  92236. * @param destination Target to store the animations
  92237. */
  92238. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92239. }
  92240. }
  92241. declare module BABYLON {
  92242. /**
  92243. * Interface containing an array of animations
  92244. */
  92245. export interface IAnimatable {
  92246. /**
  92247. * Array of animations
  92248. */
  92249. animations: Nullable<Array<Animation>>;
  92250. }
  92251. }
  92252. declare module BABYLON {
  92253. /**
  92254. * This represents all the required information to add a fresnel effect on a material:
  92255. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92256. */
  92257. export class FresnelParameters {
  92258. private _isEnabled;
  92259. /**
  92260. * Define if the fresnel effect is enable or not.
  92261. */
  92262. isEnabled: boolean;
  92263. /**
  92264. * Define the color used on edges (grazing angle)
  92265. */
  92266. leftColor: Color3;
  92267. /**
  92268. * Define the color used on center
  92269. */
  92270. rightColor: Color3;
  92271. /**
  92272. * Define bias applied to computed fresnel term
  92273. */
  92274. bias: number;
  92275. /**
  92276. * Defined the power exponent applied to fresnel term
  92277. */
  92278. power: number;
  92279. /**
  92280. * Clones the current fresnel and its valuues
  92281. * @returns a clone fresnel configuration
  92282. */
  92283. clone(): FresnelParameters;
  92284. /**
  92285. * Serializes the current fresnel parameters to a JSON representation.
  92286. * @return the JSON serialization
  92287. */
  92288. serialize(): any;
  92289. /**
  92290. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92291. * @param parsedFresnelParameters Define the JSON representation
  92292. * @returns the parsed parameters
  92293. */
  92294. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92295. }
  92296. }
  92297. declare module BABYLON {
  92298. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92299. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92300. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92301. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92302. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92303. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92304. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92305. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92306. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92307. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92308. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92309. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92310. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92311. /**
  92312. * Decorator used to define property that can be serialized as reference to a camera
  92313. * @param sourceName defines the name of the property to decorate
  92314. */
  92315. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92316. /**
  92317. * Class used to help serialization objects
  92318. */
  92319. export class SerializationHelper {
  92320. /** @hidden */
  92321. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92322. /** @hidden */
  92323. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92324. /** @hidden */
  92325. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92326. /** @hidden */
  92327. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92328. /**
  92329. * Appends the serialized animations from the source animations
  92330. * @param source Source containing the animations
  92331. * @param destination Target to store the animations
  92332. */
  92333. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92334. /**
  92335. * Static function used to serialized a specific entity
  92336. * @param entity defines the entity to serialize
  92337. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92338. * @returns a JSON compatible object representing the serialization of the entity
  92339. */
  92340. static Serialize<T>(entity: T, serializationObject?: any): any;
  92341. /**
  92342. * Creates a new entity from a serialization data object
  92343. * @param creationFunction defines a function used to instanciated the new entity
  92344. * @param source defines the source serialization data
  92345. * @param scene defines the hosting scene
  92346. * @param rootUrl defines the root url for resources
  92347. * @returns a new entity
  92348. */
  92349. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92350. /**
  92351. * Clones an object
  92352. * @param creationFunction defines the function used to instanciate the new object
  92353. * @param source defines the source object
  92354. * @returns the cloned object
  92355. */
  92356. static Clone<T>(creationFunction: () => T, source: T): T;
  92357. /**
  92358. * Instanciates a new object based on a source one (some data will be shared between both object)
  92359. * @param creationFunction defines the function used to instanciate the new object
  92360. * @param source defines the source object
  92361. * @returns the new object
  92362. */
  92363. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92364. }
  92365. }
  92366. declare module BABYLON {
  92367. /**
  92368. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  92369. */
  92370. export interface CubeMapInfo {
  92371. /**
  92372. * The pixel array for the front face.
  92373. * This is stored in format, left to right, up to down format.
  92374. */
  92375. front: Nullable<ArrayBufferView>;
  92376. /**
  92377. * The pixel array for the back face.
  92378. * This is stored in format, left to right, up to down format.
  92379. */
  92380. back: Nullable<ArrayBufferView>;
  92381. /**
  92382. * The pixel array for the left face.
  92383. * This is stored in format, left to right, up to down format.
  92384. */
  92385. left: Nullable<ArrayBufferView>;
  92386. /**
  92387. * The pixel array for the right face.
  92388. * This is stored in format, left to right, up to down format.
  92389. */
  92390. right: Nullable<ArrayBufferView>;
  92391. /**
  92392. * The pixel array for the up face.
  92393. * This is stored in format, left to right, up to down format.
  92394. */
  92395. up: Nullable<ArrayBufferView>;
  92396. /**
  92397. * The pixel array for the down face.
  92398. * This is stored in format, left to right, up to down format.
  92399. */
  92400. down: Nullable<ArrayBufferView>;
  92401. /**
  92402. * The size of the cubemap stored.
  92403. *
  92404. * Each faces will be size * size pixels.
  92405. */
  92406. size: number;
  92407. /**
  92408. * The format of the texture.
  92409. *
  92410. * RGBA, RGB.
  92411. */
  92412. format: number;
  92413. /**
  92414. * The type of the texture data.
  92415. *
  92416. * UNSIGNED_INT, FLOAT.
  92417. */
  92418. type: number;
  92419. /**
  92420. * Specifies whether the texture is in gamma space.
  92421. */
  92422. gammaSpace: boolean;
  92423. }
  92424. /**
  92425. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  92426. */
  92427. export class PanoramaToCubeMapTools {
  92428. private static FACE_FRONT;
  92429. private static FACE_BACK;
  92430. private static FACE_RIGHT;
  92431. private static FACE_LEFT;
  92432. private static FACE_DOWN;
  92433. private static FACE_UP;
  92434. /**
  92435. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  92436. *
  92437. * @param float32Array The source data.
  92438. * @param inputWidth The width of the input panorama.
  92439. * @param inputHeight The height of the input panorama.
  92440. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  92441. * @return The cubemap data
  92442. */
  92443. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  92444. private static CreateCubemapTexture;
  92445. private static CalcProjectionSpherical;
  92446. }
  92447. }
  92448. declare module BABYLON {
  92449. /**
  92450. * Helper class dealing with the extraction of spherical polynomial dataArray
  92451. * from a cube map.
  92452. */
  92453. export class CubeMapToSphericalPolynomialTools {
  92454. private static FileFaces;
  92455. /**
  92456. * Converts a texture to the according Spherical Polynomial data.
  92457. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92458. *
  92459. * @param texture The texture to extract the information from.
  92460. * @return The Spherical Polynomial data.
  92461. */
  92462. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  92463. /**
  92464. * Converts a cubemap to the according Spherical Polynomial data.
  92465. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92466. *
  92467. * @param cubeInfo The Cube map to extract the information from.
  92468. * @return The Spherical Polynomial data.
  92469. */
  92470. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  92471. }
  92472. }
  92473. declare module BABYLON {
  92474. /**
  92475. * Class used to manipulate GUIDs
  92476. */
  92477. export class GUID {
  92478. /**
  92479. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92480. * Be aware Math.random() could cause collisions, but:
  92481. * "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"
  92482. * @returns a pseudo random id
  92483. */
  92484. static RandomId(): string;
  92485. }
  92486. }
  92487. declare module BABYLON {
  92488. /**
  92489. * Base class of all the textures in babylon.
  92490. * It groups all the common properties the materials, post process, lights... might need
  92491. * in order to make a correct use of the texture.
  92492. */
  92493. export class BaseTexture implements IAnimatable {
  92494. /**
  92495. * Default anisotropic filtering level for the application.
  92496. * It is set to 4 as a good tradeoff between perf and quality.
  92497. */
  92498. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92499. /**
  92500. * Gets or sets the unique id of the texture
  92501. */
  92502. uniqueId: number;
  92503. /**
  92504. * Define the name of the texture.
  92505. */
  92506. name: string;
  92507. /**
  92508. * Gets or sets an object used to store user defined information.
  92509. */
  92510. metadata: any;
  92511. /**
  92512. * For internal use only. Please do not use.
  92513. */
  92514. reservedDataStore: any;
  92515. private _hasAlpha;
  92516. /**
  92517. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92518. */
  92519. hasAlpha: boolean;
  92520. /**
  92521. * Defines if the alpha value should be determined via the rgb values.
  92522. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92523. */
  92524. getAlphaFromRGB: boolean;
  92525. /**
  92526. * Intensity or strength of the texture.
  92527. * It is commonly used by materials to fine tune the intensity of the texture
  92528. */
  92529. level: number;
  92530. /**
  92531. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92532. * This is part of the texture as textures usually maps to one uv set.
  92533. */
  92534. coordinatesIndex: number;
  92535. private _coordinatesMode;
  92536. /**
  92537. * How a texture is mapped.
  92538. *
  92539. * | Value | Type | Description |
  92540. * | ----- | ----------------------------------- | ----------- |
  92541. * | 0 | EXPLICIT_MODE | |
  92542. * | 1 | SPHERICAL_MODE | |
  92543. * | 2 | PLANAR_MODE | |
  92544. * | 3 | CUBIC_MODE | |
  92545. * | 4 | PROJECTION_MODE | |
  92546. * | 5 | SKYBOX_MODE | |
  92547. * | 6 | INVCUBIC_MODE | |
  92548. * | 7 | EQUIRECTANGULAR_MODE | |
  92549. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92550. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92551. */
  92552. coordinatesMode: number;
  92553. /**
  92554. * | Value | Type | Description |
  92555. * | ----- | ------------------ | ----------- |
  92556. * | 0 | CLAMP_ADDRESSMODE | |
  92557. * | 1 | WRAP_ADDRESSMODE | |
  92558. * | 2 | MIRROR_ADDRESSMODE | |
  92559. */
  92560. wrapU: number;
  92561. /**
  92562. * | Value | Type | Description |
  92563. * | ----- | ------------------ | ----------- |
  92564. * | 0 | CLAMP_ADDRESSMODE | |
  92565. * | 1 | WRAP_ADDRESSMODE | |
  92566. * | 2 | MIRROR_ADDRESSMODE | |
  92567. */
  92568. wrapV: number;
  92569. /**
  92570. * | Value | Type | Description |
  92571. * | ----- | ------------------ | ----------- |
  92572. * | 0 | CLAMP_ADDRESSMODE | |
  92573. * | 1 | WRAP_ADDRESSMODE | |
  92574. * | 2 | MIRROR_ADDRESSMODE | |
  92575. */
  92576. wrapR: number;
  92577. /**
  92578. * With compliant hardware and browser (supporting anisotropic filtering)
  92579. * this defines the level of anisotropic filtering in the texture.
  92580. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92581. */
  92582. anisotropicFilteringLevel: number;
  92583. /**
  92584. * Define if the texture is a cube texture or if false a 2d texture.
  92585. */
  92586. isCube: boolean;
  92587. /**
  92588. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92589. */
  92590. is3D: boolean;
  92591. /**
  92592. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92593. * HDR texture are usually stored in linear space.
  92594. * This only impacts the PBR and Background materials
  92595. */
  92596. gammaSpace: boolean;
  92597. /**
  92598. * Gets whether or not the texture contains RGBD data.
  92599. */
  92600. readonly isRGBD: boolean;
  92601. /**
  92602. * Is Z inverted in the texture (useful in a cube texture).
  92603. */
  92604. invertZ: boolean;
  92605. /**
  92606. * Are mip maps generated for this texture or not.
  92607. */
  92608. readonly noMipmap: boolean;
  92609. /**
  92610. * @hidden
  92611. */
  92612. lodLevelInAlpha: boolean;
  92613. /**
  92614. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92615. */
  92616. lodGenerationOffset: number;
  92617. /**
  92618. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92619. */
  92620. lodGenerationScale: number;
  92621. /**
  92622. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92623. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92624. * average roughness values.
  92625. */
  92626. linearSpecularLOD: boolean;
  92627. /**
  92628. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92629. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92630. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92631. */
  92632. irradianceTexture: Nullable<BaseTexture>;
  92633. /**
  92634. * Define if the texture is a render target.
  92635. */
  92636. isRenderTarget: boolean;
  92637. /**
  92638. * Define the unique id of the texture in the scene.
  92639. */
  92640. readonly uid: string;
  92641. /**
  92642. * Return a string representation of the texture.
  92643. * @returns the texture as a string
  92644. */
  92645. toString(): string;
  92646. /**
  92647. * Get the class name of the texture.
  92648. * @returns "BaseTexture"
  92649. */
  92650. getClassName(): string;
  92651. /**
  92652. * Define the list of animation attached to the texture.
  92653. */
  92654. animations: Animation[];
  92655. /**
  92656. * An event triggered when the texture is disposed.
  92657. */
  92658. onDisposeObservable: Observable<BaseTexture>;
  92659. private _onDisposeObserver;
  92660. /**
  92661. * Callback triggered when the texture has been disposed.
  92662. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92663. */
  92664. onDispose: () => void;
  92665. /**
  92666. * Define the current state of the loading sequence when in delayed load mode.
  92667. */
  92668. delayLoadState: number;
  92669. private _scene;
  92670. /** @hidden */
  92671. _texture: Nullable<InternalTexture>;
  92672. private _uid;
  92673. /**
  92674. * Define if the texture is preventinga material to render or not.
  92675. * If not and the texture is not ready, the engine will use a default black texture instead.
  92676. */
  92677. readonly isBlocking: boolean;
  92678. /**
  92679. * Instantiates a new BaseTexture.
  92680. * Base class of all the textures in babylon.
  92681. * It groups all the common properties the materials, post process, lights... might need
  92682. * in order to make a correct use of the texture.
  92683. * @param scene Define the scene the texture blongs to
  92684. */
  92685. constructor(scene: Nullable<Scene>);
  92686. /**
  92687. * Get the scene the texture belongs to.
  92688. * @returns the scene or null if undefined
  92689. */
  92690. getScene(): Nullable<Scene>;
  92691. /**
  92692. * Get the texture transform matrix used to offset tile the texture for istance.
  92693. * @returns the transformation matrix
  92694. */
  92695. getTextureMatrix(): Matrix;
  92696. /**
  92697. * Get the texture reflection matrix used to rotate/transform the reflection.
  92698. * @returns the reflection matrix
  92699. */
  92700. getReflectionTextureMatrix(): Matrix;
  92701. /**
  92702. * Get the underlying lower level texture from Babylon.
  92703. * @returns the insternal texture
  92704. */
  92705. getInternalTexture(): Nullable<InternalTexture>;
  92706. /**
  92707. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92708. * @returns true if ready or not blocking
  92709. */
  92710. isReadyOrNotBlocking(): boolean;
  92711. /**
  92712. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  92713. * @returns true if fully ready
  92714. */
  92715. isReady(): boolean;
  92716. private _cachedSize;
  92717. /**
  92718. * Get the size of the texture.
  92719. * @returns the texture size.
  92720. */
  92721. getSize(): ISize;
  92722. /**
  92723. * Get the base size of the texture.
  92724. * It can be different from the size if the texture has been resized for POT for instance
  92725. * @returns the base size
  92726. */
  92727. getBaseSize(): ISize;
  92728. /**
  92729. * Update the sampling mode of the texture.
  92730. * Default is Trilinear mode.
  92731. *
  92732. * | Value | Type | Description |
  92733. * | ----- | ------------------ | ----------- |
  92734. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  92735. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  92736. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  92737. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  92738. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  92739. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  92740. * | 7 | NEAREST_LINEAR | |
  92741. * | 8 | NEAREST_NEAREST | |
  92742. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  92743. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  92744. * | 11 | LINEAR_LINEAR | |
  92745. * | 12 | LINEAR_NEAREST | |
  92746. *
  92747. * > _mag_: magnification filter (close to the viewer)
  92748. * > _min_: minification filter (far from the viewer)
  92749. * > _mip_: filter used between mip map levels
  92750. *@param samplingMode Define the new sampling mode of the texture
  92751. */
  92752. updateSamplingMode(samplingMode: number): void;
  92753. /**
  92754. * Scales the texture if is `canRescale()`
  92755. * @param ratio the resize factor we want to use to rescale
  92756. */
  92757. scale(ratio: number): void;
  92758. /**
  92759. * Get if the texture can rescale.
  92760. */
  92761. readonly canRescale: boolean;
  92762. /** @hidden */
  92763. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92764. /** @hidden */
  92765. _rebuild(): void;
  92766. /**
  92767. * Triggers the load sequence in delayed load mode.
  92768. */
  92769. delayLoad(): void;
  92770. /**
  92771. * Clones the texture.
  92772. * @returns the cloned texture
  92773. */
  92774. clone(): Nullable<BaseTexture>;
  92775. /**
  92776. * Get the texture underlying type (INT, FLOAT...)
  92777. */
  92778. readonly textureType: number;
  92779. /**
  92780. * Get the texture underlying format (RGB, RGBA...)
  92781. */
  92782. readonly textureFormat: number;
  92783. /**
  92784. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92785. * This will returns an RGBA array buffer containing either in values (0-255) or
  92786. * float values (0-1) depending of the underlying buffer type.
  92787. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92788. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92789. * @param buffer defines a user defined buffer to fill with data (can be null)
  92790. * @returns The Array buffer containing the pixels data.
  92791. */
  92792. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92793. /**
  92794. * Release and destroy the underlying lower level texture aka internalTexture.
  92795. */
  92796. releaseInternalTexture(): void;
  92797. /**
  92798. * Get the polynomial representation of the texture data.
  92799. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92800. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92801. */
  92802. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92803. /** @hidden */
  92804. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92805. /** @hidden */
  92806. readonly _lodTextureMid: Nullable<BaseTexture>;
  92807. /** @hidden */
  92808. readonly _lodTextureLow: Nullable<BaseTexture>;
  92809. /**
  92810. * Dispose the texture and release its associated resources.
  92811. */
  92812. dispose(): void;
  92813. /**
  92814. * Serialize the texture into a JSON representation that can be parsed later on.
  92815. * @returns the JSON representation of the texture
  92816. */
  92817. serialize(): any;
  92818. /**
  92819. * Helper function to be called back once a list of texture contains only ready textures.
  92820. * @param textures Define the list of textures to wait for
  92821. * @param callback Define the callback triggered once the entire list will be ready
  92822. */
  92823. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92824. }
  92825. }
  92826. declare module BABYLON {
  92827. /**
  92828. * Class used to store data associated with WebGL texture data for the engine
  92829. * This class should not be used directly
  92830. */
  92831. export class InternalTexture {
  92832. /** @hidden */
  92833. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92834. /**
  92835. * The source of the texture data is unknown
  92836. */
  92837. static DATASOURCE_UNKNOWN: number;
  92838. /**
  92839. * Texture data comes from an URL
  92840. */
  92841. static DATASOURCE_URL: number;
  92842. /**
  92843. * Texture data is only used for temporary storage
  92844. */
  92845. static DATASOURCE_TEMP: number;
  92846. /**
  92847. * Texture data comes from raw data (ArrayBuffer)
  92848. */
  92849. static DATASOURCE_RAW: number;
  92850. /**
  92851. * Texture content is dynamic (video or dynamic texture)
  92852. */
  92853. static DATASOURCE_DYNAMIC: number;
  92854. /**
  92855. * Texture content is generated by rendering to it
  92856. */
  92857. static DATASOURCE_RENDERTARGET: number;
  92858. /**
  92859. * Texture content is part of a multi render target process
  92860. */
  92861. static DATASOURCE_MULTIRENDERTARGET: number;
  92862. /**
  92863. * Texture data comes from a cube data file
  92864. */
  92865. static DATASOURCE_CUBE: number;
  92866. /**
  92867. * Texture data comes from a raw cube data
  92868. */
  92869. static DATASOURCE_CUBERAW: number;
  92870. /**
  92871. * Texture data come from a prefiltered cube data file
  92872. */
  92873. static DATASOURCE_CUBEPREFILTERED: number;
  92874. /**
  92875. * Texture content is raw 3D data
  92876. */
  92877. static DATASOURCE_RAW3D: number;
  92878. /**
  92879. * Texture content is a depth texture
  92880. */
  92881. static DATASOURCE_DEPTHTEXTURE: number;
  92882. /**
  92883. * Texture data comes from a raw cube data encoded with RGBD
  92884. */
  92885. static DATASOURCE_CUBERAW_RGBD: number;
  92886. /**
  92887. * Defines if the texture is ready
  92888. */
  92889. isReady: boolean;
  92890. /**
  92891. * Defines if the texture is a cube texture
  92892. */
  92893. isCube: boolean;
  92894. /**
  92895. * Defines if the texture contains 3D data
  92896. */
  92897. is3D: boolean;
  92898. /**
  92899. * Defines if the texture contains multiview data
  92900. */
  92901. isMultiview: boolean;
  92902. /**
  92903. * Gets the URL used to load this texture
  92904. */
  92905. url: string;
  92906. /**
  92907. * Gets the sampling mode of the texture
  92908. */
  92909. samplingMode: number;
  92910. /**
  92911. * Gets a boolean indicating if the texture needs mipmaps generation
  92912. */
  92913. generateMipMaps: boolean;
  92914. /**
  92915. * Gets the number of samples used by the texture (WebGL2+ only)
  92916. */
  92917. samples: number;
  92918. /**
  92919. * Gets the type of the texture (int, float...)
  92920. */
  92921. type: number;
  92922. /**
  92923. * Gets the format of the texture (RGB, RGBA...)
  92924. */
  92925. format: number;
  92926. /**
  92927. * Observable called when the texture is loaded
  92928. */
  92929. onLoadedObservable: Observable<InternalTexture>;
  92930. /**
  92931. * Gets the width of the texture
  92932. */
  92933. width: number;
  92934. /**
  92935. * Gets the height of the texture
  92936. */
  92937. height: number;
  92938. /**
  92939. * Gets the depth of the texture
  92940. */
  92941. depth: number;
  92942. /**
  92943. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  92944. */
  92945. baseWidth: number;
  92946. /**
  92947. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  92948. */
  92949. baseHeight: number;
  92950. /**
  92951. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  92952. */
  92953. baseDepth: number;
  92954. /**
  92955. * Gets a boolean indicating if the texture is inverted on Y axis
  92956. */
  92957. invertY: boolean;
  92958. /** @hidden */
  92959. _invertVScale: boolean;
  92960. /** @hidden */
  92961. _associatedChannel: number;
  92962. /** @hidden */
  92963. _dataSource: number;
  92964. /** @hidden */
  92965. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  92966. /** @hidden */
  92967. _bufferView: Nullable<ArrayBufferView>;
  92968. /** @hidden */
  92969. _bufferViewArray: Nullable<ArrayBufferView[]>;
  92970. /** @hidden */
  92971. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  92972. /** @hidden */
  92973. _size: number;
  92974. /** @hidden */
  92975. _extension: string;
  92976. /** @hidden */
  92977. _files: Nullable<string[]>;
  92978. /** @hidden */
  92979. _workingCanvas: Nullable<HTMLCanvasElement>;
  92980. /** @hidden */
  92981. _workingContext: Nullable<CanvasRenderingContext2D>;
  92982. /** @hidden */
  92983. _framebuffer: Nullable<WebGLFramebuffer>;
  92984. /** @hidden */
  92985. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  92986. /** @hidden */
  92987. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  92988. /** @hidden */
  92989. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  92990. /** @hidden */
  92991. _attachments: Nullable<number[]>;
  92992. /** @hidden */
  92993. _cachedCoordinatesMode: Nullable<number>;
  92994. /** @hidden */
  92995. _cachedWrapU: Nullable<number>;
  92996. /** @hidden */
  92997. _cachedWrapV: Nullable<number>;
  92998. /** @hidden */
  92999. _cachedWrapR: Nullable<number>;
  93000. /** @hidden */
  93001. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93002. /** @hidden */
  93003. _isDisabled: boolean;
  93004. /** @hidden */
  93005. _compression: Nullable<string>;
  93006. /** @hidden */
  93007. _generateStencilBuffer: boolean;
  93008. /** @hidden */
  93009. _generateDepthBuffer: boolean;
  93010. /** @hidden */
  93011. _comparisonFunction: number;
  93012. /** @hidden */
  93013. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93014. /** @hidden */
  93015. _lodGenerationScale: number;
  93016. /** @hidden */
  93017. _lodGenerationOffset: number;
  93018. /** @hidden */
  93019. _colorTextureArray: Nullable<WebGLTexture>;
  93020. /** @hidden */
  93021. _depthStencilTextureArray: Nullable<WebGLTexture>;
  93022. /** @hidden */
  93023. _lodTextureHigh: Nullable<BaseTexture>;
  93024. /** @hidden */
  93025. _lodTextureMid: Nullable<BaseTexture>;
  93026. /** @hidden */
  93027. _lodTextureLow: Nullable<BaseTexture>;
  93028. /** @hidden */
  93029. _isRGBD: boolean;
  93030. /** @hidden */
  93031. _linearSpecularLOD: boolean;
  93032. /** @hidden */
  93033. _irradianceTexture: Nullable<BaseTexture>;
  93034. /** @hidden */
  93035. _webGLTexture: Nullable<WebGLTexture>;
  93036. /** @hidden */
  93037. _references: number;
  93038. private _engine;
  93039. /**
  93040. * Gets the Engine the texture belongs to.
  93041. * @returns The babylon engine
  93042. */
  93043. getEngine(): Engine;
  93044. /**
  93045. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  93046. */
  93047. readonly dataSource: number;
  93048. /**
  93049. * Creates a new InternalTexture
  93050. * @param engine defines the engine to use
  93051. * @param dataSource defines the type of data that will be used
  93052. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93053. */
  93054. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  93055. /**
  93056. * Increments the number of references (ie. the number of Texture that point to it)
  93057. */
  93058. incrementReferences(): void;
  93059. /**
  93060. * Change the size of the texture (not the size of the content)
  93061. * @param width defines the new width
  93062. * @param height defines the new height
  93063. * @param depth defines the new depth (1 by default)
  93064. */
  93065. updateSize(width: int, height: int, depth?: int): void;
  93066. /** @hidden */
  93067. _rebuild(): void;
  93068. /** @hidden */
  93069. _swapAndDie(target: InternalTexture): void;
  93070. /**
  93071. * Dispose the current allocated resources
  93072. */
  93073. dispose(): void;
  93074. }
  93075. }
  93076. declare module BABYLON {
  93077. /**
  93078. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  93079. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  93080. */
  93081. export class EffectFallbacks {
  93082. private _defines;
  93083. private _currentRank;
  93084. private _maxRank;
  93085. private _mesh;
  93086. /**
  93087. * Removes the fallback from the bound mesh.
  93088. */
  93089. unBindMesh(): void;
  93090. /**
  93091. * Adds a fallback on the specified property.
  93092. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93093. * @param define The name of the define in the shader
  93094. */
  93095. addFallback(rank: number, define: string): void;
  93096. /**
  93097. * Sets the mesh to use CPU skinning when needing to fallback.
  93098. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93099. * @param mesh The mesh to use the fallbacks.
  93100. */
  93101. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  93102. /**
  93103. * Checks to see if more fallbacks are still availible.
  93104. */
  93105. readonly hasMoreFallbacks: boolean;
  93106. /**
  93107. * Removes the defines that should be removed when falling back.
  93108. * @param currentDefines defines the current define statements for the shader.
  93109. * @param effect defines the current effect we try to compile
  93110. * @returns The resulting defines with defines of the current rank removed.
  93111. */
  93112. reduce(currentDefines: string, effect: Effect): string;
  93113. }
  93114. /**
  93115. * Options to be used when creating an effect.
  93116. */
  93117. export class EffectCreationOptions {
  93118. /**
  93119. * Atrributes that will be used in the shader.
  93120. */
  93121. attributes: string[];
  93122. /**
  93123. * Uniform varible names that will be set in the shader.
  93124. */
  93125. uniformsNames: string[];
  93126. /**
  93127. * Uniform buffer varible names that will be set in the shader.
  93128. */
  93129. uniformBuffersNames: string[];
  93130. /**
  93131. * Sampler texture variable names that will be set in the shader.
  93132. */
  93133. samplers: string[];
  93134. /**
  93135. * Define statements that will be set in the shader.
  93136. */
  93137. defines: any;
  93138. /**
  93139. * Possible fallbacks for this effect to improve performance when needed.
  93140. */
  93141. fallbacks: Nullable<EffectFallbacks>;
  93142. /**
  93143. * Callback that will be called when the shader is compiled.
  93144. */
  93145. onCompiled: Nullable<(effect: Effect) => void>;
  93146. /**
  93147. * Callback that will be called if an error occurs during shader compilation.
  93148. */
  93149. onError: Nullable<(effect: Effect, errors: string) => void>;
  93150. /**
  93151. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93152. */
  93153. indexParameters: any;
  93154. /**
  93155. * Max number of lights that can be used in the shader.
  93156. */
  93157. maxSimultaneousLights: number;
  93158. /**
  93159. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  93160. */
  93161. transformFeedbackVaryings: Nullable<string[]>;
  93162. }
  93163. /**
  93164. * Effect containing vertex and fragment shader that can be executed on an object.
  93165. */
  93166. export class Effect implements IDisposable {
  93167. /**
  93168. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93169. */
  93170. static ShadersRepository: string;
  93171. /**
  93172. * Name of the effect.
  93173. */
  93174. name: any;
  93175. /**
  93176. * String container all the define statements that should be set on the shader.
  93177. */
  93178. defines: string;
  93179. /**
  93180. * Callback that will be called when the shader is compiled.
  93181. */
  93182. onCompiled: Nullable<(effect: Effect) => void>;
  93183. /**
  93184. * Callback that will be called if an error occurs during shader compilation.
  93185. */
  93186. onError: Nullable<(effect: Effect, errors: string) => void>;
  93187. /**
  93188. * Callback that will be called when effect is bound.
  93189. */
  93190. onBind: Nullable<(effect: Effect) => void>;
  93191. /**
  93192. * Unique ID of the effect.
  93193. */
  93194. uniqueId: number;
  93195. /**
  93196. * Observable that will be called when the shader is compiled.
  93197. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  93198. */
  93199. onCompileObservable: Observable<Effect>;
  93200. /**
  93201. * Observable that will be called if an error occurs during shader compilation.
  93202. */
  93203. onErrorObservable: Observable<Effect>;
  93204. /** @hidden */
  93205. _onBindObservable: Nullable<Observable<Effect>>;
  93206. /**
  93207. * Observable that will be called when effect is bound.
  93208. */
  93209. readonly onBindObservable: Observable<Effect>;
  93210. /** @hidden */
  93211. _bonesComputationForcedToCPU: boolean;
  93212. private static _uniqueIdSeed;
  93213. private _engine;
  93214. private _uniformBuffersNames;
  93215. private _uniformsNames;
  93216. private _samplerList;
  93217. private _samplers;
  93218. private _isReady;
  93219. private _compilationError;
  93220. private _attributesNames;
  93221. private _attributes;
  93222. private _uniforms;
  93223. /**
  93224. * Key for the effect.
  93225. * @hidden
  93226. */
  93227. _key: string;
  93228. private _indexParameters;
  93229. private _fallbacks;
  93230. private _vertexSourceCode;
  93231. private _fragmentSourceCode;
  93232. private _vertexSourceCodeOverride;
  93233. private _fragmentSourceCodeOverride;
  93234. private _transformFeedbackVaryings;
  93235. /**
  93236. * Compiled shader to webGL program.
  93237. * @hidden
  93238. */
  93239. _pipelineContext: Nullable<IPipelineContext>;
  93240. private _valueCache;
  93241. private static _baseCache;
  93242. /**
  93243. * Instantiates an effect.
  93244. * An effect can be used to create/manage/execute vertex and fragment shaders.
  93245. * @param baseName Name of the effect.
  93246. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  93247. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  93248. * @param samplers List of sampler variables that will be passed to the shader.
  93249. * @param engine Engine to be used to render the effect
  93250. * @param defines Define statements to be added to the shader.
  93251. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  93252. * @param onCompiled Callback that will be called when the shader is compiled.
  93253. * @param onError Callback that will be called if an error occurs during shader compilation.
  93254. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93255. */
  93256. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  93257. private _useFinalCode;
  93258. /**
  93259. * Unique key for this effect
  93260. */
  93261. readonly key: string;
  93262. /**
  93263. * If the effect has been compiled and prepared.
  93264. * @returns if the effect is compiled and prepared.
  93265. */
  93266. isReady(): boolean;
  93267. private _isReadyInternal;
  93268. /**
  93269. * The engine the effect was initialized with.
  93270. * @returns the engine.
  93271. */
  93272. getEngine(): Engine;
  93273. /**
  93274. * The pipeline context for this effect
  93275. * @returns the associated pipeline context
  93276. */
  93277. getPipelineContext(): Nullable<IPipelineContext>;
  93278. /**
  93279. * The set of names of attribute variables for the shader.
  93280. * @returns An array of attribute names.
  93281. */
  93282. getAttributesNames(): string[];
  93283. /**
  93284. * Returns the attribute at the given index.
  93285. * @param index The index of the attribute.
  93286. * @returns The location of the attribute.
  93287. */
  93288. getAttributeLocation(index: number): number;
  93289. /**
  93290. * Returns the attribute based on the name of the variable.
  93291. * @param name of the attribute to look up.
  93292. * @returns the attribute location.
  93293. */
  93294. getAttributeLocationByName(name: string): number;
  93295. /**
  93296. * The number of attributes.
  93297. * @returns the numnber of attributes.
  93298. */
  93299. getAttributesCount(): number;
  93300. /**
  93301. * Gets the index of a uniform variable.
  93302. * @param uniformName of the uniform to look up.
  93303. * @returns the index.
  93304. */
  93305. getUniformIndex(uniformName: string): number;
  93306. /**
  93307. * Returns the attribute based on the name of the variable.
  93308. * @param uniformName of the uniform to look up.
  93309. * @returns the location of the uniform.
  93310. */
  93311. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  93312. /**
  93313. * Returns an array of sampler variable names
  93314. * @returns The array of sampler variable neames.
  93315. */
  93316. getSamplers(): string[];
  93317. /**
  93318. * The error from the last compilation.
  93319. * @returns the error string.
  93320. */
  93321. getCompilationError(): string;
  93322. /**
  93323. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  93324. * @param func The callback to be used.
  93325. */
  93326. executeWhenCompiled(func: (effect: Effect) => void): void;
  93327. private _checkIsReady;
  93328. /** @hidden */
  93329. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  93330. /** @hidden */
  93331. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  93332. /** @hidden */
  93333. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  93334. /**
  93335. * Recompiles the webGL program
  93336. * @param vertexSourceCode The source code for the vertex shader.
  93337. * @param fragmentSourceCode The source code for the fragment shader.
  93338. * @param onCompiled Callback called when completed.
  93339. * @param onError Callback called on error.
  93340. * @hidden
  93341. */
  93342. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  93343. /**
  93344. * Prepares the effect
  93345. * @hidden
  93346. */
  93347. _prepareEffect(): void;
  93348. private _processCompilationErrors;
  93349. /**
  93350. * Checks if the effect is supported. (Must be called after compilation)
  93351. */
  93352. readonly isSupported: boolean;
  93353. /**
  93354. * Binds a texture to the engine to be used as output of the shader.
  93355. * @param channel Name of the output variable.
  93356. * @param texture Texture to bind.
  93357. * @hidden
  93358. */
  93359. _bindTexture(channel: string, texture: InternalTexture): void;
  93360. /**
  93361. * Sets a texture on the engine to be used in the shader.
  93362. * @param channel Name of the sampler variable.
  93363. * @param texture Texture to set.
  93364. */
  93365. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  93366. /**
  93367. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  93368. * @param channel Name of the sampler variable.
  93369. * @param texture Texture to set.
  93370. */
  93371. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  93372. /**
  93373. * Sets an array of textures on the engine to be used in the shader.
  93374. * @param channel Name of the variable.
  93375. * @param textures Textures to set.
  93376. */
  93377. setTextureArray(channel: string, textures: BaseTexture[]): void;
  93378. /**
  93379. * 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)
  93380. * @param channel Name of the sampler variable.
  93381. * @param postProcess Post process to get the input texture from.
  93382. */
  93383. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  93384. /**
  93385. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  93386. * 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)
  93387. * @param channel Name of the sampler variable.
  93388. * @param postProcess Post process to get the output texture from.
  93389. */
  93390. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  93391. /** @hidden */
  93392. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  93393. /** @hidden */
  93394. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  93395. /** @hidden */
  93396. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  93397. /** @hidden */
  93398. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  93399. /**
  93400. * Binds a buffer to a uniform.
  93401. * @param buffer Buffer to bind.
  93402. * @param name Name of the uniform variable to bind to.
  93403. */
  93404. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  93405. /**
  93406. * Binds block to a uniform.
  93407. * @param blockName Name of the block to bind.
  93408. * @param index Index to bind.
  93409. */
  93410. bindUniformBlock(blockName: string, index: number): void;
  93411. /**
  93412. * Sets an interger value on a uniform variable.
  93413. * @param uniformName Name of the variable.
  93414. * @param value Value to be set.
  93415. * @returns this effect.
  93416. */
  93417. setInt(uniformName: string, value: number): Effect;
  93418. /**
  93419. * Sets an int array on a uniform variable.
  93420. * @param uniformName Name of the variable.
  93421. * @param array array to be set.
  93422. * @returns this effect.
  93423. */
  93424. setIntArray(uniformName: string, array: Int32Array): Effect;
  93425. /**
  93426. * 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)
  93427. * @param uniformName Name of the variable.
  93428. * @param array array to be set.
  93429. * @returns this effect.
  93430. */
  93431. setIntArray2(uniformName: string, array: Int32Array): Effect;
  93432. /**
  93433. * 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)
  93434. * @param uniformName Name of the variable.
  93435. * @param array array to be set.
  93436. * @returns this effect.
  93437. */
  93438. setIntArray3(uniformName: string, array: Int32Array): Effect;
  93439. /**
  93440. * 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)
  93441. * @param uniformName Name of the variable.
  93442. * @param array array to be set.
  93443. * @returns this effect.
  93444. */
  93445. setIntArray4(uniformName: string, array: Int32Array): Effect;
  93446. /**
  93447. * Sets an float array on a uniform variable.
  93448. * @param uniformName Name of the variable.
  93449. * @param array array to be set.
  93450. * @returns this effect.
  93451. */
  93452. setFloatArray(uniformName: string, array: Float32Array): Effect;
  93453. /**
  93454. * 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)
  93455. * @param uniformName Name of the variable.
  93456. * @param array array to be set.
  93457. * @returns this effect.
  93458. */
  93459. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  93460. /**
  93461. * 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)
  93462. * @param uniformName Name of the variable.
  93463. * @param array array to be set.
  93464. * @returns this effect.
  93465. */
  93466. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  93467. /**
  93468. * 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)
  93469. * @param uniformName Name of the variable.
  93470. * @param array array to be set.
  93471. * @returns this effect.
  93472. */
  93473. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  93474. /**
  93475. * Sets an array on a uniform variable.
  93476. * @param uniformName Name of the variable.
  93477. * @param array array to be set.
  93478. * @returns this effect.
  93479. */
  93480. setArray(uniformName: string, array: number[]): Effect;
  93481. /**
  93482. * 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)
  93483. * @param uniformName Name of the variable.
  93484. * @param array array to be set.
  93485. * @returns this effect.
  93486. */
  93487. setArray2(uniformName: string, array: number[]): Effect;
  93488. /**
  93489. * 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)
  93490. * @param uniformName Name of the variable.
  93491. * @param array array to be set.
  93492. * @returns this effect.
  93493. */
  93494. setArray3(uniformName: string, array: number[]): Effect;
  93495. /**
  93496. * 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)
  93497. * @param uniformName Name of the variable.
  93498. * @param array array to be set.
  93499. * @returns this effect.
  93500. */
  93501. setArray4(uniformName: string, array: number[]): Effect;
  93502. /**
  93503. * Sets matrices on a uniform variable.
  93504. * @param uniformName Name of the variable.
  93505. * @param matrices matrices to be set.
  93506. * @returns this effect.
  93507. */
  93508. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  93509. /**
  93510. * Sets matrix on a uniform variable.
  93511. * @param uniformName Name of the variable.
  93512. * @param matrix matrix to be set.
  93513. * @returns this effect.
  93514. */
  93515. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  93516. /**
  93517. * 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)
  93518. * @param uniformName Name of the variable.
  93519. * @param matrix matrix to be set.
  93520. * @returns this effect.
  93521. */
  93522. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  93523. /**
  93524. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93525. * @param uniformName Name of the variable.
  93526. * @param matrix matrix to be set.
  93527. * @returns this effect.
  93528. */
  93529. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  93530. /**
  93531. * Sets a float on a uniform variable.
  93532. * @param uniformName Name of the variable.
  93533. * @param value value to be set.
  93534. * @returns this effect.
  93535. */
  93536. setFloat(uniformName: string, value: number): Effect;
  93537. /**
  93538. * Sets a boolean on a uniform variable.
  93539. * @param uniformName Name of the variable.
  93540. * @param bool value to be set.
  93541. * @returns this effect.
  93542. */
  93543. setBool(uniformName: string, bool: boolean): Effect;
  93544. /**
  93545. * Sets a Vector2 on a uniform variable.
  93546. * @param uniformName Name of the variable.
  93547. * @param vector2 vector2 to be set.
  93548. * @returns this effect.
  93549. */
  93550. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  93551. /**
  93552. * Sets a float2 on a uniform variable.
  93553. * @param uniformName Name of the variable.
  93554. * @param x First float in float2.
  93555. * @param y Second float in float2.
  93556. * @returns this effect.
  93557. */
  93558. setFloat2(uniformName: string, x: number, y: number): Effect;
  93559. /**
  93560. * Sets a Vector3 on a uniform variable.
  93561. * @param uniformName Name of the variable.
  93562. * @param vector3 Value to be set.
  93563. * @returns this effect.
  93564. */
  93565. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  93566. /**
  93567. * Sets a float3 on a uniform variable.
  93568. * @param uniformName Name of the variable.
  93569. * @param x First float in float3.
  93570. * @param y Second float in float3.
  93571. * @param z Third float in float3.
  93572. * @returns this effect.
  93573. */
  93574. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  93575. /**
  93576. * Sets a Vector4 on a uniform variable.
  93577. * @param uniformName Name of the variable.
  93578. * @param vector4 Value to be set.
  93579. * @returns this effect.
  93580. */
  93581. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  93582. /**
  93583. * Sets a float4 on a uniform variable.
  93584. * @param uniformName Name of the variable.
  93585. * @param x First float in float4.
  93586. * @param y Second float in float4.
  93587. * @param z Third float in float4.
  93588. * @param w Fourth float in float4.
  93589. * @returns this effect.
  93590. */
  93591. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  93592. /**
  93593. * Sets a Color3 on a uniform variable.
  93594. * @param uniformName Name of the variable.
  93595. * @param color3 Value to be set.
  93596. * @returns this effect.
  93597. */
  93598. setColor3(uniformName: string, color3: IColor3Like): Effect;
  93599. /**
  93600. * Sets a Color4 on a uniform variable.
  93601. * @param uniformName Name of the variable.
  93602. * @param color3 Value to be set.
  93603. * @param alpha Alpha value to be set.
  93604. * @returns this effect.
  93605. */
  93606. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  93607. /**
  93608. * Sets a Color4 on a uniform variable
  93609. * @param uniformName defines the name of the variable
  93610. * @param color4 defines the value to be set
  93611. * @returns this effect.
  93612. */
  93613. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  93614. /** Release all associated resources */
  93615. dispose(): void;
  93616. /**
  93617. * This function will add a new shader to the shader store
  93618. * @param name the name of the shader
  93619. * @param pixelShader optional pixel shader content
  93620. * @param vertexShader optional vertex shader content
  93621. */
  93622. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  93623. /**
  93624. * Store of each shader (The can be looked up using effect.key)
  93625. */
  93626. static ShadersStore: {
  93627. [key: string]: string;
  93628. };
  93629. /**
  93630. * Store of each included file for a shader (The can be looked up using effect.key)
  93631. */
  93632. static IncludesShadersStore: {
  93633. [key: string]: string;
  93634. };
  93635. /**
  93636. * Resets the cache of effects.
  93637. */
  93638. static ResetCache(): void;
  93639. }
  93640. }
  93641. declare module BABYLON {
  93642. /**
  93643. * Uniform buffer objects.
  93644. *
  93645. * Handles blocks of uniform on the GPU.
  93646. *
  93647. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93648. *
  93649. * For more information, please refer to :
  93650. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93651. */
  93652. export class UniformBuffer {
  93653. private _engine;
  93654. private _buffer;
  93655. private _data;
  93656. private _bufferData;
  93657. private _dynamic?;
  93658. private _uniformLocations;
  93659. private _uniformSizes;
  93660. private _uniformLocationPointer;
  93661. private _needSync;
  93662. private _noUBO;
  93663. private _currentEffect;
  93664. private static _MAX_UNIFORM_SIZE;
  93665. private static _tempBuffer;
  93666. /**
  93667. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93668. * This is dynamic to allow compat with webgl 1 and 2.
  93669. * You will need to pass the name of the uniform as well as the value.
  93670. */
  93671. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93672. /**
  93673. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93674. * This is dynamic to allow compat with webgl 1 and 2.
  93675. * You will need to pass the name of the uniform as well as the value.
  93676. */
  93677. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93678. /**
  93679. * Lambda to Update a single float in a uniform buffer.
  93680. * This is dynamic to allow compat with webgl 1 and 2.
  93681. * You will need to pass the name of the uniform as well as the value.
  93682. */
  93683. updateFloat: (name: string, x: number) => void;
  93684. /**
  93685. * Lambda to Update a vec2 of float in a uniform buffer.
  93686. * This is dynamic to allow compat with webgl 1 and 2.
  93687. * You will need to pass the name of the uniform as well as the value.
  93688. */
  93689. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93690. /**
  93691. * Lambda to Update a vec3 of float in a uniform buffer.
  93692. * This is dynamic to allow compat with webgl 1 and 2.
  93693. * You will need to pass the name of the uniform as well as the value.
  93694. */
  93695. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93696. /**
  93697. * Lambda to Update a vec4 of float in a uniform buffer.
  93698. * This is dynamic to allow compat with webgl 1 and 2.
  93699. * You will need to pass the name of the uniform as well as the value.
  93700. */
  93701. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93702. /**
  93703. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93704. * This is dynamic to allow compat with webgl 1 and 2.
  93705. * You will need to pass the name of the uniform as well as the value.
  93706. */
  93707. updateMatrix: (name: string, mat: Matrix) => void;
  93708. /**
  93709. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93710. * This is dynamic to allow compat with webgl 1 and 2.
  93711. * You will need to pass the name of the uniform as well as the value.
  93712. */
  93713. updateVector3: (name: string, vector: Vector3) => void;
  93714. /**
  93715. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93716. * This is dynamic to allow compat with webgl 1 and 2.
  93717. * You will need to pass the name of the uniform as well as the value.
  93718. */
  93719. updateVector4: (name: string, vector: Vector4) => void;
  93720. /**
  93721. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93722. * This is dynamic to allow compat with webgl 1 and 2.
  93723. * You will need to pass the name of the uniform as well as the value.
  93724. */
  93725. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93726. /**
  93727. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93728. * This is dynamic to allow compat with webgl 1 and 2.
  93729. * You will need to pass the name of the uniform as well as the value.
  93730. */
  93731. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93732. /**
  93733. * Instantiates a new Uniform buffer objects.
  93734. *
  93735. * Handles blocks of uniform on the GPU.
  93736. *
  93737. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93738. *
  93739. * For more information, please refer to :
  93740. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93741. * @param engine Define the engine the buffer is associated with
  93742. * @param data Define the data contained in the buffer
  93743. * @param dynamic Define if the buffer is updatable
  93744. */
  93745. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  93746. /**
  93747. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93748. * or just falling back on setUniformXXX calls.
  93749. */
  93750. readonly useUbo: boolean;
  93751. /**
  93752. * Indicates if the WebGL underlying uniform buffer is in sync
  93753. * with the javascript cache data.
  93754. */
  93755. readonly isSync: boolean;
  93756. /**
  93757. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93758. * Also, a dynamic UniformBuffer will disable cache verification and always
  93759. * update the underlying WebGL uniform buffer to the GPU.
  93760. * @returns if Dynamic, otherwise false
  93761. */
  93762. isDynamic(): boolean;
  93763. /**
  93764. * The data cache on JS side.
  93765. * @returns the underlying data as a float array
  93766. */
  93767. getData(): Float32Array;
  93768. /**
  93769. * The underlying WebGL Uniform buffer.
  93770. * @returns the webgl buffer
  93771. */
  93772. getBuffer(): Nullable<DataBuffer>;
  93773. /**
  93774. * std140 layout specifies how to align data within an UBO structure.
  93775. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93776. * for specs.
  93777. */
  93778. private _fillAlignment;
  93779. /**
  93780. * Adds an uniform in the buffer.
  93781. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93782. * for the layout to be correct !
  93783. * @param name Name of the uniform, as used in the uniform block in the shader.
  93784. * @param size Data size, or data directly.
  93785. */
  93786. addUniform(name: string, size: number | number[]): void;
  93787. /**
  93788. * Adds a Matrix 4x4 to the uniform buffer.
  93789. * @param name Name of the uniform, as used in the uniform block in the shader.
  93790. * @param mat A 4x4 matrix.
  93791. */
  93792. addMatrix(name: string, mat: Matrix): void;
  93793. /**
  93794. * Adds a vec2 to the uniform buffer.
  93795. * @param name Name of the uniform, as used in the uniform block in the shader.
  93796. * @param x Define the x component value of the vec2
  93797. * @param y Define the y component value of the vec2
  93798. */
  93799. addFloat2(name: string, x: number, y: number): void;
  93800. /**
  93801. * Adds a vec3 to the uniform buffer.
  93802. * @param name Name of the uniform, as used in the uniform block in the shader.
  93803. * @param x Define the x component value of the vec3
  93804. * @param y Define the y component value of the vec3
  93805. * @param z Define the z component value of the vec3
  93806. */
  93807. addFloat3(name: string, x: number, y: number, z: number): void;
  93808. /**
  93809. * Adds a vec3 to the uniform buffer.
  93810. * @param name Name of the uniform, as used in the uniform block in the shader.
  93811. * @param color Define the vec3 from a Color
  93812. */
  93813. addColor3(name: string, color: Color3): void;
  93814. /**
  93815. * Adds a vec4 to the uniform buffer.
  93816. * @param name Name of the uniform, as used in the uniform block in the shader.
  93817. * @param color Define the rgb components from a Color
  93818. * @param alpha Define the a component of the vec4
  93819. */
  93820. addColor4(name: string, color: Color3, alpha: number): void;
  93821. /**
  93822. * Adds a vec3 to the uniform buffer.
  93823. * @param name Name of the uniform, as used in the uniform block in the shader.
  93824. * @param vector Define the vec3 components from a Vector
  93825. */
  93826. addVector3(name: string, vector: Vector3): void;
  93827. /**
  93828. * Adds a Matrix 3x3 to the uniform buffer.
  93829. * @param name Name of the uniform, as used in the uniform block in the shader.
  93830. */
  93831. addMatrix3x3(name: string): void;
  93832. /**
  93833. * Adds a Matrix 2x2 to the uniform buffer.
  93834. * @param name Name of the uniform, as used in the uniform block in the shader.
  93835. */
  93836. addMatrix2x2(name: string): void;
  93837. /**
  93838. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93839. */
  93840. create(): void;
  93841. /** @hidden */
  93842. _rebuild(): void;
  93843. /**
  93844. * Updates the WebGL Uniform Buffer on the GPU.
  93845. * If the `dynamic` flag is set to true, no cache comparison is done.
  93846. * Otherwise, the buffer will be updated only if the cache differs.
  93847. */
  93848. update(): void;
  93849. /**
  93850. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93851. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93852. * @param data Define the flattened data
  93853. * @param size Define the size of the data.
  93854. */
  93855. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93856. private _valueCache;
  93857. private _cacheMatrix;
  93858. private _updateMatrix3x3ForUniform;
  93859. private _updateMatrix3x3ForEffect;
  93860. private _updateMatrix2x2ForEffect;
  93861. private _updateMatrix2x2ForUniform;
  93862. private _updateFloatForEffect;
  93863. private _updateFloatForUniform;
  93864. private _updateFloat2ForEffect;
  93865. private _updateFloat2ForUniform;
  93866. private _updateFloat3ForEffect;
  93867. private _updateFloat3ForUniform;
  93868. private _updateFloat4ForEffect;
  93869. private _updateFloat4ForUniform;
  93870. private _updateMatrixForEffect;
  93871. private _updateMatrixForUniform;
  93872. private _updateVector3ForEffect;
  93873. private _updateVector3ForUniform;
  93874. private _updateVector4ForEffect;
  93875. private _updateVector4ForUniform;
  93876. private _updateColor3ForEffect;
  93877. private _updateColor3ForUniform;
  93878. private _updateColor4ForEffect;
  93879. private _updateColor4ForUniform;
  93880. /**
  93881. * Sets a sampler uniform on the effect.
  93882. * @param name Define the name of the sampler.
  93883. * @param texture Define the texture to set in the sampler
  93884. */
  93885. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93886. /**
  93887. * Directly updates the value of the uniform in the cache AND on the GPU.
  93888. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93889. * @param data Define the flattened data
  93890. */
  93891. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93892. /**
  93893. * Binds this uniform buffer to an effect.
  93894. * @param effect Define the effect to bind the buffer to
  93895. * @param name Name of the uniform block in the shader.
  93896. */
  93897. bindToEffect(effect: Effect, name: string): void;
  93898. /**
  93899. * Disposes the uniform buffer.
  93900. */
  93901. dispose(): void;
  93902. }
  93903. }
  93904. declare module BABYLON {
  93905. /**
  93906. * Class used to work with sound analyzer using fast fourier transform (FFT)
  93907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93908. */
  93909. export class Analyser {
  93910. /**
  93911. * Gets or sets the smoothing
  93912. * @ignorenaming
  93913. */
  93914. SMOOTHING: number;
  93915. /**
  93916. * Gets or sets the FFT table size
  93917. * @ignorenaming
  93918. */
  93919. FFT_SIZE: number;
  93920. /**
  93921. * Gets or sets the bar graph amplitude
  93922. * @ignorenaming
  93923. */
  93924. BARGRAPHAMPLITUDE: number;
  93925. /**
  93926. * Gets or sets the position of the debug canvas
  93927. * @ignorenaming
  93928. */
  93929. DEBUGCANVASPOS: {
  93930. x: number;
  93931. y: number;
  93932. };
  93933. /**
  93934. * Gets or sets the debug canvas size
  93935. * @ignorenaming
  93936. */
  93937. DEBUGCANVASSIZE: {
  93938. width: number;
  93939. height: number;
  93940. };
  93941. private _byteFreqs;
  93942. private _byteTime;
  93943. private _floatFreqs;
  93944. private _webAudioAnalyser;
  93945. private _debugCanvas;
  93946. private _debugCanvasContext;
  93947. private _scene;
  93948. private _registerFunc;
  93949. private _audioEngine;
  93950. /**
  93951. * Creates a new analyser
  93952. * @param scene defines hosting scene
  93953. */
  93954. constructor(scene: Scene);
  93955. /**
  93956. * Get the number of data values you will have to play with for the visualization
  93957. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  93958. * @returns a number
  93959. */
  93960. getFrequencyBinCount(): number;
  93961. /**
  93962. * Gets the current frequency data as a byte array
  93963. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93964. * @returns a Uint8Array
  93965. */
  93966. getByteFrequencyData(): Uint8Array;
  93967. /**
  93968. * Gets the current waveform as a byte array
  93969. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  93970. * @returns a Uint8Array
  93971. */
  93972. getByteTimeDomainData(): Uint8Array;
  93973. /**
  93974. * Gets the current frequency data as a float array
  93975. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93976. * @returns a Float32Array
  93977. */
  93978. getFloatFrequencyData(): Float32Array;
  93979. /**
  93980. * Renders the debug canvas
  93981. */
  93982. drawDebugCanvas(): void;
  93983. /**
  93984. * Stops rendering the debug canvas and removes it
  93985. */
  93986. stopDebugCanvas(): void;
  93987. /**
  93988. * Connects two audio nodes
  93989. * @param inputAudioNode defines first node to connect
  93990. * @param outputAudioNode defines second node to connect
  93991. */
  93992. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  93993. /**
  93994. * Releases all associated resources
  93995. */
  93996. dispose(): void;
  93997. }
  93998. }
  93999. declare module BABYLON {
  94000. /**
  94001. * This represents an audio engine and it is responsible
  94002. * to play, synchronize and analyse sounds throughout the application.
  94003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94004. */
  94005. export interface IAudioEngine extends IDisposable {
  94006. /**
  94007. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94008. */
  94009. readonly canUseWebAudio: boolean;
  94010. /**
  94011. * Gets the current AudioContext if available.
  94012. */
  94013. readonly audioContext: Nullable<AudioContext>;
  94014. /**
  94015. * The master gain node defines the global audio volume of your audio engine.
  94016. */
  94017. readonly masterGain: GainNode;
  94018. /**
  94019. * Gets whether or not mp3 are supported by your browser.
  94020. */
  94021. readonly isMP3supported: boolean;
  94022. /**
  94023. * Gets whether or not ogg are supported by your browser.
  94024. */
  94025. readonly isOGGsupported: boolean;
  94026. /**
  94027. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94028. * @ignoreNaming
  94029. */
  94030. WarnedWebAudioUnsupported: boolean;
  94031. /**
  94032. * Defines if the audio engine relies on a custom unlocked button.
  94033. * In this case, the embedded button will not be displayed.
  94034. */
  94035. useCustomUnlockedButton: boolean;
  94036. /**
  94037. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  94038. */
  94039. readonly unlocked: boolean;
  94040. /**
  94041. * Event raised when audio has been unlocked on the browser.
  94042. */
  94043. onAudioUnlockedObservable: Observable<AudioEngine>;
  94044. /**
  94045. * Event raised when audio has been locked on the browser.
  94046. */
  94047. onAudioLockedObservable: Observable<AudioEngine>;
  94048. /**
  94049. * Flags the audio engine in Locked state.
  94050. * This happens due to new browser policies preventing audio to autoplay.
  94051. */
  94052. lock(): void;
  94053. /**
  94054. * Unlocks the audio engine once a user action has been done on the dom.
  94055. * This is helpful to resume play once browser policies have been satisfied.
  94056. */
  94057. unlock(): void;
  94058. }
  94059. /**
  94060. * This represents the default audio engine used in babylon.
  94061. * It is responsible to play, synchronize and analyse sounds throughout the application.
  94062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94063. */
  94064. export class AudioEngine implements IAudioEngine {
  94065. private _audioContext;
  94066. private _audioContextInitialized;
  94067. private _muteButton;
  94068. private _hostElement;
  94069. /**
  94070. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94071. */
  94072. canUseWebAudio: boolean;
  94073. /**
  94074. * The master gain node defines the global audio volume of your audio engine.
  94075. */
  94076. masterGain: GainNode;
  94077. /**
  94078. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94079. * @ignoreNaming
  94080. */
  94081. WarnedWebAudioUnsupported: boolean;
  94082. /**
  94083. * Gets whether or not mp3 are supported by your browser.
  94084. */
  94085. isMP3supported: boolean;
  94086. /**
  94087. * Gets whether or not ogg are supported by your browser.
  94088. */
  94089. isOGGsupported: boolean;
  94090. /**
  94091. * Gets whether audio has been unlocked on the device.
  94092. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  94093. * a user interaction has happened.
  94094. */
  94095. unlocked: boolean;
  94096. /**
  94097. * Defines if the audio engine relies on a custom unlocked button.
  94098. * In this case, the embedded button will not be displayed.
  94099. */
  94100. useCustomUnlockedButton: boolean;
  94101. /**
  94102. * Event raised when audio has been unlocked on the browser.
  94103. */
  94104. onAudioUnlockedObservable: Observable<AudioEngine>;
  94105. /**
  94106. * Event raised when audio has been locked on the browser.
  94107. */
  94108. onAudioLockedObservable: Observable<AudioEngine>;
  94109. /**
  94110. * Gets the current AudioContext if available.
  94111. */
  94112. readonly audioContext: Nullable<AudioContext>;
  94113. private _connectedAnalyser;
  94114. /**
  94115. * Instantiates a new audio engine.
  94116. *
  94117. * There should be only one per page as some browsers restrict the number
  94118. * of audio contexts you can create.
  94119. * @param hostElement defines the host element where to display the mute icon if necessary
  94120. */
  94121. constructor(hostElement?: Nullable<HTMLElement>);
  94122. /**
  94123. * Flags the audio engine in Locked state.
  94124. * This happens due to new browser policies preventing audio to autoplay.
  94125. */
  94126. lock(): void;
  94127. /**
  94128. * Unlocks the audio engine once a user action has been done on the dom.
  94129. * This is helpful to resume play once browser policies have been satisfied.
  94130. */
  94131. unlock(): void;
  94132. private _resumeAudioContext;
  94133. private _initializeAudioContext;
  94134. private _tryToRun;
  94135. private _triggerRunningState;
  94136. private _triggerSuspendedState;
  94137. private _displayMuteButton;
  94138. private _moveButtonToTopLeft;
  94139. private _onResize;
  94140. private _hideMuteButton;
  94141. /**
  94142. * Destroy and release the resources associated with the audio ccontext.
  94143. */
  94144. dispose(): void;
  94145. /**
  94146. * Gets the global volume sets on the master gain.
  94147. * @returns the global volume if set or -1 otherwise
  94148. */
  94149. getGlobalVolume(): number;
  94150. /**
  94151. * Sets the global volume of your experience (sets on the master gain).
  94152. * @param newVolume Defines the new global volume of the application
  94153. */
  94154. setGlobalVolume(newVolume: number): void;
  94155. /**
  94156. * Connect the audio engine to an audio analyser allowing some amazing
  94157. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94159. * @param analyser The analyser to connect to the engine
  94160. */
  94161. connectToAnalyser(analyser: Analyser): void;
  94162. }
  94163. }
  94164. declare module BABYLON {
  94165. /**
  94166. * Interface used to present a loading screen while loading a scene
  94167. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94168. */
  94169. export interface ILoadingScreen {
  94170. /**
  94171. * Function called to display the loading screen
  94172. */
  94173. displayLoadingUI: () => void;
  94174. /**
  94175. * Function called to hide the loading screen
  94176. */
  94177. hideLoadingUI: () => void;
  94178. /**
  94179. * Gets or sets the color to use for the background
  94180. */
  94181. loadingUIBackgroundColor: string;
  94182. /**
  94183. * Gets or sets the text to display while loading
  94184. */
  94185. loadingUIText: string;
  94186. }
  94187. /**
  94188. * Class used for the default loading screen
  94189. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94190. */
  94191. export class DefaultLoadingScreen implements ILoadingScreen {
  94192. private _renderingCanvas;
  94193. private _loadingText;
  94194. private _loadingDivBackgroundColor;
  94195. private _loadingDiv;
  94196. private _loadingTextDiv;
  94197. /** Gets or sets the logo url to use for the default loading screen */
  94198. static DefaultLogoUrl: string;
  94199. /** Gets or sets the spinner url to use for the default loading screen */
  94200. static DefaultSpinnerUrl: string;
  94201. /**
  94202. * Creates a new default loading screen
  94203. * @param _renderingCanvas defines the canvas used to render the scene
  94204. * @param _loadingText defines the default text to display
  94205. * @param _loadingDivBackgroundColor defines the default background color
  94206. */
  94207. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  94208. /**
  94209. * Function called to display the loading screen
  94210. */
  94211. displayLoadingUI(): void;
  94212. /**
  94213. * Function called to hide the loading screen
  94214. */
  94215. hideLoadingUI(): void;
  94216. /**
  94217. * Gets or sets the text to display while loading
  94218. */
  94219. loadingUIText: string;
  94220. /**
  94221. * Gets or sets the color to use for the background
  94222. */
  94223. loadingUIBackgroundColor: string;
  94224. private _resizeLoadingUI;
  94225. }
  94226. }
  94227. declare module BABYLON {
  94228. /** @hidden */
  94229. export class WebGLPipelineContext implements IPipelineContext {
  94230. engine: Engine;
  94231. program: Nullable<WebGLProgram>;
  94232. context?: WebGLRenderingContext;
  94233. vertexShader?: WebGLShader;
  94234. fragmentShader?: WebGLShader;
  94235. isParallelCompiled: boolean;
  94236. onCompiled?: () => void;
  94237. transformFeedback?: WebGLTransformFeedback | null;
  94238. readonly isAsync: boolean;
  94239. readonly isReady: boolean;
  94240. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  94241. }
  94242. }
  94243. declare module BABYLON {
  94244. /** @hidden */
  94245. export class WebGLDataBuffer extends DataBuffer {
  94246. private _buffer;
  94247. constructor(resource: WebGLBuffer);
  94248. readonly underlyingResource: any;
  94249. }
  94250. }
  94251. declare module BABYLON {
  94252. /** @hidden */
  94253. export class WebGL2ShaderProcessor implements IShaderProcessor {
  94254. attributeProcessor(attribute: string): string;
  94255. varyingProcessor(varying: string, isFragment: boolean): string;
  94256. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  94257. }
  94258. }
  94259. declare module BABYLON {
  94260. /**
  94261. * This class is used to track a performance counter which is number based.
  94262. * The user has access to many properties which give statistics of different nature.
  94263. *
  94264. * The implementer can track two kinds of Performance Counter: time and count.
  94265. * 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.
  94266. * 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.
  94267. */
  94268. export class PerfCounter {
  94269. /**
  94270. * Gets or sets a global boolean to turn on and off all the counters
  94271. */
  94272. static Enabled: boolean;
  94273. /**
  94274. * Returns the smallest value ever
  94275. */
  94276. readonly min: number;
  94277. /**
  94278. * Returns the biggest value ever
  94279. */
  94280. readonly max: number;
  94281. /**
  94282. * Returns the average value since the performance counter is running
  94283. */
  94284. readonly average: number;
  94285. /**
  94286. * Returns the average value of the last second the counter was monitored
  94287. */
  94288. readonly lastSecAverage: number;
  94289. /**
  94290. * Returns the current value
  94291. */
  94292. readonly current: number;
  94293. /**
  94294. * Gets the accumulated total
  94295. */
  94296. readonly total: number;
  94297. /**
  94298. * Gets the total value count
  94299. */
  94300. readonly count: number;
  94301. /**
  94302. * Creates a new counter
  94303. */
  94304. constructor();
  94305. /**
  94306. * Call this method to start monitoring a new frame.
  94307. * 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.
  94308. */
  94309. fetchNewFrame(): void;
  94310. /**
  94311. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94312. * @param newCount the count value to add to the monitored count
  94313. * @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.
  94314. */
  94315. addCount(newCount: number, fetchResult: boolean): void;
  94316. /**
  94317. * Start monitoring this performance counter
  94318. */
  94319. beginMonitoring(): void;
  94320. /**
  94321. * Compute the time lapsed since the previous beginMonitoring() call.
  94322. * @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
  94323. */
  94324. endMonitoring(newFrame?: boolean): void;
  94325. private _fetchResult;
  94326. private _startMonitoringTime;
  94327. private _min;
  94328. private _max;
  94329. private _average;
  94330. private _current;
  94331. private _totalValueCount;
  94332. private _totalAccumulated;
  94333. private _lastSecAverage;
  94334. private _lastSecAccumulated;
  94335. private _lastSecTime;
  94336. private _lastSecValueCount;
  94337. }
  94338. }
  94339. declare module BABYLON {
  94340. /**
  94341. * Interface for any object that can request an animation frame
  94342. */
  94343. export interface ICustomAnimationFrameRequester {
  94344. /**
  94345. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  94346. */
  94347. renderFunction?: Function;
  94348. /**
  94349. * Called to request the next frame to render to
  94350. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  94351. */
  94352. requestAnimationFrame: Function;
  94353. /**
  94354. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  94355. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  94356. */
  94357. requestID?: number;
  94358. }
  94359. }
  94360. declare module BABYLON {
  94361. /**
  94362. * Settings for finer control over video usage
  94363. */
  94364. export interface VideoTextureSettings {
  94365. /**
  94366. * Applies `autoplay` to video, if specified
  94367. */
  94368. autoPlay?: boolean;
  94369. /**
  94370. * Applies `loop` to video, if specified
  94371. */
  94372. loop?: boolean;
  94373. /**
  94374. * Automatically updates internal texture from video at every frame in the render loop
  94375. */
  94376. autoUpdateTexture: boolean;
  94377. /**
  94378. * Image src displayed during the video loading or until the user interacts with the video.
  94379. */
  94380. poster?: string;
  94381. }
  94382. /**
  94383. * If you want to display a video in your scene, this is the special texture for that.
  94384. * This special texture works similar to other textures, with the exception of a few parameters.
  94385. * @see https://doc.babylonjs.com/how_to/video_texture
  94386. */
  94387. export class VideoTexture extends Texture {
  94388. /**
  94389. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  94390. */
  94391. readonly autoUpdateTexture: boolean;
  94392. /**
  94393. * The video instance used by the texture internally
  94394. */
  94395. readonly video: HTMLVideoElement;
  94396. private _onUserActionRequestedObservable;
  94397. /**
  94398. * Event triggerd when a dom action is required by the user to play the video.
  94399. * This happens due to recent changes in browser policies preventing video to auto start.
  94400. */
  94401. readonly onUserActionRequestedObservable: Observable<Texture>;
  94402. private _generateMipMaps;
  94403. private _engine;
  94404. private _stillImageCaptured;
  94405. private _displayingPosterTexture;
  94406. private _settings;
  94407. private _createInternalTextureOnEvent;
  94408. /**
  94409. * Creates a video texture.
  94410. * If you want to display a video in your scene, this is the special texture for that.
  94411. * This special texture works similar to other textures, with the exception of a few parameters.
  94412. * @see https://doc.babylonjs.com/how_to/video_texture
  94413. * @param name optional name, will detect from video source, if not defined
  94414. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  94415. * @param scene is obviously the current scene.
  94416. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  94417. * @param invertY is false by default but can be used to invert video on Y axis
  94418. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  94419. * @param settings allows finer control over video usage
  94420. */
  94421. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  94422. private _getName;
  94423. private _getVideo;
  94424. private _createInternalTexture;
  94425. private reset;
  94426. /**
  94427. * @hidden Internal method to initiate `update`.
  94428. */
  94429. _rebuild(): void;
  94430. /**
  94431. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  94432. */
  94433. update(): void;
  94434. /**
  94435. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  94436. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  94437. */
  94438. updateTexture(isVisible: boolean): void;
  94439. protected _updateInternalTexture: () => void;
  94440. /**
  94441. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  94442. * @param url New url.
  94443. */
  94444. updateURL(url: string): void;
  94445. /**
  94446. * Dispose the texture and release its associated resources.
  94447. */
  94448. dispose(): void;
  94449. /**
  94450. * Creates a video texture straight from a stream.
  94451. * @param scene Define the scene the texture should be created in
  94452. * @param stream Define the stream the texture should be created from
  94453. * @returns The created video texture as a promise
  94454. */
  94455. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  94456. /**
  94457. * Creates a video texture straight from your WebCam video feed.
  94458. * @param scene Define the scene the texture should be created in
  94459. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94460. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94461. * @returns The created video texture as a promise
  94462. */
  94463. static CreateFromWebCamAsync(scene: Scene, constraints: {
  94464. minWidth: number;
  94465. maxWidth: number;
  94466. minHeight: number;
  94467. maxHeight: number;
  94468. deviceId: string;
  94469. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  94470. /**
  94471. * Creates a video texture straight from your WebCam video feed.
  94472. * @param scene Define the scene the texture should be created in
  94473. * @param onReady Define a callback to triggered once the texture will be ready
  94474. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94475. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94476. */
  94477. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  94478. minWidth: number;
  94479. maxWidth: number;
  94480. minHeight: number;
  94481. maxHeight: number;
  94482. deviceId: string;
  94483. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  94484. }
  94485. }
  94486. declare module BABYLON {
  94487. /**
  94488. * Defines the interface used by objects containing a viewport (like a camera)
  94489. */
  94490. interface IViewportOwnerLike {
  94491. /**
  94492. * Gets or sets the viewport
  94493. */
  94494. viewport: IViewportLike;
  94495. }
  94496. /**
  94497. * Interface for attribute information associated with buffer instanciation
  94498. */
  94499. export class InstancingAttributeInfo {
  94500. /**
  94501. * Index/offset of the attribute in the vertex shader
  94502. */
  94503. index: number;
  94504. /**
  94505. * size of the attribute, 1, 2, 3 or 4
  94506. */
  94507. attributeSize: number;
  94508. /**
  94509. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  94510. * default is FLOAT
  94511. */
  94512. attribyteType: number;
  94513. /**
  94514. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  94515. */
  94516. normalized: boolean;
  94517. /**
  94518. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  94519. */
  94520. offset: number;
  94521. /**
  94522. * Name of the GLSL attribute, for debugging purpose only
  94523. */
  94524. attributeName: string;
  94525. }
  94526. /**
  94527. * Define options used to create a depth texture
  94528. */
  94529. export class DepthTextureCreationOptions {
  94530. /** Specifies whether or not a stencil should be allocated in the texture */
  94531. generateStencil?: boolean;
  94532. /** Specifies whether or not bilinear filtering is enable on the texture */
  94533. bilinearFiltering?: boolean;
  94534. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  94535. comparisonFunction?: number;
  94536. /** Specifies if the created texture is a cube texture */
  94537. isCube?: boolean;
  94538. }
  94539. /**
  94540. * Class used to describe the capabilities of the engine relatively to the current browser
  94541. */
  94542. export class EngineCapabilities {
  94543. /** Maximum textures units per fragment shader */
  94544. maxTexturesImageUnits: number;
  94545. /** Maximum texture units per vertex shader */
  94546. maxVertexTextureImageUnits: number;
  94547. /** Maximum textures units in the entire pipeline */
  94548. maxCombinedTexturesImageUnits: number;
  94549. /** Maximum texture size */
  94550. maxTextureSize: number;
  94551. /** Maximum cube texture size */
  94552. maxCubemapTextureSize: number;
  94553. /** Maximum render texture size */
  94554. maxRenderTextureSize: number;
  94555. /** Maximum number of vertex attributes */
  94556. maxVertexAttribs: number;
  94557. /** Maximum number of varyings */
  94558. maxVaryingVectors: number;
  94559. /** Maximum number of uniforms per vertex shader */
  94560. maxVertexUniformVectors: number;
  94561. /** Maximum number of uniforms per fragment shader */
  94562. maxFragmentUniformVectors: number;
  94563. /** Defines if standard derivates (dx/dy) are supported */
  94564. standardDerivatives: boolean;
  94565. /** Defines if s3tc texture compression is supported */
  94566. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  94567. /** Defines if pvrtc texture compression is supported */
  94568. pvrtc: any;
  94569. /** Defines if etc1 texture compression is supported */
  94570. etc1: any;
  94571. /** Defines if etc2 texture compression is supported */
  94572. etc2: any;
  94573. /** Defines if astc texture compression is supported */
  94574. astc: any;
  94575. /** Defines if float textures are supported */
  94576. textureFloat: boolean;
  94577. /** Defines if vertex array objects are supported */
  94578. vertexArrayObject: boolean;
  94579. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  94580. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  94581. /** Gets the maximum level of anisotropy supported */
  94582. maxAnisotropy: number;
  94583. /** Defines if instancing is supported */
  94584. instancedArrays: boolean;
  94585. /** Defines if 32 bits indices are supported */
  94586. uintIndices: boolean;
  94587. /** Defines if high precision shaders are supported */
  94588. highPrecisionShaderSupported: boolean;
  94589. /** Defines if depth reading in the fragment shader is supported */
  94590. fragmentDepthSupported: boolean;
  94591. /** Defines if float texture linear filtering is supported*/
  94592. textureFloatLinearFiltering: boolean;
  94593. /** Defines if rendering to float textures is supported */
  94594. textureFloatRender: boolean;
  94595. /** Defines if half float textures are supported*/
  94596. textureHalfFloat: boolean;
  94597. /** Defines if half float texture linear filtering is supported*/
  94598. textureHalfFloatLinearFiltering: boolean;
  94599. /** Defines if rendering to half float textures is supported */
  94600. textureHalfFloatRender: boolean;
  94601. /** Defines if textureLOD shader command is supported */
  94602. textureLOD: boolean;
  94603. /** Defines if draw buffers extension is supported */
  94604. drawBuffersExtension: boolean;
  94605. /** Defines if depth textures are supported */
  94606. depthTextureExtension: boolean;
  94607. /** Defines if float color buffer are supported */
  94608. colorBufferFloat: boolean;
  94609. /** Gets disjoint timer query extension (null if not supported) */
  94610. timerQuery: EXT_disjoint_timer_query;
  94611. /** Defines if timestamp can be used with timer query */
  94612. canUseTimestampForTimerQuery: boolean;
  94613. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  94614. multiview: any;
  94615. /** Function used to let the system compiles shaders in background */
  94616. parallelShaderCompile: {
  94617. COMPLETION_STATUS_KHR: number;
  94618. };
  94619. /** Max number of texture samples for MSAA */
  94620. maxMSAASamples: number;
  94621. }
  94622. /** Interface defining initialization parameters for Engine class */
  94623. export interface EngineOptions extends WebGLContextAttributes {
  94624. /**
  94625. * Defines if the engine should no exceed a specified device ratio
  94626. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  94627. */
  94628. limitDeviceRatio?: number;
  94629. /**
  94630. * Defines if webvr should be enabled automatically
  94631. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94632. */
  94633. autoEnableWebVR?: boolean;
  94634. /**
  94635. * Defines if webgl2 should be turned off even if supported
  94636. * @see http://doc.babylonjs.com/features/webgl2
  94637. */
  94638. disableWebGL2Support?: boolean;
  94639. /**
  94640. * Defines if webaudio should be initialized as well
  94641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94642. */
  94643. audioEngine?: boolean;
  94644. /**
  94645. * Defines if animations should run using a deterministic lock step
  94646. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94647. */
  94648. deterministicLockstep?: boolean;
  94649. /** Defines the maximum steps to use with deterministic lock step mode */
  94650. lockstepMaxSteps?: number;
  94651. /**
  94652. * Defines that engine should ignore context lost events
  94653. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  94654. */
  94655. doNotHandleContextLost?: boolean;
  94656. /**
  94657. * Defines that engine should ignore modifying touch action attribute and style
  94658. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  94659. */
  94660. doNotHandleTouchAction?: boolean;
  94661. /**
  94662. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  94663. */
  94664. useHighPrecisionFloats?: boolean;
  94665. }
  94666. /**
  94667. * Defines the interface used by display changed events
  94668. */
  94669. export interface IDisplayChangedEventArgs {
  94670. /** Gets the vrDisplay object (if any) */
  94671. vrDisplay: Nullable<any>;
  94672. /** Gets a boolean indicating if webVR is supported */
  94673. vrSupported: boolean;
  94674. }
  94675. /**
  94676. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  94677. */
  94678. export class Engine {
  94679. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  94680. static ExceptionList: ({
  94681. key: string;
  94682. capture: string;
  94683. captureConstraint: number;
  94684. targets: string[];
  94685. } | {
  94686. key: string;
  94687. capture: null;
  94688. captureConstraint: null;
  94689. targets: string[];
  94690. })[];
  94691. /** Gets the list of created engines */
  94692. static readonly Instances: Engine[];
  94693. /**
  94694. * Gets the latest created engine
  94695. */
  94696. static readonly LastCreatedEngine: Nullable<Engine>;
  94697. /**
  94698. * Gets the latest created scene
  94699. */
  94700. static readonly LastCreatedScene: Nullable<Scene>;
  94701. /**
  94702. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  94703. * @param flag defines which part of the materials must be marked as dirty
  94704. * @param predicate defines a predicate used to filter which materials should be affected
  94705. */
  94706. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  94707. /** @hidden */
  94708. static _TextureLoaders: IInternalTextureLoader[];
  94709. /** Defines that alpha blending is disabled */
  94710. static readonly ALPHA_DISABLE: number;
  94711. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  94712. static readonly ALPHA_ADD: number;
  94713. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  94714. static readonly ALPHA_COMBINE: number;
  94715. /** Defines that alpha blending to DEST - SRC * DEST */
  94716. static readonly ALPHA_SUBTRACT: number;
  94717. /** Defines that alpha blending to SRC * DEST */
  94718. static readonly ALPHA_MULTIPLY: number;
  94719. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  94720. static readonly ALPHA_MAXIMIZED: number;
  94721. /** Defines that alpha blending to SRC + DEST */
  94722. static readonly ALPHA_ONEONE: number;
  94723. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  94724. static readonly ALPHA_PREMULTIPLIED: number;
  94725. /**
  94726. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  94727. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  94728. */
  94729. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  94730. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  94731. static readonly ALPHA_INTERPOLATE: number;
  94732. /**
  94733. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  94734. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  94735. */
  94736. static readonly ALPHA_SCREENMODE: number;
  94737. /** Defines that the ressource is not delayed*/
  94738. static readonly DELAYLOADSTATE_NONE: number;
  94739. /** Defines that the ressource was successfully delay loaded */
  94740. static readonly DELAYLOADSTATE_LOADED: number;
  94741. /** Defines that the ressource is currently delay loading */
  94742. static readonly DELAYLOADSTATE_LOADING: number;
  94743. /** Defines that the ressource is delayed and has not started loading */
  94744. static readonly DELAYLOADSTATE_NOTLOADED: number;
  94745. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  94746. static readonly NEVER: number;
  94747. /** 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 */
  94748. static readonly ALWAYS: number;
  94749. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  94750. static readonly LESS: number;
  94751. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  94752. static readonly EQUAL: number;
  94753. /** 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 */
  94754. static readonly LEQUAL: number;
  94755. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  94756. static readonly GREATER: number;
  94757. /** 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 */
  94758. static readonly GEQUAL: number;
  94759. /** 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 */
  94760. static readonly NOTEQUAL: number;
  94761. /** Passed to stencilOperation to specify that stencil value must be kept */
  94762. static readonly KEEP: number;
  94763. /** Passed to stencilOperation to specify that stencil value must be replaced */
  94764. static readonly REPLACE: number;
  94765. /** Passed to stencilOperation to specify that stencil value must be incremented */
  94766. static readonly INCR: number;
  94767. /** Passed to stencilOperation to specify that stencil value must be decremented */
  94768. static readonly DECR: number;
  94769. /** Passed to stencilOperation to specify that stencil value must be inverted */
  94770. static readonly INVERT: number;
  94771. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  94772. static readonly INCR_WRAP: number;
  94773. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  94774. static readonly DECR_WRAP: number;
  94775. /** Texture is not repeating outside of 0..1 UVs */
  94776. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  94777. /** Texture is repeating outside of 0..1 UVs */
  94778. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  94779. /** Texture is repeating and mirrored */
  94780. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  94781. /** ALPHA */
  94782. static readonly TEXTUREFORMAT_ALPHA: number;
  94783. /** LUMINANCE */
  94784. static readonly TEXTUREFORMAT_LUMINANCE: number;
  94785. /** LUMINANCE_ALPHA */
  94786. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94787. /** RGB */
  94788. static readonly TEXTUREFORMAT_RGB: number;
  94789. /** RGBA */
  94790. static readonly TEXTUREFORMAT_RGBA: number;
  94791. /** RED */
  94792. static readonly TEXTUREFORMAT_RED: number;
  94793. /** RED (2nd reference) */
  94794. static readonly TEXTUREFORMAT_R: number;
  94795. /** RG */
  94796. static readonly TEXTUREFORMAT_RG: number;
  94797. /** RED_INTEGER */
  94798. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94799. /** RED_INTEGER (2nd reference) */
  94800. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94801. /** RG_INTEGER */
  94802. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94803. /** RGB_INTEGER */
  94804. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94805. /** RGBA_INTEGER */
  94806. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94807. /** UNSIGNED_BYTE */
  94808. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94809. /** UNSIGNED_BYTE (2nd reference) */
  94810. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94811. /** FLOAT */
  94812. static readonly TEXTURETYPE_FLOAT: number;
  94813. /** HALF_FLOAT */
  94814. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94815. /** BYTE */
  94816. static readonly TEXTURETYPE_BYTE: number;
  94817. /** SHORT */
  94818. static readonly TEXTURETYPE_SHORT: number;
  94819. /** UNSIGNED_SHORT */
  94820. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94821. /** INT */
  94822. static readonly TEXTURETYPE_INT: number;
  94823. /** UNSIGNED_INT */
  94824. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94825. /** UNSIGNED_SHORT_4_4_4_4 */
  94826. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94827. /** UNSIGNED_SHORT_5_5_5_1 */
  94828. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94829. /** UNSIGNED_SHORT_5_6_5 */
  94830. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94831. /** UNSIGNED_INT_2_10_10_10_REV */
  94832. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94833. /** UNSIGNED_INT_24_8 */
  94834. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94835. /** UNSIGNED_INT_10F_11F_11F_REV */
  94836. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94837. /** UNSIGNED_INT_5_9_9_9_REV */
  94838. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94839. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94840. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94841. /** nearest is mag = nearest and min = nearest and mip = linear */
  94842. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94843. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94844. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94845. /** Trilinear is mag = linear and min = linear and mip = linear */
  94846. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94847. /** nearest is mag = nearest and min = nearest and mip = linear */
  94848. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94849. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94850. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  94851. /** Trilinear is mag = linear and min = linear and mip = linear */
  94852. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  94853. /** mag = nearest and min = nearest and mip = nearest */
  94854. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  94855. /** mag = nearest and min = linear and mip = nearest */
  94856. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  94857. /** mag = nearest and min = linear and mip = linear */
  94858. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  94859. /** mag = nearest and min = linear and mip = none */
  94860. static readonly TEXTURE_NEAREST_LINEAR: number;
  94861. /** mag = nearest and min = nearest and mip = none */
  94862. static readonly TEXTURE_NEAREST_NEAREST: number;
  94863. /** mag = linear and min = nearest and mip = nearest */
  94864. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  94865. /** mag = linear and min = nearest and mip = linear */
  94866. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  94867. /** mag = linear and min = linear and mip = none */
  94868. static readonly TEXTURE_LINEAR_LINEAR: number;
  94869. /** mag = linear and min = nearest and mip = none */
  94870. static readonly TEXTURE_LINEAR_NEAREST: number;
  94871. /** Explicit coordinates mode */
  94872. static readonly TEXTURE_EXPLICIT_MODE: number;
  94873. /** Spherical coordinates mode */
  94874. static readonly TEXTURE_SPHERICAL_MODE: number;
  94875. /** Planar coordinates mode */
  94876. static readonly TEXTURE_PLANAR_MODE: number;
  94877. /** Cubic coordinates mode */
  94878. static readonly TEXTURE_CUBIC_MODE: number;
  94879. /** Projection coordinates mode */
  94880. static readonly TEXTURE_PROJECTION_MODE: number;
  94881. /** Skybox coordinates mode */
  94882. static readonly TEXTURE_SKYBOX_MODE: number;
  94883. /** Inverse Cubic coordinates mode */
  94884. static readonly TEXTURE_INVCUBIC_MODE: number;
  94885. /** Equirectangular coordinates mode */
  94886. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  94887. /** Equirectangular Fixed coordinates mode */
  94888. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  94889. /** Equirectangular Fixed Mirrored coordinates mode */
  94890. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94891. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  94892. static readonly SCALEMODE_FLOOR: number;
  94893. /** Defines that texture rescaling will look for the nearest power of 2 size */
  94894. static readonly SCALEMODE_NEAREST: number;
  94895. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  94896. static readonly SCALEMODE_CEILING: number;
  94897. /**
  94898. * Returns the current npm package of the sdk
  94899. */
  94900. static readonly NpmPackage: string;
  94901. /**
  94902. * Returns the current version of the framework
  94903. */
  94904. static readonly Version: string;
  94905. /**
  94906. * Returns a string describing the current engine
  94907. */
  94908. readonly description: string;
  94909. /**
  94910. * Gets or sets the epsilon value used by collision engine
  94911. */
  94912. static CollisionsEpsilon: number;
  94913. /**
  94914. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94915. */
  94916. static ShadersRepository: string;
  94917. /**
  94918. * Method called to create the default loading screen.
  94919. * This can be overriden in your own app.
  94920. * @param canvas The rendering canvas element
  94921. * @returns The loading screen
  94922. */
  94923. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  94924. /**
  94925. * Method called to create the default rescale post process on each engine.
  94926. */
  94927. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  94928. /** @hidden */
  94929. _shaderProcessor: IShaderProcessor;
  94930. /**
  94931. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  94932. */
  94933. forcePOTTextures: boolean;
  94934. /**
  94935. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  94936. */
  94937. isFullscreen: boolean;
  94938. /**
  94939. * Gets a boolean indicating if the pointer is currently locked
  94940. */
  94941. isPointerLock: boolean;
  94942. /**
  94943. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  94944. */
  94945. cullBackFaces: boolean;
  94946. /**
  94947. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  94948. */
  94949. renderEvenInBackground: boolean;
  94950. /**
  94951. * Gets or sets a boolean indicating that cache can be kept between frames
  94952. */
  94953. preventCacheWipeBetweenFrames: boolean;
  94954. /**
  94955. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  94956. **/
  94957. enableOfflineSupport: boolean;
  94958. /**
  94959. * 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)
  94960. **/
  94961. disableManifestCheck: boolean;
  94962. /**
  94963. * Gets the list of created scenes
  94964. */
  94965. scenes: Scene[];
  94966. /**
  94967. * Event raised when a new scene is created
  94968. */
  94969. onNewSceneAddedObservable: Observable<Scene>;
  94970. /**
  94971. * Gets the list of created postprocesses
  94972. */
  94973. postProcesses: PostProcess[];
  94974. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  94975. validateShaderPrograms: boolean;
  94976. /**
  94977. * Observable event triggered each time the rendering canvas is resized
  94978. */
  94979. onResizeObservable: Observable<Engine>;
  94980. /**
  94981. * Observable event triggered each time the canvas loses focus
  94982. */
  94983. onCanvasBlurObservable: Observable<Engine>;
  94984. /**
  94985. * Observable event triggered each time the canvas gains focus
  94986. */
  94987. onCanvasFocusObservable: Observable<Engine>;
  94988. /**
  94989. * Observable event triggered each time the canvas receives pointerout event
  94990. */
  94991. onCanvasPointerOutObservable: Observable<PointerEvent>;
  94992. /**
  94993. * Observable event triggered before each texture is initialized
  94994. */
  94995. onBeforeTextureInitObservable: Observable<Texture>;
  94996. /**
  94997. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  94998. */
  94999. disableUniformBuffers: boolean;
  95000. /** @hidden */
  95001. _uniformBuffers: UniformBuffer[];
  95002. /**
  95003. * Gets a boolean indicating that the engine supports uniform buffers
  95004. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95005. */
  95006. readonly supportsUniformBuffers: boolean;
  95007. /**
  95008. * Observable raised when the engine begins a new frame
  95009. */
  95010. onBeginFrameObservable: Observable<Engine>;
  95011. /**
  95012. * If set, will be used to request the next animation frame for the render loop
  95013. */
  95014. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95015. /**
  95016. * Observable raised when the engine ends the current frame
  95017. */
  95018. onEndFrameObservable: Observable<Engine>;
  95019. /**
  95020. * Observable raised when the engine is about to compile a shader
  95021. */
  95022. onBeforeShaderCompilationObservable: Observable<Engine>;
  95023. /**
  95024. * Observable raised when the engine has jsut compiled a shader
  95025. */
  95026. onAfterShaderCompilationObservable: Observable<Engine>;
  95027. /** @hidden */
  95028. _gl: WebGLRenderingContext;
  95029. private _renderingCanvas;
  95030. private _windowIsBackground;
  95031. private _webGLVersion;
  95032. protected _highPrecisionShadersAllowed: boolean;
  95033. /** @hidden */
  95034. readonly _shouldUseHighPrecisionShader: boolean;
  95035. /**
  95036. * Gets a boolean indicating that only power of 2 textures are supported
  95037. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95038. */
  95039. readonly needPOTTextures: boolean;
  95040. /** @hidden */
  95041. _badOS: boolean;
  95042. /** @hidden */
  95043. _badDesktopOS: boolean;
  95044. /**
  95045. * Gets the audio engine
  95046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95047. * @ignorenaming
  95048. */
  95049. static audioEngine: IAudioEngine;
  95050. /**
  95051. * Default AudioEngine factory responsible of creating the Audio Engine.
  95052. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  95053. */
  95054. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  95055. /**
  95056. * Default offline support factory responsible of creating a tool used to store data locally.
  95057. * By default, this will create a Database object if the workload has been embedded.
  95058. */
  95059. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  95060. private _onFocus;
  95061. private _onBlur;
  95062. private _onCanvasPointerOut;
  95063. private _onCanvasBlur;
  95064. private _onCanvasFocus;
  95065. private _onFullscreenChange;
  95066. private _onPointerLockChange;
  95067. private _hardwareScalingLevel;
  95068. /** @hidden */
  95069. _caps: EngineCapabilities;
  95070. private _pointerLockRequested;
  95071. private _isStencilEnable;
  95072. private _colorWrite;
  95073. private _loadingScreen;
  95074. /** @hidden */
  95075. _drawCalls: PerfCounter;
  95076. private _glVersion;
  95077. private _glRenderer;
  95078. private _glVendor;
  95079. private _videoTextureSupported;
  95080. private _renderingQueueLaunched;
  95081. private _activeRenderLoops;
  95082. private _deterministicLockstep;
  95083. private _lockstepMaxSteps;
  95084. /**
  95085. * Observable signaled when a context lost event is raised
  95086. */
  95087. onContextLostObservable: Observable<Engine>;
  95088. /**
  95089. * Observable signaled when a context restored event is raised
  95090. */
  95091. onContextRestoredObservable: Observable<Engine>;
  95092. private _onContextLost;
  95093. private _onContextRestored;
  95094. private _contextWasLost;
  95095. /** @hidden */
  95096. _doNotHandleContextLost: boolean;
  95097. /**
  95098. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95099. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95100. */
  95101. doNotHandleContextLost: boolean;
  95102. private _performanceMonitor;
  95103. private _fps;
  95104. private _deltaTime;
  95105. /**
  95106. * Turn this value on if you want to pause FPS computation when in background
  95107. */
  95108. disablePerformanceMonitorInBackground: boolean;
  95109. /**
  95110. * Gets the performance monitor attached to this engine
  95111. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  95112. */
  95113. readonly performanceMonitor: PerformanceMonitor;
  95114. /**
  95115. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95116. */
  95117. disableVertexArrayObjects: boolean;
  95118. /** @hidden */
  95119. protected _depthCullingState: _DepthCullingState;
  95120. /** @hidden */
  95121. protected _stencilState: _StencilState;
  95122. /** @hidden */
  95123. protected _alphaState: _AlphaState;
  95124. /** @hidden */
  95125. protected _alphaMode: number;
  95126. /** @hidden */
  95127. _internalTexturesCache: InternalTexture[];
  95128. /** @hidden */
  95129. protected _activeChannel: number;
  95130. private _currentTextureChannel;
  95131. /** @hidden */
  95132. protected _boundTexturesCache: {
  95133. [key: string]: Nullable<InternalTexture>;
  95134. };
  95135. /** @hidden */
  95136. protected _currentEffect: Nullable<Effect>;
  95137. /** @hidden */
  95138. protected _currentProgram: Nullable<WebGLProgram>;
  95139. private _compiledEffects;
  95140. private _vertexAttribArraysEnabled;
  95141. /** @hidden */
  95142. protected _cachedViewport: Nullable<IViewportLike>;
  95143. private _cachedVertexArrayObject;
  95144. /** @hidden */
  95145. protected _cachedVertexBuffers: any;
  95146. /** @hidden */
  95147. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95148. /** @hidden */
  95149. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95150. /** @hidden */
  95151. _currentRenderTarget: Nullable<InternalTexture>;
  95152. private _uintIndicesCurrentlySet;
  95153. private _currentBoundBuffer;
  95154. /** @hidden */
  95155. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95156. private _currentBufferPointers;
  95157. private _currentInstanceLocations;
  95158. private _currentInstanceBuffers;
  95159. private _textureUnits;
  95160. /** @hidden */
  95161. _workingCanvas: Nullable<HTMLCanvasElement>;
  95162. /** @hidden */
  95163. _workingContext: Nullable<CanvasRenderingContext2D>;
  95164. private _rescalePostProcess;
  95165. private _dummyFramebuffer;
  95166. private _externalData;
  95167. /** @hidden */
  95168. _bindedRenderFunction: any;
  95169. private _vaoRecordInProgress;
  95170. private _mustWipeVertexAttributes;
  95171. private _emptyTexture;
  95172. private _emptyCubeTexture;
  95173. private _emptyTexture3D;
  95174. /** @hidden */
  95175. _frameHandler: number;
  95176. private _nextFreeTextureSlots;
  95177. private _maxSimultaneousTextures;
  95178. private _activeRequests;
  95179. private _texturesSupported;
  95180. /** @hidden */
  95181. _textureFormatInUse: Nullable<string>;
  95182. /**
  95183. * Gets the list of texture formats supported
  95184. */
  95185. readonly texturesSupported: Array<string>;
  95186. /**
  95187. * Gets the list of texture formats in use
  95188. */
  95189. readonly textureFormatInUse: Nullable<string>;
  95190. /**
  95191. * Gets the current viewport
  95192. */
  95193. readonly currentViewport: Nullable<IViewportLike>;
  95194. /**
  95195. * Gets the default empty texture
  95196. */
  95197. readonly emptyTexture: InternalTexture;
  95198. /**
  95199. * Gets the default empty 3D texture
  95200. */
  95201. readonly emptyTexture3D: InternalTexture;
  95202. /**
  95203. * Gets the default empty cube texture
  95204. */
  95205. readonly emptyCubeTexture: InternalTexture;
  95206. /**
  95207. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95208. */
  95209. readonly premultipliedAlpha: boolean;
  95210. /**
  95211. * Creates a new engine
  95212. * @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
  95213. * @param antialias defines enable antialiasing (default: false)
  95214. * @param options defines further options to be sent to the getContext() function
  95215. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95216. */
  95217. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95218. /**
  95219. * Initializes a webVR display and starts listening to display change events
  95220. * The onVRDisplayChangedObservable will be notified upon these changes
  95221. * @returns The onVRDisplayChangedObservable
  95222. */
  95223. initWebVR(): Observable<IDisplayChangedEventArgs>;
  95224. /** @hidden */
  95225. _prepareVRComponent(): void;
  95226. /** @hidden */
  95227. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  95228. /** @hidden */
  95229. _submitVRFrame(): void;
  95230. /**
  95231. * Call this function to leave webVR mode
  95232. * Will do nothing if webVR is not supported or if there is no webVR device
  95233. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95234. */
  95235. disableVR(): void;
  95236. /**
  95237. * Gets a boolean indicating that the system is in VR mode and is presenting
  95238. * @returns true if VR mode is engaged
  95239. */
  95240. isVRPresenting(): boolean;
  95241. /** @hidden */
  95242. _requestVRFrame(): void;
  95243. private _disableTouchAction;
  95244. private _rebuildInternalTextures;
  95245. private _rebuildEffects;
  95246. /**
  95247. * Gets a boolean indicating if all created effects are ready
  95248. * @returns true if all effects are ready
  95249. */
  95250. areAllEffectsReady(): boolean;
  95251. private _rebuildBuffers;
  95252. private _initGLContext;
  95253. /**
  95254. * Gets version of the current webGL context
  95255. */
  95256. readonly webGLVersion: number;
  95257. /**
  95258. * Gets a string idenfifying the name of the class
  95259. * @returns "Engine" string
  95260. */
  95261. getClassName(): string;
  95262. /**
  95263. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95264. */
  95265. readonly isStencilEnable: boolean;
  95266. /** @hidden */
  95267. _prepareWorkingCanvas(): void;
  95268. /**
  95269. * Reset the texture cache to empty state
  95270. */
  95271. resetTextureCache(): void;
  95272. /**
  95273. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  95274. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95275. * @returns true if engine is in deterministic lock step mode
  95276. */
  95277. isDeterministicLockStep(): boolean;
  95278. /**
  95279. * Gets the max steps when engine is running in deterministic lock step
  95280. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95281. * @returns the max steps
  95282. */
  95283. getLockstepMaxSteps(): number;
  95284. /**
  95285. * Gets an object containing information about the current webGL context
  95286. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95287. */
  95288. getGlInfo(): {
  95289. vendor: string;
  95290. renderer: string;
  95291. version: string;
  95292. };
  95293. /**
  95294. * Gets current aspect ratio
  95295. * @param viewportOwner defines the camera to use to get the aspect ratio
  95296. * @param useScreen defines if screen size must be used (or the current render target if any)
  95297. * @returns a number defining the aspect ratio
  95298. */
  95299. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  95300. /**
  95301. * Gets current screen aspect ratio
  95302. * @returns a number defining the aspect ratio
  95303. */
  95304. getScreenAspectRatio(): number;
  95305. /**
  95306. * Gets the current render width
  95307. * @param useScreen defines if screen size must be used (or the current render target if any)
  95308. * @returns a number defining the current render width
  95309. */
  95310. getRenderWidth(useScreen?: boolean): number;
  95311. /**
  95312. * Gets the current render height
  95313. * @param useScreen defines if screen size must be used (or the current render target if any)
  95314. * @returns a number defining the current render height
  95315. */
  95316. getRenderHeight(useScreen?: boolean): number;
  95317. /**
  95318. * Gets the HTML canvas attached with the current webGL context
  95319. * @returns a HTML canvas
  95320. */
  95321. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95322. /**
  95323. * Gets host window
  95324. * @returns the host window object
  95325. */
  95326. getHostWindow(): Window;
  95327. /**
  95328. * Gets host document
  95329. * @returns the host document object
  95330. */
  95331. getHostDocument(): Document;
  95332. /**
  95333. * Gets the client rect of the HTML canvas attached with the current webGL context
  95334. * @returns a client rectanglee
  95335. */
  95336. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  95337. /**
  95338. * Defines the hardware scaling level.
  95339. * By default the hardware scaling level is computed from the window device ratio.
  95340. * 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.
  95341. * @param level defines the level to use
  95342. */
  95343. setHardwareScalingLevel(level: number): void;
  95344. /**
  95345. * Gets the current hardware scaling level.
  95346. * By default the hardware scaling level is computed from the window device ratio.
  95347. * 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.
  95348. * @returns a number indicating the current hardware scaling level
  95349. */
  95350. getHardwareScalingLevel(): number;
  95351. /**
  95352. * Gets the list of loaded textures
  95353. * @returns an array containing all loaded textures
  95354. */
  95355. getLoadedTexturesCache(): InternalTexture[];
  95356. /**
  95357. * Gets the object containing all engine capabilities
  95358. * @returns the EngineCapabilities object
  95359. */
  95360. getCaps(): EngineCapabilities;
  95361. /**
  95362. * Gets the current depth function
  95363. * @returns a number defining the depth function
  95364. */
  95365. getDepthFunction(): Nullable<number>;
  95366. /**
  95367. * Sets the current depth function
  95368. * @param depthFunc defines the function to use
  95369. */
  95370. setDepthFunction(depthFunc: number): void;
  95371. /**
  95372. * Sets the current depth function to GREATER
  95373. */
  95374. setDepthFunctionToGreater(): void;
  95375. /**
  95376. * Sets the current depth function to GEQUAL
  95377. */
  95378. setDepthFunctionToGreaterOrEqual(): void;
  95379. /**
  95380. * Sets the current depth function to LESS
  95381. */
  95382. setDepthFunctionToLess(): void;
  95383. private _cachedStencilBuffer;
  95384. private _cachedStencilFunction;
  95385. private _cachedStencilMask;
  95386. private _cachedStencilOperationPass;
  95387. private _cachedStencilOperationFail;
  95388. private _cachedStencilOperationDepthFail;
  95389. private _cachedStencilReference;
  95390. /**
  95391. * Caches the the state of the stencil buffer
  95392. */
  95393. cacheStencilState(): void;
  95394. /**
  95395. * Restores the state of the stencil buffer
  95396. */
  95397. restoreStencilState(): void;
  95398. /**
  95399. * Sets the current depth function to LEQUAL
  95400. */
  95401. setDepthFunctionToLessOrEqual(): void;
  95402. /**
  95403. * Gets a boolean indicating if stencil buffer is enabled
  95404. * @returns the current stencil buffer state
  95405. */
  95406. getStencilBuffer(): boolean;
  95407. /**
  95408. * Enable or disable the stencil buffer
  95409. * @param enable defines if the stencil buffer must be enabled or disabled
  95410. */
  95411. setStencilBuffer(enable: boolean): void;
  95412. /**
  95413. * Gets the current stencil mask
  95414. * @returns a number defining the new stencil mask to use
  95415. */
  95416. getStencilMask(): number;
  95417. /**
  95418. * Sets the current stencil mask
  95419. * @param mask defines the new stencil mask to use
  95420. */
  95421. setStencilMask(mask: number): void;
  95422. /**
  95423. * Gets the current stencil function
  95424. * @returns a number defining the stencil function to use
  95425. */
  95426. getStencilFunction(): number;
  95427. /**
  95428. * Gets the current stencil reference value
  95429. * @returns a number defining the stencil reference value to use
  95430. */
  95431. getStencilFunctionReference(): number;
  95432. /**
  95433. * Gets the current stencil mask
  95434. * @returns a number defining the stencil mask to use
  95435. */
  95436. getStencilFunctionMask(): number;
  95437. /**
  95438. * Sets the current stencil function
  95439. * @param stencilFunc defines the new stencil function to use
  95440. */
  95441. setStencilFunction(stencilFunc: number): void;
  95442. /**
  95443. * Sets the current stencil reference
  95444. * @param reference defines the new stencil reference to use
  95445. */
  95446. setStencilFunctionReference(reference: number): void;
  95447. /**
  95448. * Sets the current stencil mask
  95449. * @param mask defines the new stencil mask to use
  95450. */
  95451. setStencilFunctionMask(mask: number): void;
  95452. /**
  95453. * Gets the current stencil operation when stencil fails
  95454. * @returns a number defining stencil operation to use when stencil fails
  95455. */
  95456. getStencilOperationFail(): number;
  95457. /**
  95458. * Gets the current stencil operation when depth fails
  95459. * @returns a number defining stencil operation to use when depth fails
  95460. */
  95461. getStencilOperationDepthFail(): number;
  95462. /**
  95463. * Gets the current stencil operation when stencil passes
  95464. * @returns a number defining stencil operation to use when stencil passes
  95465. */
  95466. getStencilOperationPass(): number;
  95467. /**
  95468. * Sets the stencil operation to use when stencil fails
  95469. * @param operation defines the stencil operation to use when stencil fails
  95470. */
  95471. setStencilOperationFail(operation: number): void;
  95472. /**
  95473. * Sets the stencil operation to use when depth fails
  95474. * @param operation defines the stencil operation to use when depth fails
  95475. */
  95476. setStencilOperationDepthFail(operation: number): void;
  95477. /**
  95478. * Sets the stencil operation to use when stencil passes
  95479. * @param operation defines the stencil operation to use when stencil passes
  95480. */
  95481. setStencilOperationPass(operation: number): void;
  95482. /**
  95483. * Sets a boolean indicating if the dithering state is enabled or disabled
  95484. * @param value defines the dithering state
  95485. */
  95486. setDitheringState(value: boolean): void;
  95487. /**
  95488. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  95489. * @param value defines the rasterizer state
  95490. */
  95491. setRasterizerState(value: boolean): void;
  95492. /**
  95493. * stop executing a render loop function and remove it from the execution array
  95494. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95495. */
  95496. stopRenderLoop(renderFunction?: () => void): void;
  95497. /** @hidden */
  95498. _renderLoop(): void;
  95499. /**
  95500. * Register and execute a render loop. The engine can have more than one render function
  95501. * @param renderFunction defines the function to continuously execute
  95502. */
  95503. runRenderLoop(renderFunction: () => void): void;
  95504. /**
  95505. * Toggle full screen mode
  95506. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95507. */
  95508. switchFullscreen(requestPointerLock: boolean): void;
  95509. /**
  95510. * Enters full screen mode
  95511. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95512. */
  95513. enterFullscreen(requestPointerLock: boolean): void;
  95514. /**
  95515. * Exits full screen mode
  95516. */
  95517. exitFullscreen(): void;
  95518. /**
  95519. * Enters Pointerlock mode
  95520. */
  95521. enterPointerlock(): void;
  95522. /**
  95523. * Exits Pointerlock mode
  95524. */
  95525. exitPointerlock(): void;
  95526. /**
  95527. * Clear the current render buffer or the current render target (if any is set up)
  95528. * @param color defines the color to use
  95529. * @param backBuffer defines if the back buffer must be cleared
  95530. * @param depth defines if the depth buffer must be cleared
  95531. * @param stencil defines if the stencil buffer must be cleared
  95532. */
  95533. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95534. /**
  95535. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  95536. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95537. * @param y defines the y-coordinate of the corner of the clear rectangle
  95538. * @param width defines the width of the clear rectangle
  95539. * @param height defines the height of the clear rectangle
  95540. * @param clearColor defines the clear color
  95541. */
  95542. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  95543. /**
  95544. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  95545. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95546. * @param y defines the y-coordinate of the corner of the clear rectangle
  95547. * @param width defines the width of the clear rectangle
  95548. * @param height defines the height of the clear rectangle
  95549. */
  95550. enableScissor(x: number, y: number, width: number, height: number): void;
  95551. /**
  95552. * Disable previously set scissor test rectangle
  95553. */
  95554. disableScissor(): void;
  95555. private _viewportCached;
  95556. /** @hidden */
  95557. _viewport(x: number, y: number, width: number, height: number): void;
  95558. /**
  95559. * Set the WebGL's viewport
  95560. * @param viewport defines the viewport element to be used
  95561. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95562. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95563. */
  95564. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95565. /**
  95566. * Directly set the WebGL Viewport
  95567. * @param x defines the x coordinate of the viewport (in screen space)
  95568. * @param y defines the y coordinate of the viewport (in screen space)
  95569. * @param width defines the width of the viewport (in screen space)
  95570. * @param height defines the height of the viewport (in screen space)
  95571. * @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
  95572. */
  95573. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  95574. /**
  95575. * Begin a new frame
  95576. */
  95577. beginFrame(): void;
  95578. /**
  95579. * Enf the current frame
  95580. */
  95581. endFrame(): void;
  95582. /**
  95583. * Resize the view according to the canvas' size
  95584. */
  95585. resize(): void;
  95586. /**
  95587. * Force a specific size of the canvas
  95588. * @param width defines the new canvas' width
  95589. * @param height defines the new canvas' height
  95590. */
  95591. setSize(width: number, height: number): void;
  95592. /**
  95593. * Binds the frame buffer to the specified texture.
  95594. * @param texture The texture to render to or null for the default canvas
  95595. * @param faceIndex The face of the texture to render to in case of cube texture
  95596. * @param requiredWidth The width of the target to render to
  95597. * @param requiredHeight The height of the target to render to
  95598. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95599. * @param depthStencilTexture The depth stencil texture to use to render
  95600. * @param lodLevel defines le lod level to bind to the frame buffer
  95601. */
  95602. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95603. /** @hidden */
  95604. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95605. /**
  95606. * Unbind the current render target texture from the webGL context
  95607. * @param texture defines the render target texture to unbind
  95608. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95609. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95610. */
  95611. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95612. /**
  95613. * Force the mipmap generation for the given render target texture
  95614. * @param texture defines the render target texture to use
  95615. */
  95616. generateMipMapsForCubemap(texture: InternalTexture): void;
  95617. /**
  95618. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95619. */
  95620. flushFramebuffer(): void;
  95621. /**
  95622. * Unbind the current render target and bind the default framebuffer
  95623. */
  95624. restoreDefaultFramebuffer(): void;
  95625. /**
  95626. * Create an uniform buffer
  95627. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95628. * @param elements defines the content of the uniform buffer
  95629. * @returns the webGL uniform buffer
  95630. */
  95631. createUniformBuffer(elements: FloatArray): DataBuffer;
  95632. /**
  95633. * Create a dynamic uniform buffer
  95634. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95635. * @param elements defines the content of the uniform buffer
  95636. * @returns the webGL uniform buffer
  95637. */
  95638. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  95639. /**
  95640. * Update an existing uniform buffer
  95641. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95642. * @param uniformBuffer defines the target uniform buffer
  95643. * @param elements defines the content to update
  95644. * @param offset defines the offset in the uniform buffer where update should start
  95645. * @param count defines the size of the data to update
  95646. */
  95647. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  95648. private _resetVertexBufferBinding;
  95649. /**
  95650. * Creates a vertex buffer
  95651. * @param data the data for the vertex buffer
  95652. * @returns the new WebGL static buffer
  95653. */
  95654. createVertexBuffer(data: DataArray): DataBuffer;
  95655. /**
  95656. * Creates a dynamic vertex buffer
  95657. * @param data the data for the dynamic vertex buffer
  95658. * @returns the new WebGL dynamic buffer
  95659. */
  95660. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95661. /**
  95662. * Update a dynamic index buffer
  95663. * @param indexBuffer defines the target index buffer
  95664. * @param indices defines the data to update
  95665. * @param offset defines the offset in the target index buffer where update should start
  95666. */
  95667. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95668. /**
  95669. * Updates a dynamic vertex buffer.
  95670. * @param vertexBuffer the vertex buffer to update
  95671. * @param data the data used to update the vertex buffer
  95672. * @param byteOffset the byte offset of the data
  95673. * @param byteLength the byte length of the data
  95674. */
  95675. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95676. private _resetIndexBufferBinding;
  95677. /**
  95678. * Creates a new index buffer
  95679. * @param indices defines the content of the index buffer
  95680. * @param updatable defines if the index buffer must be updatable
  95681. * @returns a new webGL buffer
  95682. */
  95683. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  95684. /**
  95685. * Bind a webGL buffer to the webGL context
  95686. * @param buffer defines the buffer to bind
  95687. */
  95688. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  95689. /**
  95690. * Bind an uniform buffer to the current webGL context
  95691. * @param buffer defines the buffer to bind
  95692. */
  95693. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  95694. /**
  95695. * Bind a buffer to the current webGL context at a given location
  95696. * @param buffer defines the buffer to bind
  95697. * @param location defines the index where to bind the buffer
  95698. */
  95699. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  95700. /**
  95701. * Bind a specific block at a given index in a specific shader program
  95702. * @param pipelineContext defines the pipeline context to use
  95703. * @param blockName defines the block name
  95704. * @param index defines the index where to bind the block
  95705. */
  95706. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  95707. private bindIndexBuffer;
  95708. private bindBuffer;
  95709. /**
  95710. * update the bound buffer with the given data
  95711. * @param data defines the data to update
  95712. */
  95713. updateArrayBuffer(data: Float32Array): void;
  95714. private _vertexAttribPointer;
  95715. private _bindIndexBufferWithCache;
  95716. private _bindVertexBuffersAttributes;
  95717. /**
  95718. * Records a vertex array object
  95719. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95720. * @param vertexBuffers defines the list of vertex buffers to store
  95721. * @param indexBuffer defines the index buffer to store
  95722. * @param effect defines the effect to store
  95723. * @returns the new vertex array object
  95724. */
  95725. recordVertexArrayObject(vertexBuffers: {
  95726. [key: string]: VertexBuffer;
  95727. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  95728. /**
  95729. * Bind a specific vertex array object
  95730. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95731. * @param vertexArrayObject defines the vertex array object to bind
  95732. * @param indexBuffer defines the index buffer to bind
  95733. */
  95734. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  95735. /**
  95736. * Bind webGl buffers directly to the webGL context
  95737. * @param vertexBuffer defines the vertex buffer to bind
  95738. * @param indexBuffer defines the index buffer to bind
  95739. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  95740. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  95741. * @param effect defines the effect associated with the vertex buffer
  95742. */
  95743. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  95744. private _unbindVertexArrayObject;
  95745. /**
  95746. * Bind a list of vertex buffers to the webGL context
  95747. * @param vertexBuffers defines the list of vertex buffers to bind
  95748. * @param indexBuffer defines the index buffer to bind
  95749. * @param effect defines the effect associated with the vertex buffers
  95750. */
  95751. bindBuffers(vertexBuffers: {
  95752. [key: string]: Nullable<VertexBuffer>;
  95753. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  95754. /**
  95755. * Unbind all instance attributes
  95756. */
  95757. unbindInstanceAttributes(): void;
  95758. /**
  95759. * Release and free the memory of a vertex array object
  95760. * @param vao defines the vertex array object to delete
  95761. */
  95762. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  95763. /** @hidden */
  95764. _releaseBuffer(buffer: DataBuffer): boolean;
  95765. /**
  95766. * Creates a webGL buffer to use with instanciation
  95767. * @param capacity defines the size of the buffer
  95768. * @returns the webGL buffer
  95769. */
  95770. createInstancesBuffer(capacity: number): DataBuffer;
  95771. /**
  95772. * Delete a webGL buffer used with instanciation
  95773. * @param buffer defines the webGL buffer to delete
  95774. */
  95775. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95776. /**
  95777. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95778. * @param instancesBuffer defines the webGL buffer to update and bind
  95779. * @param data defines the data to store in the buffer
  95780. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95781. */
  95782. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95783. /**
  95784. * Apply all cached states (depth, culling, stencil and alpha)
  95785. */
  95786. applyStates(): void;
  95787. /**
  95788. * Send a draw order
  95789. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95790. * @param indexStart defines the starting index
  95791. * @param indexCount defines the number of index to draw
  95792. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95793. */
  95794. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95795. /**
  95796. * Draw a list of points
  95797. * @param verticesStart defines the index of first vertex to draw
  95798. * @param verticesCount defines the count of vertices to draw
  95799. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95800. */
  95801. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95802. /**
  95803. * Draw a list of unindexed primitives
  95804. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95805. * @param verticesStart defines the index of first vertex to draw
  95806. * @param verticesCount defines the count of vertices to draw
  95807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95808. */
  95809. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95810. /**
  95811. * Draw a list of indexed primitives
  95812. * @param fillMode defines the primitive to use
  95813. * @param indexStart defines the starting index
  95814. * @param indexCount defines the number of index to draw
  95815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95816. */
  95817. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95818. /**
  95819. * Draw a list of unindexed primitives
  95820. * @param fillMode defines the primitive to use
  95821. * @param verticesStart defines the index of first vertex to draw
  95822. * @param verticesCount defines the count of vertices to draw
  95823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95824. */
  95825. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95826. private _drawMode;
  95827. /** @hidden */
  95828. _releaseEffect(effect: Effect): void;
  95829. /** @hidden */
  95830. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95831. /**
  95832. * Create a new effect (used to store vertex/fragment shaders)
  95833. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95834. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95835. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95836. * @param samplers defines an array of string used to represent textures
  95837. * @param defines defines the string containing the defines to use to compile the shaders
  95838. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95839. * @param onCompiled defines a function to call when the effect creation is successful
  95840. * @param onError defines a function to call when the effect creation has failed
  95841. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95842. * @returns the new Effect
  95843. */
  95844. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  95845. private _compileShader;
  95846. private _compileRawShader;
  95847. /**
  95848. * Directly creates a webGL program
  95849. * @param pipelineContext defines the pipeline context to attach to
  95850. * @param vertexCode defines the vertex shader code to use
  95851. * @param fragmentCode defines the fragment shader code to use
  95852. * @param context defines the webGL context to use (if not set, the current one will be used)
  95853. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95854. * @returns the new webGL program
  95855. */
  95856. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95857. /**
  95858. * Creates a webGL program
  95859. * @param pipelineContext defines the pipeline context to attach to
  95860. * @param vertexCode defines the vertex shader code to use
  95861. * @param fragmentCode defines the fragment shader code to use
  95862. * @param defines defines the string containing the defines to use to compile the shaders
  95863. * @param context defines the webGL context to use (if not set, the current one will be used)
  95864. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95865. * @returns the new webGL program
  95866. */
  95867. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95868. /**
  95869. * Creates a new pipeline context
  95870. * @returns the new pipeline
  95871. */
  95872. createPipelineContext(): WebGLPipelineContext;
  95873. private _createShaderProgram;
  95874. private _finalizePipelineContext;
  95875. /** @hidden */
  95876. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  95877. /** @hidden */
  95878. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  95879. /** @hidden */
  95880. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  95881. /**
  95882. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  95883. * @param pipelineContext defines the pipeline context to use
  95884. * @param uniformsNames defines the list of uniform names
  95885. * @returns an array of webGL uniform locations
  95886. */
  95887. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  95888. /**
  95889. * Gets the lsit of active attributes for a given webGL program
  95890. * @param pipelineContext defines the pipeline context to use
  95891. * @param attributesNames defines the list of attribute names to get
  95892. * @returns an array of indices indicating the offset of each attribute
  95893. */
  95894. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  95895. /**
  95896. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  95897. * @param effect defines the effect to activate
  95898. */
  95899. enableEffect(effect: Nullable<Effect>): void;
  95900. /**
  95901. * Set the value of an uniform to an array of int32
  95902. * @param uniform defines the webGL uniform location where to store the value
  95903. * @param array defines the array of int32 to store
  95904. */
  95905. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95906. /**
  95907. * Set the value of an uniform to an array of int32 (stored as vec2)
  95908. * @param uniform defines the webGL uniform location where to store the value
  95909. * @param array defines the array of int32 to store
  95910. */
  95911. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95912. /**
  95913. * Set the value of an uniform to an array of int32 (stored as vec3)
  95914. * @param uniform defines the webGL uniform location where to store the value
  95915. * @param array defines the array of int32 to store
  95916. */
  95917. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95918. /**
  95919. * Set the value of an uniform to an array of int32 (stored as vec4)
  95920. * @param uniform defines the webGL uniform location where to store the value
  95921. * @param array defines the array of int32 to store
  95922. */
  95923. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95924. /**
  95925. * Set the value of an uniform to an array of float32
  95926. * @param uniform defines the webGL uniform location where to store the value
  95927. * @param array defines the array of float32 to store
  95928. */
  95929. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95930. /**
  95931. * Set the value of an uniform to an array of float32 (stored as vec2)
  95932. * @param uniform defines the webGL uniform location where to store the value
  95933. * @param array defines the array of float32 to store
  95934. */
  95935. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95936. /**
  95937. * Set the value of an uniform to an array of float32 (stored as vec3)
  95938. * @param uniform defines the webGL uniform location where to store the value
  95939. * @param array defines the array of float32 to store
  95940. */
  95941. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95942. /**
  95943. * Set the value of an uniform to an array of float32 (stored as vec4)
  95944. * @param uniform defines the webGL uniform location where to store the value
  95945. * @param array defines the array of float32 to store
  95946. */
  95947. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95948. /**
  95949. * Set the value of an uniform to an array of number
  95950. * @param uniform defines the webGL uniform location where to store the value
  95951. * @param array defines the array of number to store
  95952. */
  95953. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95954. /**
  95955. * Set the value of an uniform to an array of number (stored as vec2)
  95956. * @param uniform defines the webGL uniform location where to store the value
  95957. * @param array defines the array of number to store
  95958. */
  95959. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95960. /**
  95961. * Set the value of an uniform to an array of number (stored as vec3)
  95962. * @param uniform defines the webGL uniform location where to store the value
  95963. * @param array defines the array of number to store
  95964. */
  95965. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95966. /**
  95967. * Set the value of an uniform to an array of number (stored as vec4)
  95968. * @param uniform defines the webGL uniform location where to store the value
  95969. * @param array defines the array of number to store
  95970. */
  95971. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95972. /**
  95973. * Set the value of an uniform to an array of float32 (stored as matrices)
  95974. * @param uniform defines the webGL uniform location where to store the value
  95975. * @param matrices defines the array of float32 to store
  95976. */
  95977. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  95978. /**
  95979. * Set the value of an uniform to a matrix (3x3)
  95980. * @param uniform defines the webGL uniform location where to store the value
  95981. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  95982. */
  95983. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95984. /**
  95985. * Set the value of an uniform to a matrix (2x2)
  95986. * @param uniform defines the webGL uniform location where to store the value
  95987. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  95988. */
  95989. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95990. /**
  95991. * Set the value of an uniform to a number (int)
  95992. * @param uniform defines the webGL uniform location where to store the value
  95993. * @param value defines the int number to store
  95994. */
  95995. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95996. /**
  95997. * Set the value of an uniform to a number (float)
  95998. * @param uniform defines the webGL uniform location where to store the value
  95999. * @param value defines the float number to store
  96000. */
  96001. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96002. /**
  96003. * Set the value of an uniform to a vec2
  96004. * @param uniform defines the webGL uniform location where to store the value
  96005. * @param x defines the 1st component of the value
  96006. * @param y defines the 2nd component of the value
  96007. */
  96008. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96009. /**
  96010. * Set the value of an uniform to a vec3
  96011. * @param uniform defines the webGL uniform location where to store the value
  96012. * @param x defines the 1st component of the value
  96013. * @param y defines the 2nd component of the value
  96014. * @param z defines the 3rd component of the value
  96015. */
  96016. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96017. /**
  96018. * Set the value of an uniform to a boolean
  96019. * @param uniform defines the webGL uniform location where to store the value
  96020. * @param bool defines the boolean to store
  96021. */
  96022. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96023. /**
  96024. * Set the value of an uniform to a vec4
  96025. * @param uniform defines the webGL uniform location where to store the value
  96026. * @param x defines the 1st component of the value
  96027. * @param y defines the 2nd component of the value
  96028. * @param z defines the 3rd component of the value
  96029. * @param w defines the 4th component of the value
  96030. */
  96031. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96032. /**
  96033. * Sets a Color4 on a uniform variable
  96034. * @param uniform defines the uniform location
  96035. * @param color4 defines the value to be set
  96036. */
  96037. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96038. /**
  96039. * Set various states to the webGL context
  96040. * @param culling defines backface culling state
  96041. * @param zOffset defines the value to apply to zOffset (0 by default)
  96042. * @param force defines if states must be applied even if cache is up to date
  96043. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  96044. */
  96045. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96046. /**
  96047. * Set the z offset to apply to current rendering
  96048. * @param value defines the offset to apply
  96049. */
  96050. setZOffset(value: number): void;
  96051. /**
  96052. * Gets the current value of the zOffset
  96053. * @returns the current zOffset state
  96054. */
  96055. getZOffset(): number;
  96056. /**
  96057. * Enable or disable depth buffering
  96058. * @param enable defines the state to set
  96059. */
  96060. setDepthBuffer(enable: boolean): void;
  96061. /**
  96062. * Gets a boolean indicating if depth writing is enabled
  96063. * @returns the current depth writing state
  96064. */
  96065. getDepthWrite(): boolean;
  96066. /**
  96067. * Enable or disable depth writing
  96068. * @param enable defines the state to set
  96069. */
  96070. setDepthWrite(enable: boolean): void;
  96071. /**
  96072. * Enable or disable color writing
  96073. * @param enable defines the state to set
  96074. */
  96075. setColorWrite(enable: boolean): void;
  96076. /**
  96077. * Gets a boolean indicating if color writing is enabled
  96078. * @returns the current color writing state
  96079. */
  96080. getColorWrite(): boolean;
  96081. /**
  96082. * Sets alpha constants used by some alpha blending modes
  96083. * @param r defines the red component
  96084. * @param g defines the green component
  96085. * @param b defines the blue component
  96086. * @param a defines the alpha component
  96087. */
  96088. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96089. /**
  96090. * Sets the current alpha mode
  96091. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96092. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96093. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96094. */
  96095. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96096. /**
  96097. * Gets the current alpha mode
  96098. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96099. * @returns the current alpha mode
  96100. */
  96101. getAlphaMode(): number;
  96102. /**
  96103. * Clears the list of texture accessible through engine.
  96104. * This can help preventing texture load conflict due to name collision.
  96105. */
  96106. clearInternalTexturesCache(): void;
  96107. /**
  96108. * Force the entire cache to be cleared
  96109. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96110. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96111. */
  96112. wipeCaches(bruteForce?: boolean): void;
  96113. /**
  96114. * Set the compressed texture format to use, based on the formats you have, and the formats
  96115. * supported by the hardware / browser.
  96116. *
  96117. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  96118. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  96119. * to API arguments needed to compressed textures. This puts the burden on the container
  96120. * generator to house the arcane code for determining these for current & future formats.
  96121. *
  96122. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96123. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96124. *
  96125. * Note: The result of this call is not taken into account when a texture is base64.
  96126. *
  96127. * @param formatsAvailable defines the list of those format families you have created
  96128. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  96129. *
  96130. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  96131. * @returns The extension selected.
  96132. */
  96133. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  96134. /** @hidden */
  96135. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96136. min: number;
  96137. mag: number;
  96138. };
  96139. /** @hidden */
  96140. _createTexture(): WebGLTexture;
  96141. /**
  96142. * Usually called from Texture.ts.
  96143. * Passed information to create a WebGLTexture
  96144. * @param urlArg defines a value which contains one of the following:
  96145. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96146. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96147. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96148. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96149. * @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)
  96150. * @param scene needed for loading to the correct scene
  96151. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96152. * @param onLoad optional callback to be called upon successful completion
  96153. * @param onError optional callback to be called upon failure
  96154. * @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
  96155. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96156. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96157. * @param forcedExtension defines the extension to use to pick the right loader
  96158. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96159. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96160. */
  96161. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96162. /**
  96163. * @hidden
  96164. * Rescales a texture
  96165. * @param source input texutre
  96166. * @param destination destination texture
  96167. * @param scene scene to use to render the resize
  96168. * @param internalFormat format to use when resizing
  96169. * @param onComplete callback to be called when resize has completed
  96170. */
  96171. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  96172. private _unpackFlipYCached;
  96173. /**
  96174. * In case you are sharing the context with other applications, it might
  96175. * be interested to not cache the unpack flip y state to ensure a consistent
  96176. * value would be set.
  96177. */
  96178. enableUnpackFlipYCached: boolean;
  96179. /** @hidden */
  96180. _unpackFlipY(value: boolean): void;
  96181. /** @hidden */
  96182. _getUnpackAlignement(): number;
  96183. /**
  96184. * Creates a dynamic texture
  96185. * @param width defines the width of the texture
  96186. * @param height defines the height of the texture
  96187. * @param generateMipMaps defines if the engine should generate the mip levels
  96188. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96189. * @returns the dynamic texture inside an InternalTexture
  96190. */
  96191. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  96192. /**
  96193. * Update the sampling mode of a given texture
  96194. * @param samplingMode defines the required sampling mode
  96195. * @param texture defines the texture to update
  96196. */
  96197. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96198. /**
  96199. * Update the content of a dynamic texture
  96200. * @param texture defines the texture to update
  96201. * @param canvas defines the canvas containing the source
  96202. * @param invertY defines if data must be stored with Y axis inverted
  96203. * @param premulAlpha defines if alpha is stored as premultiplied
  96204. * @param format defines the format of the data
  96205. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  96206. */
  96207. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  96208. /**
  96209. * Update a video texture
  96210. * @param texture defines the texture to update
  96211. * @param video defines the video element to use
  96212. * @param invertY defines if data must be stored with Y axis inverted
  96213. */
  96214. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96215. /**
  96216. * Updates a depth texture Comparison Mode and Function.
  96217. * If the comparison Function is equal to 0, the mode will be set to none.
  96218. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96219. * @param texture The texture to set the comparison function for
  96220. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96221. */
  96222. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96223. /** @hidden */
  96224. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96225. width: number;
  96226. height: number;
  96227. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96228. /**
  96229. * Creates a depth stencil texture.
  96230. * This is only available in WebGL 2 or with the depth texture extension available.
  96231. * @param size The size of face edge in the texture.
  96232. * @param options The options defining the texture.
  96233. * @returns The texture
  96234. */
  96235. createDepthStencilTexture(size: number | {
  96236. width: number;
  96237. height: number;
  96238. }, options: DepthTextureCreationOptions): InternalTexture;
  96239. /**
  96240. * Creates a depth stencil texture.
  96241. * This is only available in WebGL 2 or with the depth texture extension available.
  96242. * @param size The size of face edge in the texture.
  96243. * @param options The options defining the texture.
  96244. * @returns The texture
  96245. */
  96246. private _createDepthStencilTexture;
  96247. /**
  96248. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96249. * @param renderTarget The render target to set the frame buffer for
  96250. */
  96251. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96252. /**
  96253. * Creates a new render target texture
  96254. * @param size defines the size of the texture
  96255. * @param options defines the options used to create the texture
  96256. * @returns a new render target texture stored in an InternalTexture
  96257. */
  96258. createRenderTargetTexture(size: number | {
  96259. width: number;
  96260. height: number;
  96261. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96262. /** @hidden */
  96263. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96264. /**
  96265. * Updates the sample count of a render target texture
  96266. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  96267. * @param texture defines the texture to update
  96268. * @param samples defines the sample count to set
  96269. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  96270. */
  96271. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  96272. /** @hidden */
  96273. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96274. /** @hidden */
  96275. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96276. /** @hidden */
  96277. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96278. /** @hidden */
  96279. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96280. /**
  96281. * @hidden
  96282. */
  96283. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96284. private _prepareWebGLTextureContinuation;
  96285. private _prepareWebGLTexture;
  96286. /** @hidden */
  96287. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  96288. /** @hidden */
  96289. _releaseFramebufferObjects(texture: InternalTexture): void;
  96290. /** @hidden */
  96291. _releaseTexture(texture: InternalTexture): void;
  96292. private setProgram;
  96293. private _boundUniforms;
  96294. /**
  96295. * Binds an effect to the webGL context
  96296. * @param effect defines the effect to bind
  96297. */
  96298. bindSamplers(effect: Effect): void;
  96299. private _activateCurrentTexture;
  96300. /** @hidden */
  96301. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96302. /** @hidden */
  96303. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96304. /**
  96305. * Sets a texture to the webGL context from a postprocess
  96306. * @param channel defines the channel to use
  96307. * @param postProcess defines the source postprocess
  96308. */
  96309. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  96310. /**
  96311. * Binds the output of the passed in post process to the texture channel specified
  96312. * @param channel The channel the texture should be bound to
  96313. * @param postProcess The post process which's output should be bound
  96314. */
  96315. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  96316. /**
  96317. * Unbind all textures from the webGL context
  96318. */
  96319. unbindAllTextures(): void;
  96320. /**
  96321. * Sets a texture to the according uniform.
  96322. * @param channel The texture channel
  96323. * @param uniform The uniform to set
  96324. * @param texture The texture to apply
  96325. */
  96326. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96327. /**
  96328. * Sets a depth stencil texture from a render target to the according uniform.
  96329. * @param channel The texture channel
  96330. * @param uniform The uniform to set
  96331. * @param texture The render target texture containing the depth stencil texture to apply
  96332. */
  96333. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  96334. private _bindSamplerUniformToChannel;
  96335. private _getTextureWrapMode;
  96336. private _setTexture;
  96337. /**
  96338. * Sets an array of texture to the webGL context
  96339. * @param channel defines the channel where the texture array must be set
  96340. * @param uniform defines the associated uniform location
  96341. * @param textures defines the array of textures to bind
  96342. */
  96343. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96344. /** @hidden */
  96345. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96346. private _setTextureParameterFloat;
  96347. private _setTextureParameterInteger;
  96348. /**
  96349. * Reads pixels from the current frame buffer. Please note that this function can be slow
  96350. * @param x defines the x coordinate of the rectangle where pixels must be read
  96351. * @param y defines the y coordinate of the rectangle where pixels must be read
  96352. * @param width defines the width of the rectangle where pixels must be read
  96353. * @param height defines the height of the rectangle where pixels must be read
  96354. * @returns a Uint8Array containing RGBA colors
  96355. */
  96356. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  96357. /**
  96358. * Add an externaly attached data from its key.
  96359. * This method call will fail and return false, if such key already exists.
  96360. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96361. * @param key the unique key that identifies the data
  96362. * @param data the data object to associate to the key for this Engine instance
  96363. * @return true if no such key were already present and the data was added successfully, false otherwise
  96364. */
  96365. addExternalData<T>(key: string, data: T): boolean;
  96366. /**
  96367. * Get an externaly attached data from its key
  96368. * @param key the unique key that identifies the data
  96369. * @return the associated data, if present (can be null), or undefined if not present
  96370. */
  96371. getExternalData<T>(key: string): T;
  96372. /**
  96373. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96374. * @param key the unique key that identifies the data
  96375. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96376. * @return the associated data, can be null if the factory returned null.
  96377. */
  96378. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96379. /**
  96380. * Remove an externaly attached data from the Engine instance
  96381. * @param key the unique key that identifies the data
  96382. * @return true if the data was successfully removed, false if it doesn't exist
  96383. */
  96384. removeExternalData(key: string): boolean;
  96385. /**
  96386. * Unbind all vertex attributes from the webGL context
  96387. */
  96388. unbindAllAttributes(): void;
  96389. /**
  96390. * 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
  96391. */
  96392. releaseEffects(): void;
  96393. /**
  96394. * Dispose and release all associated resources
  96395. */
  96396. dispose(): void;
  96397. /**
  96398. * Display the loading screen
  96399. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96400. */
  96401. displayLoadingUI(): void;
  96402. /**
  96403. * Hide the loading screen
  96404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96405. */
  96406. hideLoadingUI(): void;
  96407. /**
  96408. * Gets the current loading screen object
  96409. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96410. */
  96411. /**
  96412. * Sets the current loading screen object
  96413. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96414. */
  96415. loadingScreen: ILoadingScreen;
  96416. /**
  96417. * Sets the current loading screen text
  96418. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96419. */
  96420. loadingUIText: string;
  96421. /**
  96422. * Sets the current loading screen background color
  96423. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96424. */
  96425. loadingUIBackgroundColor: string;
  96426. /**
  96427. * Attach a new callback raised when context lost event is fired
  96428. * @param callback defines the callback to call
  96429. */
  96430. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96431. /**
  96432. * Attach a new callback raised when context restored event is fired
  96433. * @param callback defines the callback to call
  96434. */
  96435. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96436. /**
  96437. * Gets the source code of the vertex shader associated with a specific webGL program
  96438. * @param program defines the program to use
  96439. * @returns a string containing the source code of the vertex shader associated with the program
  96440. */
  96441. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  96442. /**
  96443. * Gets the source code of the fragment shader associated with a specific webGL program
  96444. * @param program defines the program to use
  96445. * @returns a string containing the source code of the fragment shader associated with the program
  96446. */
  96447. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  96448. /**
  96449. * Get the current error code of the webGL context
  96450. * @returns the error code
  96451. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96452. */
  96453. getError(): number;
  96454. /**
  96455. * Gets the current framerate
  96456. * @returns a number representing the framerate
  96457. */
  96458. getFps(): number;
  96459. /**
  96460. * Gets the time spent between current and previous frame
  96461. * @returns a number representing the delta time in ms
  96462. */
  96463. getDeltaTime(): number;
  96464. private _measureFps;
  96465. /** @hidden */
  96466. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  96467. private _canRenderToFloatFramebuffer;
  96468. private _canRenderToHalfFloatFramebuffer;
  96469. private _canRenderToFramebuffer;
  96470. /** @hidden */
  96471. _getWebGLTextureType(type: number): number;
  96472. /** @hidden */
  96473. _getInternalFormat(format: number): number;
  96474. /** @hidden */
  96475. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96476. /** @hidden */
  96477. _getRGBAMultiSampleBufferFormat(type: number): number;
  96478. /** @hidden */
  96479. _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;
  96480. /** @hidden */
  96481. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96482. /**
  96483. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96484. * @returns true if the engine can be created
  96485. * @ignorenaming
  96486. */
  96487. static isSupported(): boolean;
  96488. /**
  96489. * Find the next highest power of two.
  96490. * @param x Number to start search from.
  96491. * @return Next highest power of two.
  96492. */
  96493. static CeilingPOT(x: number): number;
  96494. /**
  96495. * Find the next lowest power of two.
  96496. * @param x Number to start search from.
  96497. * @return Next lowest power of two.
  96498. */
  96499. static FloorPOT(x: number): number;
  96500. /**
  96501. * Find the nearest power of two.
  96502. * @param x Number to start search from.
  96503. * @return Next nearest power of two.
  96504. */
  96505. static NearestPOT(x: number): number;
  96506. /**
  96507. * Get the closest exponent of two
  96508. * @param value defines the value to approximate
  96509. * @param max defines the maximum value to return
  96510. * @param mode defines how to define the closest value
  96511. * @returns closest exponent of two of the given value
  96512. */
  96513. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96514. /**
  96515. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96516. * @param func - the function to be called
  96517. * @param requester - the object that will request the next frame. Falls back to window.
  96518. * @returns frame number
  96519. */
  96520. static QueueNewFrame(func: () => void, requester?: any): number;
  96521. /**
  96522. * Ask the browser to promote the current element to pointerlock mode
  96523. * @param element defines the DOM element to promote
  96524. */
  96525. static _RequestPointerlock(element: HTMLElement): void;
  96526. /**
  96527. * Asks the browser to exit pointerlock mode
  96528. */
  96529. static _ExitPointerlock(): void;
  96530. /**
  96531. * Ask the browser to promote the current element to fullscreen rendering mode
  96532. * @param element defines the DOM element to promote
  96533. */
  96534. static _RequestFullscreen(element: HTMLElement): void;
  96535. /**
  96536. * Asks the browser to exit fullscreen mode
  96537. */
  96538. static _ExitFullscreen(): void;
  96539. }
  96540. }
  96541. declare module BABYLON {
  96542. /**
  96543. * The engine store class is responsible to hold all the instances of Engine and Scene created
  96544. * during the life time of the application.
  96545. */
  96546. export class EngineStore {
  96547. /** Gets the list of created engines */
  96548. static Instances: Engine[];
  96549. /** @hidden */
  96550. static _LastCreatedScene: Nullable<Scene>;
  96551. /**
  96552. * Gets the latest created engine
  96553. */
  96554. static readonly LastCreatedEngine: Nullable<Engine>;
  96555. /**
  96556. * Gets the latest created scene
  96557. */
  96558. static readonly LastCreatedScene: Nullable<Scene>;
  96559. /**
  96560. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96561. * @ignorenaming
  96562. */
  96563. static UseFallbackTexture: boolean;
  96564. /**
  96565. * Texture content used if a texture cannot loaded
  96566. * @ignorenaming
  96567. */
  96568. static FallbackTexture: string;
  96569. }
  96570. }
  96571. declare module BABYLON {
  96572. /**
  96573. * Helper class that provides a small promise polyfill
  96574. */
  96575. export class PromisePolyfill {
  96576. /**
  96577. * Static function used to check if the polyfill is required
  96578. * If this is the case then the function will inject the polyfill to window.Promise
  96579. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96580. */
  96581. static Apply(force?: boolean): void;
  96582. }
  96583. }
  96584. declare module BABYLON {
  96585. /**
  96586. * Interface for screenshot methods with describe argument called `size` as object with options
  96587. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  96588. */
  96589. export interface IScreenshotSize {
  96590. /**
  96591. * number in pixels for canvas height
  96592. */
  96593. height?: number;
  96594. /**
  96595. * multiplier allowing render at a higher or lower resolution
  96596. * If value is defined then height and width will be ignored and taken from camera
  96597. */
  96598. precision?: number;
  96599. /**
  96600. * number in pixels for canvas width
  96601. */
  96602. width?: number;
  96603. }
  96604. }
  96605. declare module BABYLON {
  96606. interface IColor4Like {
  96607. r: float;
  96608. g: float;
  96609. b: float;
  96610. a: float;
  96611. }
  96612. /**
  96613. * Class containing a set of static utilities functions
  96614. */
  96615. export class Tools {
  96616. /**
  96617. * Gets or sets the base URL to use to load assets
  96618. */
  96619. static BaseUrl: string;
  96620. /**
  96621. * Enable/Disable Custom HTTP Request Headers globally.
  96622. * default = false
  96623. * @see CustomRequestHeaders
  96624. */
  96625. static UseCustomRequestHeaders: boolean;
  96626. /**
  96627. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  96628. * i.e. when loading files, where the server/service expects an Authorization header
  96629. */
  96630. static CustomRequestHeaders: {
  96631. [key: string]: string;
  96632. };
  96633. /**
  96634. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  96635. */
  96636. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  96637. /**
  96638. * Default behaviour for cors in the application.
  96639. * It can be a string if the expected behavior is identical in the entire app.
  96640. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  96641. */
  96642. static CorsBehavior: string | ((url: string | string[]) => string);
  96643. /**
  96644. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96645. * @ignorenaming
  96646. */
  96647. static UseFallbackTexture: boolean;
  96648. /**
  96649. * Use this object to register external classes like custom textures or material
  96650. * to allow the laoders to instantiate them
  96651. */
  96652. static RegisteredExternalClasses: {
  96653. [key: string]: Object;
  96654. };
  96655. /**
  96656. * Texture content used if a texture cannot loaded
  96657. * @ignorenaming
  96658. */
  96659. static fallbackTexture: string;
  96660. /**
  96661. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  96662. * @param u defines the coordinate on X axis
  96663. * @param v defines the coordinate on Y axis
  96664. * @param width defines the width of the source data
  96665. * @param height defines the height of the source data
  96666. * @param pixels defines the source byte array
  96667. * @param color defines the output color
  96668. */
  96669. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  96670. /**
  96671. * Interpolates between a and b via alpha
  96672. * @param a The lower value (returned when alpha = 0)
  96673. * @param b The upper value (returned when alpha = 1)
  96674. * @param alpha The interpolation-factor
  96675. * @return The mixed value
  96676. */
  96677. static Mix(a: number, b: number, alpha: number): number;
  96678. /**
  96679. * Tries to instantiate a new object from a given class name
  96680. * @param className defines the class name to instantiate
  96681. * @returns the new object or null if the system was not able to do the instantiation
  96682. */
  96683. static Instantiate(className: string): any;
  96684. /**
  96685. * Provides a slice function that will work even on IE
  96686. * @param data defines the array to slice
  96687. * @param start defines the start of the data (optional)
  96688. * @param end defines the end of the data (optional)
  96689. * @returns the new sliced array
  96690. */
  96691. static Slice<T>(data: T, start?: number, end?: number): T;
  96692. /**
  96693. * Polyfill for setImmediate
  96694. * @param action defines the action to execute after the current execution block
  96695. */
  96696. static SetImmediate(action: () => void): void;
  96697. /**
  96698. * Function indicating if a number is an exponent of 2
  96699. * @param value defines the value to test
  96700. * @returns true if the value is an exponent of 2
  96701. */
  96702. static IsExponentOfTwo(value: number): boolean;
  96703. private static _tmpFloatArray;
  96704. /**
  96705. * Returns the nearest 32-bit single precision float representation of a Number
  96706. * @param value A Number. If the parameter is of a different type, it will get converted
  96707. * to a number or to NaN if it cannot be converted
  96708. * @returns number
  96709. */
  96710. static FloatRound(value: number): number;
  96711. /**
  96712. * Extracts the filename from a path
  96713. * @param path defines the path to use
  96714. * @returns the filename
  96715. */
  96716. static GetFilename(path: string): string;
  96717. /**
  96718. * Extracts the "folder" part of a path (everything before the filename).
  96719. * @param uri The URI to extract the info from
  96720. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  96721. * @returns The "folder" part of the path
  96722. */
  96723. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  96724. /**
  96725. * Extracts text content from a DOM element hierarchy
  96726. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  96727. */
  96728. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  96729. /**
  96730. * Convert an angle in radians to degrees
  96731. * @param angle defines the angle to convert
  96732. * @returns the angle in degrees
  96733. */
  96734. static ToDegrees(angle: number): number;
  96735. /**
  96736. * Convert an angle in degrees to radians
  96737. * @param angle defines the angle to convert
  96738. * @returns the angle in radians
  96739. */
  96740. static ToRadians(angle: number): number;
  96741. /**
  96742. * Encode a buffer to a base64 string
  96743. * @param buffer defines the buffer to encode
  96744. * @returns the encoded string
  96745. */
  96746. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  96747. /**
  96748. * Returns an array if obj is not an array
  96749. * @param obj defines the object to evaluate as an array
  96750. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  96751. * @returns either obj directly if obj is an array or a new array containing obj
  96752. */
  96753. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  96754. /**
  96755. * Gets the pointer prefix to use
  96756. * @returns "pointer" if touch is enabled. Else returns "mouse"
  96757. */
  96758. static GetPointerPrefix(): string;
  96759. /**
  96760. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  96761. * @param url define the url we are trying
  96762. * @param element define the dom element where to configure the cors policy
  96763. */
  96764. static SetCorsBehavior(url: string | string[], element: {
  96765. crossOrigin: string | null;
  96766. }): void;
  96767. /**
  96768. * Removes unwanted characters from an url
  96769. * @param url defines the url to clean
  96770. * @returns the cleaned url
  96771. */
  96772. static CleanUrl(url: string): string;
  96773. /**
  96774. * Gets or sets a function used to pre-process url before using them to load assets
  96775. */
  96776. static PreprocessUrl: (url: string) => string;
  96777. /**
  96778. * Loads an image as an HTMLImageElement.
  96779. * @param input url string, ArrayBuffer, or Blob to load
  96780. * @param onLoad callback called when the image successfully loads
  96781. * @param onError callback called when the image fails to load
  96782. * @param offlineProvider offline provider for caching
  96783. * @returns the HTMLImageElement of the loaded image
  96784. */
  96785. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96786. /**
  96787. * Loads a file
  96788. * @param url url string, ArrayBuffer, or Blob to load
  96789. * @param onSuccess callback called when the file successfully loads
  96790. * @param onProgress callback called while file is loading (if the server supports this mode)
  96791. * @param offlineProvider defines the offline provider for caching
  96792. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96793. * @param onError callback called when the file fails to load
  96794. * @returns a file request object
  96795. */
  96796. 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;
  96797. /**
  96798. * Loads a file from a url
  96799. * @param url the file url to load
  96800. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96801. */
  96802. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96803. /**
  96804. * Load a script (identified by an url). When the url returns, the
  96805. * content of this file is added into a new script element, attached to the DOM (body element)
  96806. * @param scriptUrl defines the url of the script to laod
  96807. * @param onSuccess defines the callback called when the script is loaded
  96808. * @param onError defines the callback to call if an error occurs
  96809. * @param scriptId defines the id of the script element
  96810. */
  96811. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96812. /**
  96813. * Load an asynchronous script (identified by an url). When the url returns, the
  96814. * content of this file is added into a new script element, attached to the DOM (body element)
  96815. * @param scriptUrl defines the url of the script to laod
  96816. * @param scriptId defines the id of the script element
  96817. * @returns a promise request object
  96818. */
  96819. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96820. /**
  96821. * Loads a file from a blob
  96822. * @param fileToLoad defines the blob to use
  96823. * @param callback defines the callback to call when data is loaded
  96824. * @param progressCallback defines the callback to call during loading process
  96825. * @returns a file request object
  96826. */
  96827. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96828. /**
  96829. * Loads a file
  96830. * @param fileToLoad defines the file to load
  96831. * @param callback defines the callback to call when data is loaded
  96832. * @param progressCallBack defines the callback to call during loading process
  96833. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96834. * @returns a file request object
  96835. */
  96836. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96837. /**
  96838. * Creates a data url from a given string content
  96839. * @param content defines the content to convert
  96840. * @returns the new data url link
  96841. */
  96842. static FileAsURL(content: string): string;
  96843. /**
  96844. * Format the given number to a specific decimal format
  96845. * @param value defines the number to format
  96846. * @param decimals defines the number of decimals to use
  96847. * @returns the formatted string
  96848. */
  96849. static Format(value: number, decimals?: number): string;
  96850. /**
  96851. * Tries to copy an object by duplicating every property
  96852. * @param source defines the source object
  96853. * @param destination defines the target object
  96854. * @param doNotCopyList defines a list of properties to avoid
  96855. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96856. */
  96857. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  96858. /**
  96859. * Gets a boolean indicating if the given object has no own property
  96860. * @param obj defines the object to test
  96861. * @returns true if object has no own property
  96862. */
  96863. static IsEmpty(obj: any): boolean;
  96864. /**
  96865. * Function used to register events at window level
  96866. * @param windowElement defines the Window object to use
  96867. * @param events defines the events to register
  96868. */
  96869. static RegisterTopRootEvents(windowElement: Window, events: {
  96870. name: string;
  96871. handler: Nullable<(e: FocusEvent) => any>;
  96872. }[]): void;
  96873. /**
  96874. * Function used to unregister events from window level
  96875. * @param windowElement defines the Window object to use
  96876. * @param events defines the events to unregister
  96877. */
  96878. static UnregisterTopRootEvents(windowElement: Window, events: {
  96879. name: string;
  96880. handler: Nullable<(e: FocusEvent) => any>;
  96881. }[]): void;
  96882. /**
  96883. * @ignore
  96884. */
  96885. static _ScreenshotCanvas: HTMLCanvasElement;
  96886. /**
  96887. * Dumps the current bound framebuffer
  96888. * @param width defines the rendering width
  96889. * @param height defines the rendering height
  96890. * @param engine defines the hosting engine
  96891. * @param successCallback defines the callback triggered once the data are available
  96892. * @param mimeType defines the mime type of the result
  96893. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  96894. */
  96895. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96896. /**
  96897. * Converts the canvas data to blob.
  96898. * This acts as a polyfill for browsers not supporting the to blob function.
  96899. * @param canvas Defines the canvas to extract the data from
  96900. * @param successCallback Defines the callback triggered once the data are available
  96901. * @param mimeType Defines the mime type of the result
  96902. */
  96903. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  96904. /**
  96905. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  96906. * @param successCallback defines the callback triggered once the data are available
  96907. * @param mimeType defines the mime type of the result
  96908. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  96909. */
  96910. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96911. /**
  96912. * Downloads a blob in the browser
  96913. * @param blob defines the blob to download
  96914. * @param fileName defines the name of the downloaded file
  96915. */
  96916. static Download(blob: Blob, fileName: string): void;
  96917. /**
  96918. * Captures a screenshot of the current rendering
  96919. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96920. * @param engine defines the rendering engine
  96921. * @param camera defines the source camera
  96922. * @param size This parameter can be set to a single number or to an object with the
  96923. * following (optional) properties: precision, width, height. If a single number is passed,
  96924. * it will be used for both width and height. If an object is passed, the screenshot size
  96925. * will be derived from the parameters. The precision property is a multiplier allowing
  96926. * rendering at a higher or lower resolution
  96927. * @param successCallback defines the callback receives a single parameter which contains the
  96928. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96929. * src parameter of an <img> to display it
  96930. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96931. * Check your browser for supported MIME types
  96932. */
  96933. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  96934. /**
  96935. * Captures a screenshot of the current rendering
  96936. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96937. * @param engine defines the rendering engine
  96938. * @param camera defines the source camera
  96939. * @param size This parameter can be set to a single number or to an object with the
  96940. * following (optional) properties: precision, width, height. If a single number is passed,
  96941. * it will be used for both width and height. If an object is passed, the screenshot size
  96942. * will be derived from the parameters. The precision property is a multiplier allowing
  96943. * rendering at a higher or lower resolution
  96944. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96945. * Check your browser for supported MIME types
  96946. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96947. * to the src parameter of an <img> to display it
  96948. */
  96949. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  96950. /**
  96951. * Generates an image screenshot from the specified camera.
  96952. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96953. * @param engine The engine to use for rendering
  96954. * @param camera The camera to use for rendering
  96955. * @param size This parameter can be set to a single number or to an object with the
  96956. * following (optional) properties: precision, width, height. If a single number is passed,
  96957. * it will be used for both width and height. If an object is passed, the screenshot size
  96958. * will be derived from the parameters. The precision property is a multiplier allowing
  96959. * rendering at a higher or lower resolution
  96960. * @param successCallback The callback receives a single parameter which contains the
  96961. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96962. * src parameter of an <img> to display it
  96963. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96964. * Check your browser for supported MIME types
  96965. * @param samples Texture samples (default: 1)
  96966. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96967. * @param fileName A name for for the downloaded file.
  96968. */
  96969. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  96970. /**
  96971. * Generates an image screenshot from the specified camera.
  96972. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96973. * @param engine The engine to use for rendering
  96974. * @param camera The camera to use for rendering
  96975. * @param size This parameter can be set to a single number or to an object with the
  96976. * following (optional) properties: precision, width, height. If a single number is passed,
  96977. * it will be used for both width and height. If an object is passed, the screenshot size
  96978. * will be derived from the parameters. The precision property is a multiplier allowing
  96979. * rendering at a higher or lower resolution
  96980. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96981. * Check your browser for supported MIME types
  96982. * @param samples Texture samples (default: 1)
  96983. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96984. * @param fileName A name for for the downloaded file.
  96985. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96986. * to the src parameter of an <img> to display it
  96987. */
  96988. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  96989. /**
  96990. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96991. * Be aware Math.random() could cause collisions, but:
  96992. * "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"
  96993. * @returns a pseudo random id
  96994. */
  96995. static RandomId(): string;
  96996. /**
  96997. * Test if the given uri is a base64 string
  96998. * @param uri The uri to test
  96999. * @return True if the uri is a base64 string or false otherwise
  97000. */
  97001. static IsBase64(uri: string): boolean;
  97002. /**
  97003. * Decode the given base64 uri.
  97004. * @param uri The uri to decode
  97005. * @return The decoded base64 data.
  97006. */
  97007. static DecodeBase64(uri: string): ArrayBuffer;
  97008. /**
  97009. * Gets the absolute url.
  97010. * @param url the input url
  97011. * @return the absolute url
  97012. */
  97013. static GetAbsoluteUrl(url: string): string;
  97014. /**
  97015. * No log
  97016. */
  97017. static readonly NoneLogLevel: number;
  97018. /**
  97019. * Only message logs
  97020. */
  97021. static readonly MessageLogLevel: number;
  97022. /**
  97023. * Only warning logs
  97024. */
  97025. static readonly WarningLogLevel: number;
  97026. /**
  97027. * Only error logs
  97028. */
  97029. static readonly ErrorLogLevel: number;
  97030. /**
  97031. * All logs
  97032. */
  97033. static readonly AllLogLevel: number;
  97034. /**
  97035. * Gets a value indicating the number of loading errors
  97036. * @ignorenaming
  97037. */
  97038. static readonly errorsCount: number;
  97039. /**
  97040. * Callback called when a new log is added
  97041. */
  97042. static OnNewCacheEntry: (entry: string) => void;
  97043. /**
  97044. * Log a message to the console
  97045. * @param message defines the message to log
  97046. */
  97047. static Log(message: string): void;
  97048. /**
  97049. * Write a warning message to the console
  97050. * @param message defines the message to log
  97051. */
  97052. static Warn(message: string): void;
  97053. /**
  97054. * Write an error message to the console
  97055. * @param message defines the message to log
  97056. */
  97057. static Error(message: string): void;
  97058. /**
  97059. * Gets current log cache (list of logs)
  97060. */
  97061. static readonly LogCache: string;
  97062. /**
  97063. * Clears the log cache
  97064. */
  97065. static ClearLogCache(): void;
  97066. /**
  97067. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97068. */
  97069. static LogLevels: number;
  97070. /**
  97071. * Checks if the window object exists
  97072. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  97073. */
  97074. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  97075. /**
  97076. * No performance log
  97077. */
  97078. static readonly PerformanceNoneLogLevel: number;
  97079. /**
  97080. * Use user marks to log performance
  97081. */
  97082. static readonly PerformanceUserMarkLogLevel: number;
  97083. /**
  97084. * Log performance to the console
  97085. */
  97086. static readonly PerformanceConsoleLogLevel: number;
  97087. private static _performance;
  97088. /**
  97089. * Sets the current performance log level
  97090. */
  97091. static PerformanceLogLevel: number;
  97092. private static _StartPerformanceCounterDisabled;
  97093. private static _EndPerformanceCounterDisabled;
  97094. private static _StartUserMark;
  97095. private static _EndUserMark;
  97096. private static _StartPerformanceConsole;
  97097. private static _EndPerformanceConsole;
  97098. /**
  97099. * Starts a performance counter
  97100. */
  97101. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97102. /**
  97103. * Ends a specific performance coutner
  97104. */
  97105. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97106. /**
  97107. * Gets either window.performance.now() if supported or Date.now() else
  97108. */
  97109. static readonly Now: number;
  97110. /**
  97111. * This method will return the name of the class used to create the instance of the given object.
  97112. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  97113. * @param object the object to get the class name from
  97114. * @param isType defines if the object is actually a type
  97115. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  97116. */
  97117. static GetClassName(object: any, isType?: boolean): string;
  97118. /**
  97119. * Gets the first element of an array satisfying a given predicate
  97120. * @param array defines the array to browse
  97121. * @param predicate defines the predicate to use
  97122. * @returns null if not found or the element
  97123. */
  97124. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  97125. /**
  97126. * This method will return the name of the full name of the class, including its owning module (if any).
  97127. * 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).
  97128. * @param object the object to get the class name from
  97129. * @param isType defines if the object is actually a type
  97130. * @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.
  97131. * @ignorenaming
  97132. */
  97133. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  97134. /**
  97135. * Returns a promise that resolves after the given amount of time.
  97136. * @param delay Number of milliseconds to delay
  97137. * @returns Promise that resolves after the given amount of time
  97138. */
  97139. static DelayAsync(delay: number): Promise<void>;
  97140. }
  97141. /**
  97142. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  97143. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  97144. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  97145. * @param name The name of the class, case should be preserved
  97146. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  97147. */
  97148. export function className(name: string, module?: string): (target: Object) => void;
  97149. /**
  97150. * An implementation of a loop for asynchronous functions.
  97151. */
  97152. export class AsyncLoop {
  97153. /**
  97154. * Defines the number of iterations for the loop
  97155. */
  97156. iterations: number;
  97157. /**
  97158. * Defines the current index of the loop.
  97159. */
  97160. index: number;
  97161. private _done;
  97162. private _fn;
  97163. private _successCallback;
  97164. /**
  97165. * Constructor.
  97166. * @param iterations the number of iterations.
  97167. * @param func the function to run each iteration
  97168. * @param successCallback the callback that will be called upon succesful execution
  97169. * @param offset starting offset.
  97170. */
  97171. constructor(
  97172. /**
  97173. * Defines the number of iterations for the loop
  97174. */
  97175. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  97176. /**
  97177. * Execute the next iteration. Must be called after the last iteration was finished.
  97178. */
  97179. executeNext(): void;
  97180. /**
  97181. * Break the loop and run the success callback.
  97182. */
  97183. breakLoop(): void;
  97184. /**
  97185. * Create and run an async loop.
  97186. * @param iterations the number of iterations.
  97187. * @param fn the function to run each iteration
  97188. * @param successCallback the callback that will be called upon succesful execution
  97189. * @param offset starting offset.
  97190. * @returns the created async loop object
  97191. */
  97192. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  97193. /**
  97194. * A for-loop that will run a given number of iterations synchronous and the rest async.
  97195. * @param iterations total number of iterations
  97196. * @param syncedIterations number of synchronous iterations in each async iteration.
  97197. * @param fn the function to call each iteration.
  97198. * @param callback a success call back that will be called when iterating stops.
  97199. * @param breakFunction a break condition (optional)
  97200. * @param timeout timeout settings for the setTimeout function. default - 0.
  97201. * @returns the created async loop object
  97202. */
  97203. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  97204. }
  97205. }
  97206. declare module BABYLON {
  97207. /** @hidden */
  97208. export interface ICollisionCoordinator {
  97209. createCollider(): Collider;
  97210. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97211. init(scene: Scene): void;
  97212. }
  97213. /** @hidden */
  97214. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  97215. private _scene;
  97216. private _scaledPosition;
  97217. private _scaledVelocity;
  97218. private _finalPosition;
  97219. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97220. createCollider(): Collider;
  97221. init(scene: Scene): void;
  97222. private _collideWithWorld;
  97223. }
  97224. }
  97225. declare module BABYLON {
  97226. /**
  97227. * Class used to manage all inputs for the scene.
  97228. */
  97229. export class InputManager {
  97230. /** The distance in pixel that you have to move to prevent some events */
  97231. static DragMovementThreshold: number;
  97232. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  97233. static LongPressDelay: number;
  97234. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  97235. static DoubleClickDelay: number;
  97236. /** If you need to check double click without raising a single click at first click, enable this flag */
  97237. static ExclusiveDoubleClickMode: boolean;
  97238. private _wheelEventName;
  97239. private _onPointerMove;
  97240. private _onPointerDown;
  97241. private _onPointerUp;
  97242. private _initClickEvent;
  97243. private _initActionManager;
  97244. private _delayedSimpleClick;
  97245. private _delayedSimpleClickTimeout;
  97246. private _previousDelayedSimpleClickTimeout;
  97247. private _meshPickProceed;
  97248. private _previousButtonPressed;
  97249. private _currentPickResult;
  97250. private _previousPickResult;
  97251. private _totalPointersPressed;
  97252. private _doubleClickOccured;
  97253. private _pointerOverMesh;
  97254. private _pickedDownMesh;
  97255. private _pickedUpMesh;
  97256. private _pointerX;
  97257. private _pointerY;
  97258. private _unTranslatedPointerX;
  97259. private _unTranslatedPointerY;
  97260. private _startingPointerPosition;
  97261. private _previousStartingPointerPosition;
  97262. private _startingPointerTime;
  97263. private _previousStartingPointerTime;
  97264. private _pointerCaptures;
  97265. private _onKeyDown;
  97266. private _onKeyUp;
  97267. private _onCanvasFocusObserver;
  97268. private _onCanvasBlurObserver;
  97269. private _scene;
  97270. /**
  97271. * Creates a new InputManager
  97272. * @param scene defines the hosting scene
  97273. */
  97274. constructor(scene: Scene);
  97275. /**
  97276. * Gets the mesh that is currently under the pointer
  97277. */
  97278. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97279. /**
  97280. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  97281. */
  97282. readonly unTranslatedPointer: Vector2;
  97283. /**
  97284. * Gets or sets the current on-screen X position of the pointer
  97285. */
  97286. pointerX: number;
  97287. /**
  97288. * Gets or sets the current on-screen Y position of the pointer
  97289. */
  97290. pointerY: number;
  97291. private _updatePointerPosition;
  97292. private _processPointerMove;
  97293. private _setRayOnPointerInfo;
  97294. private _checkPrePointerObservable;
  97295. /**
  97296. * Use this method to simulate a pointer move on a mesh
  97297. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97298. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97299. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97300. */
  97301. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97302. /**
  97303. * Use this method to simulate a pointer down on a mesh
  97304. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97305. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97306. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97307. */
  97308. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97309. private _processPointerDown;
  97310. /** @hidden */
  97311. _isPointerSwiping(): boolean;
  97312. /**
  97313. * Use this method to simulate a pointer up on a mesh
  97314. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97315. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97316. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97317. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97318. */
  97319. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  97320. private _processPointerUp;
  97321. /**
  97322. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97323. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97324. * @returns true if the pointer was captured
  97325. */
  97326. isPointerCaptured(pointerId?: number): boolean;
  97327. /**
  97328. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97329. * @param attachUp defines if you want to attach events to pointerup
  97330. * @param attachDown defines if you want to attach events to pointerdown
  97331. * @param attachMove defines if you want to attach events to pointermove
  97332. */
  97333. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97334. /**
  97335. * Detaches all event handlers
  97336. */
  97337. detachControl(): void;
  97338. /**
  97339. * Force the value of meshUnderPointer
  97340. * @param mesh defines the mesh to use
  97341. */
  97342. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  97343. /**
  97344. * Gets the mesh under the pointer
  97345. * @returns a Mesh or null if no mesh is under the pointer
  97346. */
  97347. getPointerOverMesh(): Nullable<AbstractMesh>;
  97348. }
  97349. }
  97350. declare module BABYLON {
  97351. /**
  97352. * Helper class used to generate session unique ID
  97353. */
  97354. export class UniqueIdGenerator {
  97355. private static _UniqueIdCounter;
  97356. /**
  97357. * Gets an unique (relatively to the current scene) Id
  97358. */
  97359. static readonly UniqueId: number;
  97360. }
  97361. }
  97362. declare module BABYLON {
  97363. /**
  97364. * This class defines the direct association between an animation and a target
  97365. */
  97366. export class TargetedAnimation {
  97367. /**
  97368. * Animation to perform
  97369. */
  97370. animation: Animation;
  97371. /**
  97372. * Target to animate
  97373. */
  97374. target: any;
  97375. /**
  97376. * Serialize the object
  97377. * @returns the JSON object representing the current entity
  97378. */
  97379. serialize(): any;
  97380. }
  97381. /**
  97382. * Use this class to create coordinated animations on multiple targets
  97383. */
  97384. export class AnimationGroup implements IDisposable {
  97385. /** The name of the animation group */
  97386. name: string;
  97387. private _scene;
  97388. private _targetedAnimations;
  97389. private _animatables;
  97390. private _from;
  97391. private _to;
  97392. private _isStarted;
  97393. private _isPaused;
  97394. private _speedRatio;
  97395. private _loopAnimation;
  97396. /**
  97397. * Gets or sets the unique id of the node
  97398. */
  97399. uniqueId: number;
  97400. /**
  97401. * This observable will notify when one animation have ended
  97402. */
  97403. onAnimationEndObservable: Observable<TargetedAnimation>;
  97404. /**
  97405. * Observer raised when one animation loops
  97406. */
  97407. onAnimationLoopObservable: Observable<TargetedAnimation>;
  97408. /**
  97409. * This observable will notify when all animations have ended.
  97410. */
  97411. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  97412. /**
  97413. * This observable will notify when all animations have paused.
  97414. */
  97415. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  97416. /**
  97417. * This observable will notify when all animations are playing.
  97418. */
  97419. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  97420. /**
  97421. * Gets the first frame
  97422. */
  97423. readonly from: number;
  97424. /**
  97425. * Gets the last frame
  97426. */
  97427. readonly to: number;
  97428. /**
  97429. * Define if the animations are started
  97430. */
  97431. readonly isStarted: boolean;
  97432. /**
  97433. * Gets a value indicating that the current group is playing
  97434. */
  97435. readonly isPlaying: boolean;
  97436. /**
  97437. * Gets or sets the speed ratio to use for all animations
  97438. */
  97439. /**
  97440. * Gets or sets the speed ratio to use for all animations
  97441. */
  97442. speedRatio: number;
  97443. /**
  97444. * Gets or sets if all animations should loop or not
  97445. */
  97446. loopAnimation: boolean;
  97447. /**
  97448. * Gets the targeted animations for this animation group
  97449. */
  97450. readonly targetedAnimations: Array<TargetedAnimation>;
  97451. /**
  97452. * returning the list of animatables controlled by this animation group.
  97453. */
  97454. readonly animatables: Array<Animatable>;
  97455. /**
  97456. * Instantiates a new Animation Group.
  97457. * This helps managing several animations at once.
  97458. * @see http://doc.babylonjs.com/how_to/group
  97459. * @param name Defines the name of the group
  97460. * @param scene Defines the scene the group belongs to
  97461. */
  97462. constructor(
  97463. /** The name of the animation group */
  97464. name: string, scene?: Nullable<Scene>);
  97465. /**
  97466. * Add an animation (with its target) in the group
  97467. * @param animation defines the animation we want to add
  97468. * @param target defines the target of the animation
  97469. * @returns the TargetedAnimation object
  97470. */
  97471. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  97472. /**
  97473. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  97474. * It can add constant keys at begin or end
  97475. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  97476. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  97477. * @returns the animation group
  97478. */
  97479. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  97480. /**
  97481. * Start all animations on given targets
  97482. * @param loop defines if animations must loop
  97483. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  97484. * @param from defines the from key (optional)
  97485. * @param to defines the to key (optional)
  97486. * @returns the current animation group
  97487. */
  97488. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  97489. /**
  97490. * Pause all animations
  97491. * @returns the animation group
  97492. */
  97493. pause(): AnimationGroup;
  97494. /**
  97495. * Play all animations to initial state
  97496. * This function will start() the animations if they were not started or will restart() them if they were paused
  97497. * @param loop defines if animations must loop
  97498. * @returns the animation group
  97499. */
  97500. play(loop?: boolean): AnimationGroup;
  97501. /**
  97502. * Reset all animations to initial state
  97503. * @returns the animation group
  97504. */
  97505. reset(): AnimationGroup;
  97506. /**
  97507. * Restart animations from key 0
  97508. * @returns the animation group
  97509. */
  97510. restart(): AnimationGroup;
  97511. /**
  97512. * Stop all animations
  97513. * @returns the animation group
  97514. */
  97515. stop(): AnimationGroup;
  97516. /**
  97517. * Set animation weight for all animatables
  97518. * @param weight defines the weight to use
  97519. * @return the animationGroup
  97520. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97521. */
  97522. setWeightForAllAnimatables(weight: number): AnimationGroup;
  97523. /**
  97524. * Synchronize and normalize all animatables with a source animatable
  97525. * @param root defines the root animatable to synchronize with
  97526. * @return the animationGroup
  97527. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97528. */
  97529. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  97530. /**
  97531. * Goes to a specific frame in this animation group
  97532. * @param frame the frame number to go to
  97533. * @return the animationGroup
  97534. */
  97535. goToFrame(frame: number): AnimationGroup;
  97536. /**
  97537. * Dispose all associated resources
  97538. */
  97539. dispose(): void;
  97540. private _checkAnimationGroupEnded;
  97541. /**
  97542. * Clone the current animation group and returns a copy
  97543. * @param newName defines the name of the new group
  97544. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  97545. * @returns the new aniamtion group
  97546. */
  97547. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  97548. /**
  97549. * Serializes the animationGroup to an object
  97550. * @returns Serialized object
  97551. */
  97552. serialize(): any;
  97553. /**
  97554. * Returns a new AnimationGroup object parsed from the source provided.
  97555. * @param parsedAnimationGroup defines the source
  97556. * @param scene defines the scene that will receive the animationGroup
  97557. * @returns a new AnimationGroup
  97558. */
  97559. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  97560. /**
  97561. * Returns the string "AnimationGroup"
  97562. * @returns "AnimationGroup"
  97563. */
  97564. getClassName(): string;
  97565. /**
  97566. * Creates a detailled string about the object
  97567. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  97568. * @returns a string representing the object
  97569. */
  97570. toString(fullDetails?: boolean): string;
  97571. }
  97572. }
  97573. declare module BABYLON {
  97574. /**
  97575. * Define an interface for all classes that will hold resources
  97576. */
  97577. export interface IDisposable {
  97578. /**
  97579. * Releases all held resources
  97580. */
  97581. dispose(): void;
  97582. }
  97583. /** Interface defining initialization parameters for Scene class */
  97584. export interface SceneOptions {
  97585. /**
  97586. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  97587. * It will improve performance when the number of geometries becomes important.
  97588. */
  97589. useGeometryUniqueIdsMap?: boolean;
  97590. /**
  97591. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  97592. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97593. */
  97594. useMaterialMeshMap?: boolean;
  97595. /**
  97596. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  97597. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97598. */
  97599. useClonedMeshhMap?: boolean;
  97600. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  97601. virtual?: boolean;
  97602. }
  97603. /**
  97604. * Represents a scene to be rendered by the engine.
  97605. * @see http://doc.babylonjs.com/features/scene
  97606. */
  97607. export class Scene extends AbstractScene implements IAnimatable {
  97608. /** The fog is deactivated */
  97609. static readonly FOGMODE_NONE: number;
  97610. /** The fog density is following an exponential function */
  97611. static readonly FOGMODE_EXP: number;
  97612. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  97613. static readonly FOGMODE_EXP2: number;
  97614. /** The fog density is following a linear function. */
  97615. static readonly FOGMODE_LINEAR: number;
  97616. /**
  97617. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  97618. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97619. */
  97620. static MinDeltaTime: number;
  97621. /**
  97622. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  97623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97624. */
  97625. static MaxDeltaTime: number;
  97626. /**
  97627. * Factory used to create the default material.
  97628. * @param name The name of the material to create
  97629. * @param scene The scene to create the material for
  97630. * @returns The default material
  97631. */
  97632. static DefaultMaterialFactory(scene: Scene): Material;
  97633. /**
  97634. * Factory used to create the a collision coordinator.
  97635. * @returns The collision coordinator
  97636. */
  97637. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  97638. /** @hidden */
  97639. _inputManager: InputManager;
  97640. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  97641. cameraToUseForPointers: Nullable<Camera>;
  97642. /** @hidden */
  97643. readonly _isScene: boolean;
  97644. /**
  97645. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  97646. */
  97647. autoClear: boolean;
  97648. /**
  97649. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  97650. */
  97651. autoClearDepthAndStencil: boolean;
  97652. /**
  97653. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  97654. */
  97655. clearColor: Color4;
  97656. /**
  97657. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  97658. */
  97659. ambientColor: Color3;
  97660. /**
  97661. * This is use to store the default BRDF lookup for PBR materials in your scene.
  97662. * It should only be one of the following (if not the default embedded one):
  97663. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  97664. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  97665. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  97666. * The material properties need to be setup according to the type of texture in use.
  97667. */
  97668. environmentBRDFTexture: BaseTexture;
  97669. /** @hidden */
  97670. protected _environmentTexture: Nullable<BaseTexture>;
  97671. /**
  97672. * Texture used in all pbr material as the reflection texture.
  97673. * As in the majority of the scene they are the same (exception for multi room and so on),
  97674. * this is easier to reference from here than from all the materials.
  97675. */
  97676. /**
  97677. * Texture used in all pbr material as the reflection texture.
  97678. * As in the majority of the scene they are the same (exception for multi room and so on),
  97679. * this is easier to set here than in all the materials.
  97680. */
  97681. environmentTexture: Nullable<BaseTexture>;
  97682. /** @hidden */
  97683. protected _environmentIntensity: number;
  97684. /**
  97685. * Intensity of the environment in all pbr material.
  97686. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97687. * As in the majority of the scene they are the same (exception for multi room and so on),
  97688. * this is easier to reference from here than from all the materials.
  97689. */
  97690. /**
  97691. * Intensity of the environment in all pbr material.
  97692. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97693. * As in the majority of the scene they are the same (exception for multi room and so on),
  97694. * this is easier to set here than in all the materials.
  97695. */
  97696. environmentIntensity: number;
  97697. /** @hidden */
  97698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97699. /**
  97700. * Default image processing configuration used either in the rendering
  97701. * Forward main pass or through the imageProcessingPostProcess if present.
  97702. * As in the majority of the scene they are the same (exception for multi camera),
  97703. * this is easier to reference from here than from all the materials and post process.
  97704. *
  97705. * No setter as we it is a shared configuration, you can set the values instead.
  97706. */
  97707. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  97708. private _forceWireframe;
  97709. /**
  97710. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  97711. */
  97712. forceWireframe: boolean;
  97713. private _forcePointsCloud;
  97714. /**
  97715. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  97716. */
  97717. forcePointsCloud: boolean;
  97718. /**
  97719. * Gets or sets the active clipplane 1
  97720. */
  97721. clipPlane: Nullable<Plane>;
  97722. /**
  97723. * Gets or sets the active clipplane 2
  97724. */
  97725. clipPlane2: Nullable<Plane>;
  97726. /**
  97727. * Gets or sets the active clipplane 3
  97728. */
  97729. clipPlane3: Nullable<Plane>;
  97730. /**
  97731. * Gets or sets the active clipplane 4
  97732. */
  97733. clipPlane4: Nullable<Plane>;
  97734. /**
  97735. * Gets or sets a boolean indicating if animations are enabled
  97736. */
  97737. animationsEnabled: boolean;
  97738. private _animationPropertiesOverride;
  97739. /**
  97740. * Gets or sets the animation properties override
  97741. */
  97742. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97743. /**
  97744. * Gets or sets a boolean indicating if a constant deltatime has to be used
  97745. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  97746. */
  97747. useConstantAnimationDeltaTime: boolean;
  97748. /**
  97749. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  97750. * Please note that it requires to run a ray cast through the scene on every frame
  97751. */
  97752. constantlyUpdateMeshUnderPointer: boolean;
  97753. /**
  97754. * Defines the HTML cursor to use when hovering over interactive elements
  97755. */
  97756. hoverCursor: string;
  97757. /**
  97758. * Defines the HTML default cursor to use (empty by default)
  97759. */
  97760. defaultCursor: string;
  97761. /**
  97762. * This is used to call preventDefault() on pointer down
  97763. * in order to block unwanted artifacts like system double clicks
  97764. */
  97765. preventDefaultOnPointerDown: boolean;
  97766. /**
  97767. * This is used to call preventDefault() on pointer up
  97768. * in order to block unwanted artifacts like system double clicks
  97769. */
  97770. preventDefaultOnPointerUp: boolean;
  97771. /**
  97772. * Gets or sets user defined metadata
  97773. */
  97774. metadata: any;
  97775. /**
  97776. * For internal use only. Please do not use.
  97777. */
  97778. reservedDataStore: any;
  97779. /**
  97780. * Gets the name of the plugin used to load this scene (null by default)
  97781. */
  97782. loadingPluginName: string;
  97783. /**
  97784. * Use this array to add regular expressions used to disable offline support for specific urls
  97785. */
  97786. disableOfflineSupportExceptionRules: RegExp[];
  97787. /**
  97788. * An event triggered when the scene is disposed.
  97789. */
  97790. onDisposeObservable: Observable<Scene>;
  97791. private _onDisposeObserver;
  97792. /** Sets a function to be executed when this scene is disposed. */
  97793. onDispose: () => void;
  97794. /**
  97795. * An event triggered before rendering the scene (right after animations and physics)
  97796. */
  97797. onBeforeRenderObservable: Observable<Scene>;
  97798. private _onBeforeRenderObserver;
  97799. /** Sets a function to be executed before rendering this scene */
  97800. beforeRender: Nullable<() => void>;
  97801. /**
  97802. * An event triggered after rendering the scene
  97803. */
  97804. onAfterRenderObservable: Observable<Scene>;
  97805. /**
  97806. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97807. */
  97808. onAfterRenderCameraObservable: Observable<Camera>;
  97809. private _onAfterRenderObserver;
  97810. /** Sets a function to be executed after rendering this scene */
  97811. afterRender: Nullable<() => void>;
  97812. /**
  97813. * An event triggered before animating the scene
  97814. */
  97815. onBeforeAnimationsObservable: Observable<Scene>;
  97816. /**
  97817. * An event triggered after animations processing
  97818. */
  97819. onAfterAnimationsObservable: Observable<Scene>;
  97820. /**
  97821. * An event triggered before draw calls are ready to be sent
  97822. */
  97823. onBeforeDrawPhaseObservable: Observable<Scene>;
  97824. /**
  97825. * An event triggered after draw calls have been sent
  97826. */
  97827. onAfterDrawPhaseObservable: Observable<Scene>;
  97828. /**
  97829. * An event triggered when the scene is ready
  97830. */
  97831. onReadyObservable: Observable<Scene>;
  97832. /**
  97833. * An event triggered before rendering a camera
  97834. */
  97835. onBeforeCameraRenderObservable: Observable<Camera>;
  97836. private _onBeforeCameraRenderObserver;
  97837. /** Sets a function to be executed before rendering a camera*/
  97838. beforeCameraRender: () => void;
  97839. /**
  97840. * An event triggered after rendering a camera
  97841. */
  97842. onAfterCameraRenderObservable: Observable<Camera>;
  97843. private _onAfterCameraRenderObserver;
  97844. /** Sets a function to be executed after rendering a camera*/
  97845. afterCameraRender: () => void;
  97846. /**
  97847. * An event triggered when active meshes evaluation is about to start
  97848. */
  97849. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  97850. /**
  97851. * An event triggered when active meshes evaluation is done
  97852. */
  97853. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  97854. /**
  97855. * An event triggered when particles rendering is about to start
  97856. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97857. */
  97858. onBeforeParticlesRenderingObservable: Observable<Scene>;
  97859. /**
  97860. * An event triggered when particles rendering is done
  97861. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97862. */
  97863. onAfterParticlesRenderingObservable: Observable<Scene>;
  97864. /**
  97865. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  97866. */
  97867. onDataLoadedObservable: Observable<Scene>;
  97868. /**
  97869. * An event triggered when a camera is created
  97870. */
  97871. onNewCameraAddedObservable: Observable<Camera>;
  97872. /**
  97873. * An event triggered when a camera is removed
  97874. */
  97875. onCameraRemovedObservable: Observable<Camera>;
  97876. /**
  97877. * An event triggered when a light is created
  97878. */
  97879. onNewLightAddedObservable: Observable<Light>;
  97880. /**
  97881. * An event triggered when a light is removed
  97882. */
  97883. onLightRemovedObservable: Observable<Light>;
  97884. /**
  97885. * An event triggered when a geometry is created
  97886. */
  97887. onNewGeometryAddedObservable: Observable<Geometry>;
  97888. /**
  97889. * An event triggered when a geometry is removed
  97890. */
  97891. onGeometryRemovedObservable: Observable<Geometry>;
  97892. /**
  97893. * An event triggered when a transform node is created
  97894. */
  97895. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  97896. /**
  97897. * An event triggered when a transform node is removed
  97898. */
  97899. onTransformNodeRemovedObservable: Observable<TransformNode>;
  97900. /**
  97901. * An event triggered when a mesh is created
  97902. */
  97903. onNewMeshAddedObservable: Observable<AbstractMesh>;
  97904. /**
  97905. * An event triggered when a mesh is removed
  97906. */
  97907. onMeshRemovedObservable: Observable<AbstractMesh>;
  97908. /**
  97909. * An event triggered when a skeleton is created
  97910. */
  97911. onNewSkeletonAddedObservable: Observable<Skeleton>;
  97912. /**
  97913. * An event triggered when a skeleton is removed
  97914. */
  97915. onSkeletonRemovedObservable: Observable<Skeleton>;
  97916. /**
  97917. * An event triggered when a material is created
  97918. */
  97919. onNewMaterialAddedObservable: Observable<Material>;
  97920. /**
  97921. * An event triggered when a material is removed
  97922. */
  97923. onMaterialRemovedObservable: Observable<Material>;
  97924. /**
  97925. * An event triggered when a texture is created
  97926. */
  97927. onNewTextureAddedObservable: Observable<BaseTexture>;
  97928. /**
  97929. * An event triggered when a texture is removed
  97930. */
  97931. onTextureRemovedObservable: Observable<BaseTexture>;
  97932. /**
  97933. * An event triggered when render targets are about to be rendered
  97934. * Can happen multiple times per frame.
  97935. */
  97936. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  97937. /**
  97938. * An event triggered when render targets were rendered.
  97939. * Can happen multiple times per frame.
  97940. */
  97941. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  97942. /**
  97943. * An event triggered before calculating deterministic simulation step
  97944. */
  97945. onBeforeStepObservable: Observable<Scene>;
  97946. /**
  97947. * An event triggered after calculating deterministic simulation step
  97948. */
  97949. onAfterStepObservable: Observable<Scene>;
  97950. /**
  97951. * An event triggered when the activeCamera property is updated
  97952. */
  97953. onActiveCameraChanged: Observable<Scene>;
  97954. /**
  97955. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  97956. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97957. * 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)
  97958. */
  97959. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97960. /**
  97961. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  97962. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97963. * 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)
  97964. */
  97965. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97966. /**
  97967. * This Observable will when a mesh has been imported into the scene.
  97968. */
  97969. onMeshImportedObservable: Observable<AbstractMesh>;
  97970. /**
  97971. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  97972. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  97973. */
  97974. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  97975. /** @hidden */
  97976. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  97977. /**
  97978. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  97979. */
  97980. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  97981. /**
  97982. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  97983. */
  97984. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  97985. /**
  97986. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  97987. */
  97988. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  97989. /** Callback called when a pointer move is detected */
  97990. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97991. /** Callback called when a pointer down is detected */
  97992. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97993. /** Callback called when a pointer up is detected */
  97994. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  97995. /** Callback called when a pointer pick is detected */
  97996. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  97997. /**
  97998. * 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).
  97999. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98000. */
  98001. onPrePointerObservable: Observable<PointerInfoPre>;
  98002. /**
  98003. * Observable event triggered each time an input event is received from the rendering canvas
  98004. */
  98005. onPointerObservable: Observable<PointerInfo>;
  98006. /**
  98007. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  98008. */
  98009. readonly unTranslatedPointer: Vector2;
  98010. /**
  98011. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  98012. */
  98013. static DragMovementThreshold: number;
  98014. /**
  98015. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  98016. */
  98017. static LongPressDelay: number;
  98018. /**
  98019. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  98020. */
  98021. static DoubleClickDelay: number;
  98022. /** If you need to check double click without raising a single click at first click, enable this flag */
  98023. static ExclusiveDoubleClickMode: boolean;
  98024. /** @hidden */
  98025. _mirroredCameraPosition: Nullable<Vector3>;
  98026. /**
  98027. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  98028. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  98029. */
  98030. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  98031. /**
  98032. * Observable event triggered each time an keyboard event is received from the hosting window
  98033. */
  98034. onKeyboardObservable: Observable<KeyboardInfo>;
  98035. private _useRightHandedSystem;
  98036. /**
  98037. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  98038. */
  98039. useRightHandedSystem: boolean;
  98040. private _timeAccumulator;
  98041. private _currentStepId;
  98042. private _currentInternalStep;
  98043. /**
  98044. * Sets the step Id used by deterministic lock step
  98045. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98046. * @param newStepId defines the step Id
  98047. */
  98048. setStepId(newStepId: number): void;
  98049. /**
  98050. * Gets the step Id used by deterministic lock step
  98051. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98052. * @returns the step Id
  98053. */
  98054. getStepId(): number;
  98055. /**
  98056. * Gets the internal step used by deterministic lock step
  98057. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98058. * @returns the internal step
  98059. */
  98060. getInternalStep(): number;
  98061. private _fogEnabled;
  98062. /**
  98063. * Gets or sets a boolean indicating if fog is enabled on this scene
  98064. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98065. * (Default is true)
  98066. */
  98067. fogEnabled: boolean;
  98068. private _fogMode;
  98069. /**
  98070. * Gets or sets the fog mode to use
  98071. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98072. * | mode | value |
  98073. * | --- | --- |
  98074. * | FOGMODE_NONE | 0 |
  98075. * | FOGMODE_EXP | 1 |
  98076. * | FOGMODE_EXP2 | 2 |
  98077. * | FOGMODE_LINEAR | 3 |
  98078. */
  98079. fogMode: number;
  98080. /**
  98081. * Gets or sets the fog color to use
  98082. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98083. * (Default is Color3(0.2, 0.2, 0.3))
  98084. */
  98085. fogColor: Color3;
  98086. /**
  98087. * Gets or sets the fog density to use
  98088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98089. * (Default is 0.1)
  98090. */
  98091. fogDensity: number;
  98092. /**
  98093. * Gets or sets the fog start distance to use
  98094. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98095. * (Default is 0)
  98096. */
  98097. fogStart: number;
  98098. /**
  98099. * Gets or sets the fog end distance to use
  98100. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98101. * (Default is 1000)
  98102. */
  98103. fogEnd: number;
  98104. private _shadowsEnabled;
  98105. /**
  98106. * Gets or sets a boolean indicating if shadows are enabled on this scene
  98107. */
  98108. shadowsEnabled: boolean;
  98109. private _lightsEnabled;
  98110. /**
  98111. * Gets or sets a boolean indicating if lights are enabled on this scene
  98112. */
  98113. lightsEnabled: boolean;
  98114. /** All of the active cameras added to this scene. */
  98115. activeCameras: Camera[];
  98116. /** @hidden */
  98117. _activeCamera: Nullable<Camera>;
  98118. /** Gets or sets the current active camera */
  98119. activeCamera: Nullable<Camera>;
  98120. private _defaultMaterial;
  98121. /** The default material used on meshes when no material is affected */
  98122. /** The default material used on meshes when no material is affected */
  98123. defaultMaterial: Material;
  98124. private _texturesEnabled;
  98125. /**
  98126. * Gets or sets a boolean indicating if textures are enabled on this scene
  98127. */
  98128. texturesEnabled: boolean;
  98129. /**
  98130. * Gets or sets a boolean indicating if particles are enabled on this scene
  98131. */
  98132. particlesEnabled: boolean;
  98133. /**
  98134. * Gets or sets a boolean indicating if sprites are enabled on this scene
  98135. */
  98136. spritesEnabled: boolean;
  98137. private _skeletonsEnabled;
  98138. /**
  98139. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  98140. */
  98141. skeletonsEnabled: boolean;
  98142. /**
  98143. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  98144. */
  98145. lensFlaresEnabled: boolean;
  98146. /**
  98147. * Gets or sets a boolean indicating if collisions are enabled on this scene
  98148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98149. */
  98150. collisionsEnabled: boolean;
  98151. private _collisionCoordinator;
  98152. /** @hidden */
  98153. readonly collisionCoordinator: ICollisionCoordinator;
  98154. /**
  98155. * Defines the gravity applied to this scene (used only for collisions)
  98156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98157. */
  98158. gravity: Vector3;
  98159. /**
  98160. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  98161. */
  98162. postProcessesEnabled: boolean;
  98163. /**
  98164. * The list of postprocesses added to the scene
  98165. */
  98166. postProcesses: PostProcess[];
  98167. /**
  98168. * Gets the current postprocess manager
  98169. */
  98170. postProcessManager: PostProcessManager;
  98171. /**
  98172. * Gets or sets a boolean indicating if render targets are enabled on this scene
  98173. */
  98174. renderTargetsEnabled: boolean;
  98175. /**
  98176. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  98177. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  98178. */
  98179. dumpNextRenderTargets: boolean;
  98180. /**
  98181. * The list of user defined render targets added to the scene
  98182. */
  98183. customRenderTargets: RenderTargetTexture[];
  98184. /**
  98185. * Defines if texture loading must be delayed
  98186. * If true, textures will only be loaded when they need to be rendered
  98187. */
  98188. useDelayedTextureLoading: boolean;
  98189. /**
  98190. * Gets the list of meshes imported to the scene through SceneLoader
  98191. */
  98192. importedMeshesFiles: String[];
  98193. /**
  98194. * Gets or sets a boolean indicating if probes are enabled on this scene
  98195. */
  98196. probesEnabled: boolean;
  98197. /**
  98198. * Gets or sets the current offline provider to use to store scene data
  98199. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  98200. */
  98201. offlineProvider: IOfflineProvider;
  98202. /**
  98203. * Gets or sets the action manager associated with the scene
  98204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98205. */
  98206. actionManager: AbstractActionManager;
  98207. private _meshesForIntersections;
  98208. /**
  98209. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  98210. */
  98211. proceduralTexturesEnabled: boolean;
  98212. private _engine;
  98213. private _totalVertices;
  98214. /** @hidden */
  98215. _activeIndices: PerfCounter;
  98216. /** @hidden */
  98217. _activeParticles: PerfCounter;
  98218. /** @hidden */
  98219. _activeBones: PerfCounter;
  98220. private _animationRatio;
  98221. /** @hidden */
  98222. _animationTimeLast: number;
  98223. /** @hidden */
  98224. _animationTime: number;
  98225. /**
  98226. * Gets or sets a general scale for animation speed
  98227. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  98228. */
  98229. animationTimeScale: number;
  98230. /** @hidden */
  98231. _cachedMaterial: Nullable<Material>;
  98232. /** @hidden */
  98233. _cachedEffect: Nullable<Effect>;
  98234. /** @hidden */
  98235. _cachedVisibility: Nullable<number>;
  98236. private _renderId;
  98237. private _frameId;
  98238. private _executeWhenReadyTimeoutId;
  98239. private _intermediateRendering;
  98240. private _viewUpdateFlag;
  98241. private _projectionUpdateFlag;
  98242. /** @hidden */
  98243. _toBeDisposed: Nullable<IDisposable>[];
  98244. private _activeRequests;
  98245. /** @hidden */
  98246. _pendingData: any[];
  98247. private _isDisposed;
  98248. /**
  98249. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  98250. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  98251. */
  98252. dispatchAllSubMeshesOfActiveMeshes: boolean;
  98253. private _activeMeshes;
  98254. private _processedMaterials;
  98255. private _renderTargets;
  98256. /** @hidden */
  98257. _activeParticleSystems: SmartArray<IParticleSystem>;
  98258. private _activeSkeletons;
  98259. private _softwareSkinnedMeshes;
  98260. private _renderingManager;
  98261. /** @hidden */
  98262. _activeAnimatables: Animatable[];
  98263. private _transformMatrix;
  98264. private _sceneUbo;
  98265. /** @hidden */
  98266. _viewMatrix: Matrix;
  98267. private _projectionMatrix;
  98268. /** @hidden */
  98269. _forcedViewPosition: Nullable<Vector3>;
  98270. /** @hidden */
  98271. _frustumPlanes: Plane[];
  98272. /**
  98273. * Gets the list of frustum planes (built from the active camera)
  98274. */
  98275. readonly frustumPlanes: Plane[];
  98276. /**
  98277. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  98278. * This is useful if there are more lights that the maximum simulteanous authorized
  98279. */
  98280. requireLightSorting: boolean;
  98281. /** @hidden */
  98282. readonly useMaterialMeshMap: boolean;
  98283. /** @hidden */
  98284. readonly useClonedMeshhMap: boolean;
  98285. private _externalData;
  98286. private _uid;
  98287. /**
  98288. * @hidden
  98289. * Backing store of defined scene components.
  98290. */
  98291. _components: ISceneComponent[];
  98292. /**
  98293. * @hidden
  98294. * Backing store of defined scene components.
  98295. */
  98296. _serializableComponents: ISceneSerializableComponent[];
  98297. /**
  98298. * List of components to register on the next registration step.
  98299. */
  98300. private _transientComponents;
  98301. /**
  98302. * Registers the transient components if needed.
  98303. */
  98304. private _registerTransientComponents;
  98305. /**
  98306. * @hidden
  98307. * Add a component to the scene.
  98308. * Note that the ccomponent could be registered on th next frame if this is called after
  98309. * the register component stage.
  98310. * @param component Defines the component to add to the scene
  98311. */
  98312. _addComponent(component: ISceneComponent): void;
  98313. /**
  98314. * @hidden
  98315. * Gets a component from the scene.
  98316. * @param name defines the name of the component to retrieve
  98317. * @returns the component or null if not present
  98318. */
  98319. _getComponent(name: string): Nullable<ISceneComponent>;
  98320. /**
  98321. * @hidden
  98322. * Defines the actions happening before camera updates.
  98323. */
  98324. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  98325. /**
  98326. * @hidden
  98327. * Defines the actions happening before clear the canvas.
  98328. */
  98329. _beforeClearStage: Stage<SimpleStageAction>;
  98330. /**
  98331. * @hidden
  98332. * Defines the actions when collecting render targets for the frame.
  98333. */
  98334. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98335. /**
  98336. * @hidden
  98337. * Defines the actions happening for one camera in the frame.
  98338. */
  98339. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98340. /**
  98341. * @hidden
  98342. * Defines the actions happening during the per mesh ready checks.
  98343. */
  98344. _isReadyForMeshStage: Stage<MeshStageAction>;
  98345. /**
  98346. * @hidden
  98347. * Defines the actions happening before evaluate active mesh checks.
  98348. */
  98349. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  98350. /**
  98351. * @hidden
  98352. * Defines the actions happening during the evaluate sub mesh checks.
  98353. */
  98354. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  98355. /**
  98356. * @hidden
  98357. * Defines the actions happening during the active mesh stage.
  98358. */
  98359. _activeMeshStage: Stage<ActiveMeshStageAction>;
  98360. /**
  98361. * @hidden
  98362. * Defines the actions happening during the per camera render target step.
  98363. */
  98364. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  98365. /**
  98366. * @hidden
  98367. * Defines the actions happening just before the active camera is drawing.
  98368. */
  98369. _beforeCameraDrawStage: Stage<CameraStageAction>;
  98370. /**
  98371. * @hidden
  98372. * Defines the actions happening just before a render target is drawing.
  98373. */
  98374. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98375. /**
  98376. * @hidden
  98377. * Defines the actions happening just before a rendering group is drawing.
  98378. */
  98379. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98380. /**
  98381. * @hidden
  98382. * Defines the actions happening just before a mesh is drawing.
  98383. */
  98384. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98385. /**
  98386. * @hidden
  98387. * Defines the actions happening just after a mesh has been drawn.
  98388. */
  98389. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98390. /**
  98391. * @hidden
  98392. * Defines the actions happening just after a rendering group has been drawn.
  98393. */
  98394. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98395. /**
  98396. * @hidden
  98397. * Defines the actions happening just after the active camera has been drawn.
  98398. */
  98399. _afterCameraDrawStage: Stage<CameraStageAction>;
  98400. /**
  98401. * @hidden
  98402. * Defines the actions happening just after a render target has been drawn.
  98403. */
  98404. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98405. /**
  98406. * @hidden
  98407. * Defines the actions happening just after rendering all cameras and computing intersections.
  98408. */
  98409. _afterRenderStage: Stage<SimpleStageAction>;
  98410. /**
  98411. * @hidden
  98412. * Defines the actions happening when a pointer move event happens.
  98413. */
  98414. _pointerMoveStage: Stage<PointerMoveStageAction>;
  98415. /**
  98416. * @hidden
  98417. * Defines the actions happening when a pointer down event happens.
  98418. */
  98419. _pointerDownStage: Stage<PointerUpDownStageAction>;
  98420. /**
  98421. * @hidden
  98422. * Defines the actions happening when a pointer up event happens.
  98423. */
  98424. _pointerUpStage: Stage<PointerUpDownStageAction>;
  98425. /**
  98426. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  98427. */
  98428. private geometriesByUniqueId;
  98429. /**
  98430. * Creates a new Scene
  98431. * @param engine defines the engine to use to render this scene
  98432. * @param options defines the scene options
  98433. */
  98434. constructor(engine: Engine, options?: SceneOptions);
  98435. /**
  98436. * Gets a string idenfifying the name of the class
  98437. * @returns "Scene" string
  98438. */
  98439. getClassName(): string;
  98440. private _defaultMeshCandidates;
  98441. /**
  98442. * @hidden
  98443. */
  98444. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98445. private _defaultSubMeshCandidates;
  98446. /**
  98447. * @hidden
  98448. */
  98449. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98450. /**
  98451. * Sets the default candidate providers for the scene.
  98452. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  98453. * and getCollidingSubMeshCandidates to their default function
  98454. */
  98455. setDefaultCandidateProviders(): void;
  98456. /**
  98457. * Gets the mesh that is currently under the pointer
  98458. */
  98459. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98460. /**
  98461. * Gets or sets the current on-screen X position of the pointer
  98462. */
  98463. pointerX: number;
  98464. /**
  98465. * Gets or sets the current on-screen Y position of the pointer
  98466. */
  98467. pointerY: number;
  98468. /**
  98469. * Gets the cached material (ie. the latest rendered one)
  98470. * @returns the cached material
  98471. */
  98472. getCachedMaterial(): Nullable<Material>;
  98473. /**
  98474. * Gets the cached effect (ie. the latest rendered one)
  98475. * @returns the cached effect
  98476. */
  98477. getCachedEffect(): Nullable<Effect>;
  98478. /**
  98479. * Gets the cached visibility state (ie. the latest rendered one)
  98480. * @returns the cached visibility state
  98481. */
  98482. getCachedVisibility(): Nullable<number>;
  98483. /**
  98484. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  98485. * @param material defines the current material
  98486. * @param effect defines the current effect
  98487. * @param visibility defines the current visibility state
  98488. * @returns true if one parameter is not cached
  98489. */
  98490. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  98491. /**
  98492. * Gets the engine associated with the scene
  98493. * @returns an Engine
  98494. */
  98495. getEngine(): Engine;
  98496. /**
  98497. * Gets the total number of vertices rendered per frame
  98498. * @returns the total number of vertices rendered per frame
  98499. */
  98500. getTotalVertices(): number;
  98501. /**
  98502. * Gets the performance counter for total vertices
  98503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98504. */
  98505. readonly totalVerticesPerfCounter: PerfCounter;
  98506. /**
  98507. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  98508. * @returns the total number of active indices rendered per frame
  98509. */
  98510. getActiveIndices(): number;
  98511. /**
  98512. * Gets the performance counter for active indices
  98513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98514. */
  98515. readonly totalActiveIndicesPerfCounter: PerfCounter;
  98516. /**
  98517. * Gets the total number of active particles rendered per frame
  98518. * @returns the total number of active particles rendered per frame
  98519. */
  98520. getActiveParticles(): number;
  98521. /**
  98522. * Gets the performance counter for active particles
  98523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98524. */
  98525. readonly activeParticlesPerfCounter: PerfCounter;
  98526. /**
  98527. * Gets the total number of active bones rendered per frame
  98528. * @returns the total number of active bones rendered per frame
  98529. */
  98530. getActiveBones(): number;
  98531. /**
  98532. * Gets the performance counter for active bones
  98533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98534. */
  98535. readonly activeBonesPerfCounter: PerfCounter;
  98536. /**
  98537. * Gets the array of active meshes
  98538. * @returns an array of AbstractMesh
  98539. */
  98540. getActiveMeshes(): SmartArray<AbstractMesh>;
  98541. /**
  98542. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  98543. * @returns a number
  98544. */
  98545. getAnimationRatio(): number;
  98546. /**
  98547. * Gets an unique Id for the current render phase
  98548. * @returns a number
  98549. */
  98550. getRenderId(): number;
  98551. /**
  98552. * Gets an unique Id for the current frame
  98553. * @returns a number
  98554. */
  98555. getFrameId(): number;
  98556. /** Call this function if you want to manually increment the render Id*/
  98557. incrementRenderId(): void;
  98558. private _createUbo;
  98559. /**
  98560. * Use this method to simulate a pointer move on a mesh
  98561. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98562. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98563. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98564. * @returns the current scene
  98565. */
  98566. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98567. /**
  98568. * Use this method to simulate a pointer down on a mesh
  98569. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98570. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98571. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98572. * @returns the current scene
  98573. */
  98574. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98575. /**
  98576. * Use this method to simulate a pointer up on a mesh
  98577. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98578. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98579. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98580. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98581. * @returns the current scene
  98582. */
  98583. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  98584. /**
  98585. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98586. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98587. * @returns true if the pointer was captured
  98588. */
  98589. isPointerCaptured(pointerId?: number): boolean;
  98590. /**
  98591. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98592. * @param attachUp defines if you want to attach events to pointerup
  98593. * @param attachDown defines if you want to attach events to pointerdown
  98594. * @param attachMove defines if you want to attach events to pointermove
  98595. */
  98596. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98597. /** Detaches all event handlers*/
  98598. detachControl(): void;
  98599. /**
  98600. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  98601. * Delay loaded resources are not taking in account
  98602. * @return true if all required resources are ready
  98603. */
  98604. isReady(): boolean;
  98605. /** Resets all cached information relative to material (including effect and visibility) */
  98606. resetCachedMaterial(): void;
  98607. /**
  98608. * Registers a function to be called before every frame render
  98609. * @param func defines the function to register
  98610. */
  98611. registerBeforeRender(func: () => void): void;
  98612. /**
  98613. * Unregisters a function called before every frame render
  98614. * @param func defines the function to unregister
  98615. */
  98616. unregisterBeforeRender(func: () => void): void;
  98617. /**
  98618. * Registers a function to be called after every frame render
  98619. * @param func defines the function to register
  98620. */
  98621. registerAfterRender(func: () => void): void;
  98622. /**
  98623. * Unregisters a function called after every frame render
  98624. * @param func defines the function to unregister
  98625. */
  98626. unregisterAfterRender(func: () => void): void;
  98627. private _executeOnceBeforeRender;
  98628. /**
  98629. * The provided function will run before render once and will be disposed afterwards.
  98630. * A timeout delay can be provided so that the function will be executed in N ms.
  98631. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  98632. * @param func The function to be executed.
  98633. * @param timeout optional delay in ms
  98634. */
  98635. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  98636. /** @hidden */
  98637. _addPendingData(data: any): void;
  98638. /** @hidden */
  98639. _removePendingData(data: any): void;
  98640. /**
  98641. * Returns the number of items waiting to be loaded
  98642. * @returns the number of items waiting to be loaded
  98643. */
  98644. getWaitingItemsCount(): number;
  98645. /**
  98646. * Returns a boolean indicating if the scene is still loading data
  98647. */
  98648. readonly isLoading: boolean;
  98649. /**
  98650. * Registers a function to be executed when the scene is ready
  98651. * @param {Function} func - the function to be executed
  98652. */
  98653. executeWhenReady(func: () => void): void;
  98654. /**
  98655. * Returns a promise that resolves when the scene is ready
  98656. * @returns A promise that resolves when the scene is ready
  98657. */
  98658. whenReadyAsync(): Promise<void>;
  98659. /** @hidden */
  98660. _checkIsReady(): void;
  98661. /**
  98662. * Gets all animatable attached to the scene
  98663. */
  98664. readonly animatables: Animatable[];
  98665. /**
  98666. * Resets the last animation time frame.
  98667. * Useful to override when animations start running when loading a scene for the first time.
  98668. */
  98669. resetLastAnimationTimeFrame(): void;
  98670. /**
  98671. * Gets the current view matrix
  98672. * @returns a Matrix
  98673. */
  98674. getViewMatrix(): Matrix;
  98675. /**
  98676. * Gets the current projection matrix
  98677. * @returns a Matrix
  98678. */
  98679. getProjectionMatrix(): Matrix;
  98680. /**
  98681. * Gets the current transform matrix
  98682. * @returns a Matrix made of View * Projection
  98683. */
  98684. getTransformMatrix(): Matrix;
  98685. /**
  98686. * Sets the current transform matrix
  98687. * @param viewL defines the View matrix to use
  98688. * @param projectionL defines the Projection matrix to use
  98689. * @param viewR defines the right View matrix to use (if provided)
  98690. * @param projectionR defines the right Projection matrix to use (if provided)
  98691. */
  98692. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  98693. /**
  98694. * Gets the uniform buffer used to store scene data
  98695. * @returns a UniformBuffer
  98696. */
  98697. getSceneUniformBuffer(): UniformBuffer;
  98698. /**
  98699. * Gets an unique (relatively to the current scene) Id
  98700. * @returns an unique number for the scene
  98701. */
  98702. getUniqueId(): number;
  98703. /**
  98704. * Add a mesh to the list of scene's meshes
  98705. * @param newMesh defines the mesh to add
  98706. * @param recursive if all child meshes should also be added to the scene
  98707. */
  98708. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  98709. /**
  98710. * Remove a mesh for the list of scene's meshes
  98711. * @param toRemove defines the mesh to remove
  98712. * @param recursive if all child meshes should also be removed from the scene
  98713. * @returns the index where the mesh was in the mesh list
  98714. */
  98715. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  98716. /**
  98717. * Add a transform node to the list of scene's transform nodes
  98718. * @param newTransformNode defines the transform node to add
  98719. */
  98720. addTransformNode(newTransformNode: TransformNode): void;
  98721. /**
  98722. * Remove a transform node for the list of scene's transform nodes
  98723. * @param toRemove defines the transform node to remove
  98724. * @returns the index where the transform node was in the transform node list
  98725. */
  98726. removeTransformNode(toRemove: TransformNode): number;
  98727. /**
  98728. * Remove a skeleton for the list of scene's skeletons
  98729. * @param toRemove defines the skeleton to remove
  98730. * @returns the index where the skeleton was in the skeleton list
  98731. */
  98732. removeSkeleton(toRemove: Skeleton): number;
  98733. /**
  98734. * Remove a morph target for the list of scene's morph targets
  98735. * @param toRemove defines the morph target to remove
  98736. * @returns the index where the morph target was in the morph target list
  98737. */
  98738. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  98739. /**
  98740. * Remove a light for the list of scene's lights
  98741. * @param toRemove defines the light to remove
  98742. * @returns the index where the light was in the light list
  98743. */
  98744. removeLight(toRemove: Light): number;
  98745. /**
  98746. * Remove a camera for the list of scene's cameras
  98747. * @param toRemove defines the camera to remove
  98748. * @returns the index where the camera was in the camera list
  98749. */
  98750. removeCamera(toRemove: Camera): number;
  98751. /**
  98752. * Remove a particle system for the list of scene's particle systems
  98753. * @param toRemove defines the particle system to remove
  98754. * @returns the index where the particle system was in the particle system list
  98755. */
  98756. removeParticleSystem(toRemove: IParticleSystem): number;
  98757. /**
  98758. * Remove a animation for the list of scene's animations
  98759. * @param toRemove defines the animation to remove
  98760. * @returns the index where the animation was in the animation list
  98761. */
  98762. removeAnimation(toRemove: Animation): number;
  98763. /**
  98764. * Will stop the animation of the given target
  98765. * @param target - the target
  98766. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  98767. * @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)
  98768. */
  98769. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  98770. /**
  98771. * Removes the given animation group from this scene.
  98772. * @param toRemove The animation group to remove
  98773. * @returns The index of the removed animation group
  98774. */
  98775. removeAnimationGroup(toRemove: AnimationGroup): number;
  98776. /**
  98777. * Removes the given multi-material from this scene.
  98778. * @param toRemove The multi-material to remove
  98779. * @returns The index of the removed multi-material
  98780. */
  98781. removeMultiMaterial(toRemove: MultiMaterial): number;
  98782. /**
  98783. * Removes the given material from this scene.
  98784. * @param toRemove The material to remove
  98785. * @returns The index of the removed material
  98786. */
  98787. removeMaterial(toRemove: Material): number;
  98788. /**
  98789. * Removes the given action manager from this scene.
  98790. * @param toRemove The action manager to remove
  98791. * @returns The index of the removed action manager
  98792. */
  98793. removeActionManager(toRemove: AbstractActionManager): number;
  98794. /**
  98795. * Removes the given texture from this scene.
  98796. * @param toRemove The texture to remove
  98797. * @returns The index of the removed texture
  98798. */
  98799. removeTexture(toRemove: BaseTexture): number;
  98800. /**
  98801. * Adds the given light to this scene
  98802. * @param newLight The light to add
  98803. */
  98804. addLight(newLight: Light): void;
  98805. /**
  98806. * Sorts the list list based on light priorities
  98807. */
  98808. sortLightsByPriority(): void;
  98809. /**
  98810. * Adds the given camera to this scene
  98811. * @param newCamera The camera to add
  98812. */
  98813. addCamera(newCamera: Camera): void;
  98814. /**
  98815. * Adds the given skeleton to this scene
  98816. * @param newSkeleton The skeleton to add
  98817. */
  98818. addSkeleton(newSkeleton: Skeleton): void;
  98819. /**
  98820. * Adds the given particle system to this scene
  98821. * @param newParticleSystem The particle system to add
  98822. */
  98823. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98824. /**
  98825. * Adds the given animation to this scene
  98826. * @param newAnimation The animation to add
  98827. */
  98828. addAnimation(newAnimation: Animation): void;
  98829. /**
  98830. * Adds the given animation group to this scene.
  98831. * @param newAnimationGroup The animation group to add
  98832. */
  98833. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98834. /**
  98835. * Adds the given multi-material to this scene
  98836. * @param newMultiMaterial The multi-material to add
  98837. */
  98838. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98839. /**
  98840. * Adds the given material to this scene
  98841. * @param newMaterial The material to add
  98842. */
  98843. addMaterial(newMaterial: Material): void;
  98844. /**
  98845. * Adds the given morph target to this scene
  98846. * @param newMorphTargetManager The morph target to add
  98847. */
  98848. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98849. /**
  98850. * Adds the given geometry to this scene
  98851. * @param newGeometry The geometry to add
  98852. */
  98853. addGeometry(newGeometry: Geometry): void;
  98854. /**
  98855. * Adds the given action manager to this scene
  98856. * @param newActionManager The action manager to add
  98857. */
  98858. addActionManager(newActionManager: AbstractActionManager): void;
  98859. /**
  98860. * Adds the given texture to this scene.
  98861. * @param newTexture The texture to add
  98862. */
  98863. addTexture(newTexture: BaseTexture): void;
  98864. /**
  98865. * Switch active camera
  98866. * @param newCamera defines the new active camera
  98867. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  98868. */
  98869. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  98870. /**
  98871. * sets the active camera of the scene using its ID
  98872. * @param id defines the camera's ID
  98873. * @return the new active camera or null if none found.
  98874. */
  98875. setActiveCameraByID(id: string): Nullable<Camera>;
  98876. /**
  98877. * sets the active camera of the scene using its name
  98878. * @param name defines the camera's name
  98879. * @returns the new active camera or null if none found.
  98880. */
  98881. setActiveCameraByName(name: string): Nullable<Camera>;
  98882. /**
  98883. * get an animation group using its name
  98884. * @param name defines the material's name
  98885. * @return the animation group or null if none found.
  98886. */
  98887. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  98888. /**
  98889. * Get a material using its unique id
  98890. * @param uniqueId defines the material's unique id
  98891. * @return the material or null if none found.
  98892. */
  98893. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  98894. /**
  98895. * get a material using its id
  98896. * @param id defines the material's ID
  98897. * @return the material or null if none found.
  98898. */
  98899. getMaterialByID(id: string): Nullable<Material>;
  98900. /**
  98901. * Gets a the last added material using a given id
  98902. * @param id defines the material's ID
  98903. * @return the last material with the given id or null if none found.
  98904. */
  98905. getLastMaterialByID(id: string): Nullable<Material>;
  98906. /**
  98907. * Gets a material using its name
  98908. * @param name defines the material's name
  98909. * @return the material or null if none found.
  98910. */
  98911. getMaterialByName(name: string): Nullable<Material>;
  98912. /**
  98913. * Get a texture using its unique id
  98914. * @param uniqueId defines the texture's unique id
  98915. * @return the texture or null if none found.
  98916. */
  98917. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  98918. /**
  98919. * Gets a camera using its id
  98920. * @param id defines the id to look for
  98921. * @returns the camera or null if not found
  98922. */
  98923. getCameraByID(id: string): Nullable<Camera>;
  98924. /**
  98925. * Gets a camera using its unique id
  98926. * @param uniqueId defines the unique id to look for
  98927. * @returns the camera or null if not found
  98928. */
  98929. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  98930. /**
  98931. * Gets a camera using its name
  98932. * @param name defines the camera's name
  98933. * @return the camera or null if none found.
  98934. */
  98935. getCameraByName(name: string): Nullable<Camera>;
  98936. /**
  98937. * Gets a bone using its id
  98938. * @param id defines the bone's id
  98939. * @return the bone or null if not found
  98940. */
  98941. getBoneByID(id: string): Nullable<Bone>;
  98942. /**
  98943. * Gets a bone using its id
  98944. * @param name defines the bone's name
  98945. * @return the bone or null if not found
  98946. */
  98947. getBoneByName(name: string): Nullable<Bone>;
  98948. /**
  98949. * Gets a light node using its name
  98950. * @param name defines the the light's name
  98951. * @return the light or null if none found.
  98952. */
  98953. getLightByName(name: string): Nullable<Light>;
  98954. /**
  98955. * Gets a light node using its id
  98956. * @param id defines the light's id
  98957. * @return the light or null if none found.
  98958. */
  98959. getLightByID(id: string): Nullable<Light>;
  98960. /**
  98961. * Gets a light node using its scene-generated unique ID
  98962. * @param uniqueId defines the light's unique id
  98963. * @return the light or null if none found.
  98964. */
  98965. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  98966. /**
  98967. * Gets a particle system by id
  98968. * @param id defines the particle system id
  98969. * @return the corresponding system or null if none found
  98970. */
  98971. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  98972. /**
  98973. * Gets a geometry using its ID
  98974. * @param id defines the geometry's id
  98975. * @return the geometry or null if none found.
  98976. */
  98977. getGeometryByID(id: string): Nullable<Geometry>;
  98978. private _getGeometryByUniqueID;
  98979. /**
  98980. * Add a new geometry to this scene
  98981. * @param geometry defines the geometry to be added to the scene.
  98982. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  98983. * @return a boolean defining if the geometry was added or not
  98984. */
  98985. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  98986. /**
  98987. * Removes an existing geometry
  98988. * @param geometry defines the geometry to be removed from the scene
  98989. * @return a boolean defining if the geometry was removed or not
  98990. */
  98991. removeGeometry(geometry: Geometry): boolean;
  98992. /**
  98993. * Gets the list of geometries attached to the scene
  98994. * @returns an array of Geometry
  98995. */
  98996. getGeometries(): Geometry[];
  98997. /**
  98998. * Gets the first added mesh found of a given ID
  98999. * @param id defines the id to search for
  99000. * @return the mesh found or null if not found at all
  99001. */
  99002. getMeshByID(id: string): Nullable<AbstractMesh>;
  99003. /**
  99004. * Gets a list of meshes using their id
  99005. * @param id defines the id to search for
  99006. * @returns a list of meshes
  99007. */
  99008. getMeshesByID(id: string): Array<AbstractMesh>;
  99009. /**
  99010. * Gets the first added transform node found of a given ID
  99011. * @param id defines the id to search for
  99012. * @return the found transform node or null if not found at all.
  99013. */
  99014. getTransformNodeByID(id: string): Nullable<TransformNode>;
  99015. /**
  99016. * Gets a transform node with its auto-generated unique id
  99017. * @param uniqueId efines the unique id to search for
  99018. * @return the found transform node or null if not found at all.
  99019. */
  99020. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  99021. /**
  99022. * Gets a list of transform nodes using their id
  99023. * @param id defines the id to search for
  99024. * @returns a list of transform nodes
  99025. */
  99026. getTransformNodesByID(id: string): Array<TransformNode>;
  99027. /**
  99028. * Gets a mesh with its auto-generated unique id
  99029. * @param uniqueId defines the unique id to search for
  99030. * @return the found mesh or null if not found at all.
  99031. */
  99032. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  99033. /**
  99034. * Gets a the last added mesh using a given id
  99035. * @param id defines the id to search for
  99036. * @return the found mesh or null if not found at all.
  99037. */
  99038. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  99039. /**
  99040. * Gets a the last added node (Mesh, Camera, Light) using a given id
  99041. * @param id defines the id to search for
  99042. * @return the found node or null if not found at all
  99043. */
  99044. getLastEntryByID(id: string): Nullable<Node>;
  99045. /**
  99046. * Gets a node (Mesh, Camera, Light) using a given id
  99047. * @param id defines the id to search for
  99048. * @return the found node or null if not found at all
  99049. */
  99050. getNodeByID(id: string): Nullable<Node>;
  99051. /**
  99052. * Gets a node (Mesh, Camera, Light) using a given name
  99053. * @param name defines the name to search for
  99054. * @return the found node or null if not found at all.
  99055. */
  99056. getNodeByName(name: string): Nullable<Node>;
  99057. /**
  99058. * Gets a mesh using a given name
  99059. * @param name defines the name to search for
  99060. * @return the found mesh or null if not found at all.
  99061. */
  99062. getMeshByName(name: string): Nullable<AbstractMesh>;
  99063. /**
  99064. * Gets a transform node using a given name
  99065. * @param name defines the name to search for
  99066. * @return the found transform node or null if not found at all.
  99067. */
  99068. getTransformNodeByName(name: string): Nullable<TransformNode>;
  99069. /**
  99070. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  99071. * @param id defines the id to search for
  99072. * @return the found skeleton or null if not found at all.
  99073. */
  99074. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  99075. /**
  99076. * Gets a skeleton using a given auto generated unique id
  99077. * @param uniqueId defines the unique id to search for
  99078. * @return the found skeleton or null if not found at all.
  99079. */
  99080. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  99081. /**
  99082. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  99083. * @param id defines the id to search for
  99084. * @return the found skeleton or null if not found at all.
  99085. */
  99086. getSkeletonById(id: string): Nullable<Skeleton>;
  99087. /**
  99088. * Gets a skeleton using a given name
  99089. * @param name defines the name to search for
  99090. * @return the found skeleton or null if not found at all.
  99091. */
  99092. getSkeletonByName(name: string): Nullable<Skeleton>;
  99093. /**
  99094. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  99095. * @param id defines the id to search for
  99096. * @return the found morph target manager or null if not found at all.
  99097. */
  99098. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  99099. /**
  99100. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  99101. * @param id defines the id to search for
  99102. * @return the found morph target or null if not found at all.
  99103. */
  99104. getMorphTargetById(id: string): Nullable<MorphTarget>;
  99105. /**
  99106. * Gets a boolean indicating if the given mesh is active
  99107. * @param mesh defines the mesh to look for
  99108. * @returns true if the mesh is in the active list
  99109. */
  99110. isActiveMesh(mesh: AbstractMesh): boolean;
  99111. /**
  99112. * Return a unique id as a string which can serve as an identifier for the scene
  99113. */
  99114. readonly uid: string;
  99115. /**
  99116. * Add an externaly attached data from its key.
  99117. * This method call will fail and return false, if such key already exists.
  99118. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  99119. * @param key the unique key that identifies the data
  99120. * @param data the data object to associate to the key for this Engine instance
  99121. * @return true if no such key were already present and the data was added successfully, false otherwise
  99122. */
  99123. addExternalData<T>(key: string, data: T): boolean;
  99124. /**
  99125. * Get an externaly attached data from its key
  99126. * @param key the unique key that identifies the data
  99127. * @return the associated data, if present (can be null), or undefined if not present
  99128. */
  99129. getExternalData<T>(key: string): Nullable<T>;
  99130. /**
  99131. * Get an externaly attached data from its key, create it using a factory if it's not already present
  99132. * @param key the unique key that identifies the data
  99133. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  99134. * @return the associated data, can be null if the factory returned null.
  99135. */
  99136. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  99137. /**
  99138. * Remove an externaly attached data from the Engine instance
  99139. * @param key the unique key that identifies the data
  99140. * @return true if the data was successfully removed, false if it doesn't exist
  99141. */
  99142. removeExternalData(key: string): boolean;
  99143. private _evaluateSubMesh;
  99144. /**
  99145. * Clear the processed materials smart array preventing retention point in material dispose.
  99146. */
  99147. freeProcessedMaterials(): void;
  99148. private _preventFreeActiveMeshesAndRenderingGroups;
  99149. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  99150. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  99151. * when disposing several meshes in a row or a hierarchy of meshes.
  99152. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  99153. */
  99154. blockfreeActiveMeshesAndRenderingGroups: boolean;
  99155. /**
  99156. * Clear the active meshes smart array preventing retention point in mesh dispose.
  99157. */
  99158. freeActiveMeshes(): void;
  99159. /**
  99160. * Clear the info related to rendering groups preventing retention points during dispose.
  99161. */
  99162. freeRenderingGroups(): void;
  99163. /** @hidden */
  99164. _isInIntermediateRendering(): boolean;
  99165. /**
  99166. * Lambda returning the list of potentially active meshes.
  99167. */
  99168. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  99169. /**
  99170. * Lambda returning the list of potentially active sub meshes.
  99171. */
  99172. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  99173. /**
  99174. * Lambda returning the list of potentially intersecting sub meshes.
  99175. */
  99176. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  99177. /**
  99178. * Lambda returning the list of potentially colliding sub meshes.
  99179. */
  99180. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  99181. private _activeMeshesFrozen;
  99182. /**
  99183. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  99184. * @returns the current scene
  99185. */
  99186. freezeActiveMeshes(): Scene;
  99187. /**
  99188. * Use this function to restart evaluating active meshes on every frame
  99189. * @returns the current scene
  99190. */
  99191. unfreezeActiveMeshes(): Scene;
  99192. private _evaluateActiveMeshes;
  99193. private _activeMesh;
  99194. /**
  99195. * Update the transform matrix to update from the current active camera
  99196. * @param force defines a boolean used to force the update even if cache is up to date
  99197. */
  99198. updateTransformMatrix(force?: boolean): void;
  99199. private _bindFrameBuffer;
  99200. /** @hidden */
  99201. _allowPostProcessClearColor: boolean;
  99202. /** @hidden */
  99203. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  99204. private _processSubCameras;
  99205. private _checkIntersections;
  99206. /** @hidden */
  99207. _advancePhysicsEngineStep(step: number): void;
  99208. /**
  99209. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  99210. */
  99211. getDeterministicFrameTime: () => number;
  99212. /** @hidden */
  99213. _animate(): void;
  99214. /** Execute all animations (for a frame) */
  99215. animate(): void;
  99216. /**
  99217. * Render the scene
  99218. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  99219. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  99220. */
  99221. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  99222. /**
  99223. * Freeze all materials
  99224. * A frozen material will not be updatable but should be faster to render
  99225. */
  99226. freezeMaterials(): void;
  99227. /**
  99228. * Unfreeze all materials
  99229. * A frozen material will not be updatable but should be faster to render
  99230. */
  99231. unfreezeMaterials(): void;
  99232. /**
  99233. * Releases all held ressources
  99234. */
  99235. dispose(): void;
  99236. /**
  99237. * Gets if the scene is already disposed
  99238. */
  99239. readonly isDisposed: boolean;
  99240. /**
  99241. * Call this function to reduce memory footprint of the scene.
  99242. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  99243. */
  99244. clearCachedVertexData(): void;
  99245. /**
  99246. * This function will remove the local cached buffer data from texture.
  99247. * It will save memory but will prevent the texture from being rebuilt
  99248. */
  99249. cleanCachedTextureBuffer(): void;
  99250. /**
  99251. * Get the world extend vectors with an optional filter
  99252. *
  99253. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  99254. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  99255. */
  99256. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  99257. min: Vector3;
  99258. max: Vector3;
  99259. };
  99260. /**
  99261. * Creates a ray that can be used to pick in the scene
  99262. * @param x defines the x coordinate of the origin (on-screen)
  99263. * @param y defines the y coordinate of the origin (on-screen)
  99264. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99265. * @param camera defines the camera to use for the picking
  99266. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99267. * @returns a Ray
  99268. */
  99269. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  99270. /**
  99271. * Creates a ray that can be used to pick in the scene
  99272. * @param x defines the x coordinate of the origin (on-screen)
  99273. * @param y defines the y coordinate of the origin (on-screen)
  99274. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99275. * @param result defines the ray where to store the picking ray
  99276. * @param camera defines the camera to use for the picking
  99277. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99278. * @returns the current scene
  99279. */
  99280. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  99281. /**
  99282. * Creates a ray that can be used to pick in the scene
  99283. * @param x defines the x coordinate of the origin (on-screen)
  99284. * @param y defines the y coordinate of the origin (on-screen)
  99285. * @param camera defines the camera to use for the picking
  99286. * @returns a Ray
  99287. */
  99288. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  99289. /**
  99290. * Creates a ray that can be used to pick in the scene
  99291. * @param x defines the x coordinate of the origin (on-screen)
  99292. * @param y defines the y coordinate of the origin (on-screen)
  99293. * @param result defines the ray where to store the picking ray
  99294. * @param camera defines the camera to use for the picking
  99295. * @returns the current scene
  99296. */
  99297. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  99298. /** Launch a ray to try to pick a mesh in the scene
  99299. * @param x position on screen
  99300. * @param y position on screen
  99301. * @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
  99302. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  99303. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99304. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99305. * @returns a PickingInfo
  99306. */
  99307. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99308. /** Use the given ray to pick a mesh in the scene
  99309. * @param ray The ray to use to pick meshes
  99310. * @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
  99311. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  99312. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99313. * @returns a PickingInfo
  99314. */
  99315. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99316. /**
  99317. * Launch a ray to try to pick a mesh in the scene
  99318. * @param x X position on screen
  99319. * @param y Y position on screen
  99320. * @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
  99321. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99322. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99323. * @returns an array of PickingInfo
  99324. */
  99325. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99326. /**
  99327. * Launch a ray to try to pick a mesh in the scene
  99328. * @param ray Ray to use
  99329. * @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
  99330. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99331. * @returns an array of PickingInfo
  99332. */
  99333. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99334. /**
  99335. * Force the value of meshUnderPointer
  99336. * @param mesh defines the mesh to use
  99337. */
  99338. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99339. /**
  99340. * Gets the mesh under the pointer
  99341. * @returns a Mesh or null if no mesh is under the pointer
  99342. */
  99343. getPointerOverMesh(): Nullable<AbstractMesh>;
  99344. /** @hidden */
  99345. _rebuildGeometries(): void;
  99346. /** @hidden */
  99347. _rebuildTextures(): void;
  99348. private _getByTags;
  99349. /**
  99350. * Get a list of meshes by tags
  99351. * @param tagsQuery defines the tags query to use
  99352. * @param forEach defines a predicate used to filter results
  99353. * @returns an array of Mesh
  99354. */
  99355. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  99356. /**
  99357. * Get a list of cameras by tags
  99358. * @param tagsQuery defines the tags query to use
  99359. * @param forEach defines a predicate used to filter results
  99360. * @returns an array of Camera
  99361. */
  99362. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  99363. /**
  99364. * Get a list of lights by tags
  99365. * @param tagsQuery defines the tags query to use
  99366. * @param forEach defines a predicate used to filter results
  99367. * @returns an array of Light
  99368. */
  99369. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  99370. /**
  99371. * Get a list of materials by tags
  99372. * @param tagsQuery defines the tags query to use
  99373. * @param forEach defines a predicate used to filter results
  99374. * @returns an array of Material
  99375. */
  99376. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  99377. /**
  99378. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  99379. * This allowed control for front to back rendering or reversly depending of the special needs.
  99380. *
  99381. * @param renderingGroupId The rendering group id corresponding to its index
  99382. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  99383. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  99384. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  99385. */
  99386. 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;
  99387. /**
  99388. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  99389. *
  99390. * @param renderingGroupId The rendering group id corresponding to its index
  99391. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  99392. * @param depth Automatically clears depth between groups if true and autoClear is true.
  99393. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  99394. */
  99395. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  99396. /**
  99397. * Gets the current auto clear configuration for one rendering group of the rendering
  99398. * manager.
  99399. * @param index the rendering group index to get the information for
  99400. * @returns The auto clear setup for the requested rendering group
  99401. */
  99402. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  99403. private _blockMaterialDirtyMechanism;
  99404. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  99405. blockMaterialDirtyMechanism: boolean;
  99406. /**
  99407. * Will flag all materials as dirty to trigger new shader compilation
  99408. * @param flag defines the flag used to specify which material part must be marked as dirty
  99409. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  99410. */
  99411. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99412. /** @hidden */
  99413. _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;
  99414. /** @hidden */
  99415. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99416. }
  99417. }
  99418. declare module BABYLON {
  99419. /**
  99420. * Set of assets to keep when moving a scene into an asset container.
  99421. */
  99422. export class KeepAssets extends AbstractScene {
  99423. }
  99424. /**
  99425. * Container with a set of assets that can be added or removed from a scene.
  99426. */
  99427. export class AssetContainer extends AbstractScene {
  99428. /**
  99429. * The scene the AssetContainer belongs to.
  99430. */
  99431. scene: Scene;
  99432. /**
  99433. * Instantiates an AssetContainer.
  99434. * @param scene The scene the AssetContainer belongs to.
  99435. */
  99436. constructor(scene: Scene);
  99437. /**
  99438. * Adds all the assets from the container to the scene.
  99439. */
  99440. addAllToScene(): void;
  99441. /**
  99442. * Removes all the assets in the container from the scene
  99443. */
  99444. removeAllFromScene(): void;
  99445. /**
  99446. * Disposes all the assets in the container
  99447. */
  99448. dispose(): void;
  99449. private _moveAssets;
  99450. /**
  99451. * Removes all the assets contained in the scene and adds them to the container.
  99452. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  99453. */
  99454. moveAllFromScene(keepAssets?: KeepAssets): void;
  99455. /**
  99456. * 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.
  99457. * @returns the root mesh
  99458. */
  99459. createRootMesh(): Mesh;
  99460. }
  99461. }
  99462. declare module BABYLON {
  99463. /**
  99464. * Defines how the parser contract is defined.
  99465. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  99466. */
  99467. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  99468. /**
  99469. * Defines how the individual parser contract is defined.
  99470. * These parser can parse an individual asset
  99471. */
  99472. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  99473. /**
  99474. * Base class of the scene acting as a container for the different elements composing a scene.
  99475. * This class is dynamically extended by the different components of the scene increasing
  99476. * flexibility and reducing coupling
  99477. */
  99478. export abstract class AbstractScene {
  99479. /**
  99480. * Stores the list of available parsers in the application.
  99481. */
  99482. private static _BabylonFileParsers;
  99483. /**
  99484. * Stores the list of available individual parsers in the application.
  99485. */
  99486. private static _IndividualBabylonFileParsers;
  99487. /**
  99488. * Adds a parser in the list of available ones
  99489. * @param name Defines the name of the parser
  99490. * @param parser Defines the parser to add
  99491. */
  99492. static AddParser(name: string, parser: BabylonFileParser): void;
  99493. /**
  99494. * Gets a general parser from the list of avaialble ones
  99495. * @param name Defines the name of the parser
  99496. * @returns the requested parser or null
  99497. */
  99498. static GetParser(name: string): Nullable<BabylonFileParser>;
  99499. /**
  99500. * Adds n individual parser in the list of available ones
  99501. * @param name Defines the name of the parser
  99502. * @param parser Defines the parser to add
  99503. */
  99504. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  99505. /**
  99506. * Gets an individual parser from the list of avaialble ones
  99507. * @param name Defines the name of the parser
  99508. * @returns the requested parser or null
  99509. */
  99510. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  99511. /**
  99512. * Parser json data and populate both a scene and its associated container object
  99513. * @param jsonData Defines the data to parse
  99514. * @param scene Defines the scene to parse the data for
  99515. * @param container Defines the container attached to the parsing sequence
  99516. * @param rootUrl Defines the root url of the data
  99517. */
  99518. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  99519. /**
  99520. * Gets the list of root nodes (ie. nodes with no parent)
  99521. */
  99522. rootNodes: Node[];
  99523. /** All of the cameras added to this scene
  99524. * @see http://doc.babylonjs.com/babylon101/cameras
  99525. */
  99526. cameras: Camera[];
  99527. /**
  99528. * All of the lights added to this scene
  99529. * @see http://doc.babylonjs.com/babylon101/lights
  99530. */
  99531. lights: Light[];
  99532. /**
  99533. * All of the (abstract) meshes added to this scene
  99534. */
  99535. meshes: AbstractMesh[];
  99536. /**
  99537. * The list of skeletons added to the scene
  99538. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99539. */
  99540. skeletons: Skeleton[];
  99541. /**
  99542. * All of the particle systems added to this scene
  99543. * @see http://doc.babylonjs.com/babylon101/particles
  99544. */
  99545. particleSystems: IParticleSystem[];
  99546. /**
  99547. * Gets a list of Animations associated with the scene
  99548. */
  99549. animations: Animation[];
  99550. /**
  99551. * All of the animation groups added to this scene
  99552. * @see http://doc.babylonjs.com/how_to/group
  99553. */
  99554. animationGroups: AnimationGroup[];
  99555. /**
  99556. * All of the multi-materials added to this scene
  99557. * @see http://doc.babylonjs.com/how_to/multi_materials
  99558. */
  99559. multiMaterials: MultiMaterial[];
  99560. /**
  99561. * All of the materials added to this scene
  99562. * In the context of a Scene, it is not supposed to be modified manually.
  99563. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  99564. * Note also that the order of the Material wihin the array is not significant and might change.
  99565. * @see http://doc.babylonjs.com/babylon101/materials
  99566. */
  99567. materials: Material[];
  99568. /**
  99569. * The list of morph target managers added to the scene
  99570. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  99571. */
  99572. morphTargetManagers: MorphTargetManager[];
  99573. /**
  99574. * The list of geometries used in the scene.
  99575. */
  99576. geometries: Geometry[];
  99577. /**
  99578. * All of the tranform nodes added to this scene
  99579. * In the context of a Scene, it is not supposed to be modified manually.
  99580. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  99581. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  99582. * @see http://doc.babylonjs.com/how_to/transformnode
  99583. */
  99584. transformNodes: TransformNode[];
  99585. /**
  99586. * ActionManagers available on the scene.
  99587. */
  99588. actionManagers: AbstractActionManager[];
  99589. /**
  99590. * Textures to keep.
  99591. */
  99592. textures: BaseTexture[];
  99593. /**
  99594. * Environment texture for the scene
  99595. */
  99596. environmentTexture: Nullable<BaseTexture>;
  99597. }
  99598. }
  99599. declare module BABYLON {
  99600. /**
  99601. * Interface used to define options for Sound class
  99602. */
  99603. export interface ISoundOptions {
  99604. /**
  99605. * Does the sound autoplay once loaded.
  99606. */
  99607. autoplay?: boolean;
  99608. /**
  99609. * Does the sound loop after it finishes playing once.
  99610. */
  99611. loop?: boolean;
  99612. /**
  99613. * Sound's volume
  99614. */
  99615. volume?: number;
  99616. /**
  99617. * Is it a spatial sound?
  99618. */
  99619. spatialSound?: boolean;
  99620. /**
  99621. * Maximum distance to hear that sound
  99622. */
  99623. maxDistance?: number;
  99624. /**
  99625. * Uses user defined attenuation function
  99626. */
  99627. useCustomAttenuation?: boolean;
  99628. /**
  99629. * Define the roll off factor of spatial sounds.
  99630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99631. */
  99632. rolloffFactor?: number;
  99633. /**
  99634. * Define the reference distance the sound should be heard perfectly.
  99635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99636. */
  99637. refDistance?: number;
  99638. /**
  99639. * Define the distance attenuation model the sound will follow.
  99640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99641. */
  99642. distanceModel?: string;
  99643. /**
  99644. * Defines the playback speed (1 by default)
  99645. */
  99646. playbackRate?: number;
  99647. /**
  99648. * Defines if the sound is from a streaming source
  99649. */
  99650. streaming?: boolean;
  99651. /**
  99652. * Defines an optional length (in seconds) inside the sound file
  99653. */
  99654. length?: number;
  99655. /**
  99656. * Defines an optional offset (in seconds) inside the sound file
  99657. */
  99658. offset?: number;
  99659. /**
  99660. * If true, URLs will not be required to state the audio file codec to use.
  99661. */
  99662. skipCodecCheck?: boolean;
  99663. }
  99664. /**
  99665. * Defines a sound that can be played in the application.
  99666. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  99667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99668. */
  99669. export class Sound {
  99670. /**
  99671. * The name of the sound in the scene.
  99672. */
  99673. name: string;
  99674. /**
  99675. * Does the sound autoplay once loaded.
  99676. */
  99677. autoplay: boolean;
  99678. /**
  99679. * Does the sound loop after it finishes playing once.
  99680. */
  99681. loop: boolean;
  99682. /**
  99683. * Does the sound use a custom attenuation curve to simulate the falloff
  99684. * happening when the source gets further away from the camera.
  99685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99686. */
  99687. useCustomAttenuation: boolean;
  99688. /**
  99689. * The sound track id this sound belongs to.
  99690. */
  99691. soundTrackId: number;
  99692. /**
  99693. * Is this sound currently played.
  99694. */
  99695. isPlaying: boolean;
  99696. /**
  99697. * Is this sound currently paused.
  99698. */
  99699. isPaused: boolean;
  99700. /**
  99701. * Does this sound enables spatial sound.
  99702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99703. */
  99704. spatialSound: boolean;
  99705. /**
  99706. * Define the reference distance the sound should be heard perfectly.
  99707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99708. */
  99709. refDistance: number;
  99710. /**
  99711. * Define the roll off factor of spatial sounds.
  99712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99713. */
  99714. rolloffFactor: number;
  99715. /**
  99716. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  99717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99718. */
  99719. maxDistance: number;
  99720. /**
  99721. * Define the distance attenuation model the sound will follow.
  99722. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99723. */
  99724. distanceModel: string;
  99725. /**
  99726. * @hidden
  99727. * Back Compat
  99728. **/
  99729. onended: () => any;
  99730. /**
  99731. * Observable event when the current playing sound finishes.
  99732. */
  99733. onEndedObservable: Observable<Sound>;
  99734. private _panningModel;
  99735. private _playbackRate;
  99736. private _streaming;
  99737. private _startTime;
  99738. private _startOffset;
  99739. private _position;
  99740. /** @hidden */
  99741. _positionInEmitterSpace: boolean;
  99742. private _localDirection;
  99743. private _volume;
  99744. private _isReadyToPlay;
  99745. private _isDirectional;
  99746. private _readyToPlayCallback;
  99747. private _audioBuffer;
  99748. private _soundSource;
  99749. private _streamingSource;
  99750. private _soundPanner;
  99751. private _soundGain;
  99752. private _inputAudioNode;
  99753. private _outputAudioNode;
  99754. private _coneInnerAngle;
  99755. private _coneOuterAngle;
  99756. private _coneOuterGain;
  99757. private _scene;
  99758. private _connectedTransformNode;
  99759. private _customAttenuationFunction;
  99760. private _registerFunc;
  99761. private _isOutputConnected;
  99762. private _htmlAudioElement;
  99763. private _urlType;
  99764. private _length?;
  99765. private _offset?;
  99766. /** @hidden */
  99767. static _SceneComponentInitialization: (scene: Scene) => void;
  99768. /**
  99769. * Create a sound and attach it to a scene
  99770. * @param name Name of your sound
  99771. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  99772. * @param scene defines the scene the sound belongs to
  99773. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  99774. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  99775. */
  99776. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  99777. /**
  99778. * Release the sound and its associated resources
  99779. */
  99780. dispose(): void;
  99781. /**
  99782. * Gets if the sounds is ready to be played or not.
  99783. * @returns true if ready, otherwise false
  99784. */
  99785. isReady(): boolean;
  99786. private _soundLoaded;
  99787. /**
  99788. * Sets the data of the sound from an audiobuffer
  99789. * @param audioBuffer The audioBuffer containing the data
  99790. */
  99791. setAudioBuffer(audioBuffer: AudioBuffer): void;
  99792. /**
  99793. * Updates the current sounds options such as maxdistance, loop...
  99794. * @param options A JSON object containing values named as the object properties
  99795. */
  99796. updateOptions(options: ISoundOptions): void;
  99797. private _createSpatialParameters;
  99798. private _updateSpatialParameters;
  99799. /**
  99800. * Switch the panning model to HRTF:
  99801. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99803. */
  99804. switchPanningModelToHRTF(): void;
  99805. /**
  99806. * Switch the panning model to Equal Power:
  99807. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99809. */
  99810. switchPanningModelToEqualPower(): void;
  99811. private _switchPanningModel;
  99812. /**
  99813. * Connect this sound to a sound track audio node like gain...
  99814. * @param soundTrackAudioNode the sound track audio node to connect to
  99815. */
  99816. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99817. /**
  99818. * Transform this sound into a directional source
  99819. * @param coneInnerAngle Size of the inner cone in degree
  99820. * @param coneOuterAngle Size of the outer cone in degree
  99821. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99822. */
  99823. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99824. /**
  99825. * Gets or sets the inner angle for the directional cone.
  99826. */
  99827. /**
  99828. * Gets or sets the inner angle for the directional cone.
  99829. */
  99830. directionalConeInnerAngle: number;
  99831. /**
  99832. * Gets or sets the outer angle for the directional cone.
  99833. */
  99834. /**
  99835. * Gets or sets the outer angle for the directional cone.
  99836. */
  99837. directionalConeOuterAngle: number;
  99838. /**
  99839. * Sets the position of the emitter if spatial sound is enabled
  99840. * @param newPosition Defines the new posisiton
  99841. */
  99842. setPosition(newPosition: Vector3): void;
  99843. /**
  99844. * Sets the local direction of the emitter if spatial sound is enabled
  99845. * @param newLocalDirection Defines the new local direction
  99846. */
  99847. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99848. private _updateDirection;
  99849. /** @hidden */
  99850. updateDistanceFromListener(): void;
  99851. /**
  99852. * Sets a new custom attenuation function for the sound.
  99853. * @param callback Defines the function used for the attenuation
  99854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99855. */
  99856. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  99857. /**
  99858. * Play the sound
  99859. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  99860. * @param offset (optional) Start the sound at a specific time in seconds
  99861. * @param length (optional) Sound duration (in seconds)
  99862. */
  99863. play(time?: number, offset?: number, length?: number): void;
  99864. private _onended;
  99865. /**
  99866. * Stop the sound
  99867. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  99868. */
  99869. stop(time?: number): void;
  99870. /**
  99871. * Put the sound in pause
  99872. */
  99873. pause(): void;
  99874. /**
  99875. * Sets a dedicated volume for this sounds
  99876. * @param newVolume Define the new volume of the sound
  99877. * @param time Define time for gradual change to new volume
  99878. */
  99879. setVolume(newVolume: number, time?: number): void;
  99880. /**
  99881. * Set the sound play back rate
  99882. * @param newPlaybackRate Define the playback rate the sound should be played at
  99883. */
  99884. setPlaybackRate(newPlaybackRate: number): void;
  99885. /**
  99886. * Gets the volume of the sound.
  99887. * @returns the volume of the sound
  99888. */
  99889. getVolume(): number;
  99890. /**
  99891. * Attach the sound to a dedicated mesh
  99892. * @param transformNode The transform node to connect the sound with
  99893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99894. */
  99895. attachToMesh(transformNode: TransformNode): void;
  99896. /**
  99897. * Detach the sound from the previously attached mesh
  99898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99899. */
  99900. detachFromMesh(): void;
  99901. private _onRegisterAfterWorldMatrixUpdate;
  99902. /**
  99903. * Clone the current sound in the scene.
  99904. * @returns the new sound clone
  99905. */
  99906. clone(): Nullable<Sound>;
  99907. /**
  99908. * Gets the current underlying audio buffer containing the data
  99909. * @returns the audio buffer
  99910. */
  99911. getAudioBuffer(): Nullable<AudioBuffer>;
  99912. /**
  99913. * Serializes the Sound in a JSON representation
  99914. * @returns the JSON representation of the sound
  99915. */
  99916. serialize(): any;
  99917. /**
  99918. * Parse a JSON representation of a sound to innstantiate in a given scene
  99919. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  99920. * @param scene Define the scene the new parsed sound should be created in
  99921. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  99922. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  99923. * @returns the newly parsed sound
  99924. */
  99925. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  99926. }
  99927. }
  99928. declare module BABYLON {
  99929. /**
  99930. * This defines an action helpful to play a defined sound on a triggered action.
  99931. */
  99932. export class PlaySoundAction extends Action {
  99933. private _sound;
  99934. /**
  99935. * Instantiate the action
  99936. * @param triggerOptions defines the trigger options
  99937. * @param sound defines the sound to play
  99938. * @param condition defines the trigger related conditions
  99939. */
  99940. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99941. /** @hidden */
  99942. _prepare(): void;
  99943. /**
  99944. * Execute the action and play the sound.
  99945. */
  99946. execute(): void;
  99947. /**
  99948. * Serializes the actions and its related information.
  99949. * @param parent defines the object to serialize in
  99950. * @returns the serialized object
  99951. */
  99952. serialize(parent: any): any;
  99953. }
  99954. /**
  99955. * This defines an action helpful to stop a defined sound on a triggered action.
  99956. */
  99957. export class StopSoundAction extends Action {
  99958. private _sound;
  99959. /**
  99960. * Instantiate the action
  99961. * @param triggerOptions defines the trigger options
  99962. * @param sound defines the sound to stop
  99963. * @param condition defines the trigger related conditions
  99964. */
  99965. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99966. /** @hidden */
  99967. _prepare(): void;
  99968. /**
  99969. * Execute the action and stop the sound.
  99970. */
  99971. execute(): void;
  99972. /**
  99973. * Serializes the actions and its related information.
  99974. * @param parent defines the object to serialize in
  99975. * @returns the serialized object
  99976. */
  99977. serialize(parent: any): any;
  99978. }
  99979. }
  99980. declare module BABYLON {
  99981. /**
  99982. * This defines an action responsible to change the value of a property
  99983. * by interpolating between its current value and the newly set one once triggered.
  99984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99985. */
  99986. export class InterpolateValueAction extends Action {
  99987. /**
  99988. * Defines the path of the property where the value should be interpolated
  99989. */
  99990. propertyPath: string;
  99991. /**
  99992. * Defines the target value at the end of the interpolation.
  99993. */
  99994. value: any;
  99995. /**
  99996. * Defines the time it will take for the property to interpolate to the value.
  99997. */
  99998. duration: number;
  99999. /**
  100000. * Defines if the other scene animations should be stopped when the action has been triggered
  100001. */
  100002. stopOtherAnimations?: boolean;
  100003. /**
  100004. * Defines a callback raised once the interpolation animation has been done.
  100005. */
  100006. onInterpolationDone?: () => void;
  100007. /**
  100008. * Observable triggered once the interpolation animation has been done.
  100009. */
  100010. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  100011. private _target;
  100012. private _effectiveTarget;
  100013. private _property;
  100014. /**
  100015. * Instantiate the action
  100016. * @param triggerOptions defines the trigger options
  100017. * @param target defines the object containing the value to interpolate
  100018. * @param propertyPath defines the path to the property in the target object
  100019. * @param value defines the target value at the end of the interpolation
  100020. * @param duration deines the time it will take for the property to interpolate to the value.
  100021. * @param condition defines the trigger related conditions
  100022. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  100023. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  100024. */
  100025. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  100026. /** @hidden */
  100027. _prepare(): void;
  100028. /**
  100029. * Execute the action starts the value interpolation.
  100030. */
  100031. execute(): void;
  100032. /**
  100033. * Serializes the actions and its related information.
  100034. * @param parent defines the object to serialize in
  100035. * @returns the serialized object
  100036. */
  100037. serialize(parent: any): any;
  100038. }
  100039. }
  100040. declare module BABYLON {
  100041. /**
  100042. * Options allowed during the creation of a sound track.
  100043. */
  100044. export interface ISoundTrackOptions {
  100045. /**
  100046. * The volume the sound track should take during creation
  100047. */
  100048. volume?: number;
  100049. /**
  100050. * Define if the sound track is the main sound track of the scene
  100051. */
  100052. mainTrack?: boolean;
  100053. }
  100054. /**
  100055. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  100056. * It will be also used in a future release to apply effects on a specific track.
  100057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100058. */
  100059. export class SoundTrack {
  100060. /**
  100061. * The unique identifier of the sound track in the scene.
  100062. */
  100063. id: number;
  100064. /**
  100065. * The list of sounds included in the sound track.
  100066. */
  100067. soundCollection: Array<Sound>;
  100068. private _outputAudioNode;
  100069. private _scene;
  100070. private _isMainTrack;
  100071. private _connectedAnalyser;
  100072. private _options;
  100073. private _isInitialized;
  100074. /**
  100075. * Creates a new sound track.
  100076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100077. * @param scene Define the scene the sound track belongs to
  100078. * @param options
  100079. */
  100080. constructor(scene: Scene, options?: ISoundTrackOptions);
  100081. private _initializeSoundTrackAudioGraph;
  100082. /**
  100083. * Release the sound track and its associated resources
  100084. */
  100085. dispose(): void;
  100086. /**
  100087. * Adds a sound to this sound track
  100088. * @param sound define the cound to add
  100089. * @ignoreNaming
  100090. */
  100091. AddSound(sound: Sound): void;
  100092. /**
  100093. * Removes a sound to this sound track
  100094. * @param sound define the cound to remove
  100095. * @ignoreNaming
  100096. */
  100097. RemoveSound(sound: Sound): void;
  100098. /**
  100099. * Set a global volume for the full sound track.
  100100. * @param newVolume Define the new volume of the sound track
  100101. */
  100102. setVolume(newVolume: number): void;
  100103. /**
  100104. * Switch the panning model to HRTF:
  100105. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100107. */
  100108. switchPanningModelToHRTF(): void;
  100109. /**
  100110. * Switch the panning model to Equal Power:
  100111. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100113. */
  100114. switchPanningModelToEqualPower(): void;
  100115. /**
  100116. * Connect the sound track to an audio analyser allowing some amazing
  100117. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  100118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  100119. * @param analyser The analyser to connect to the engine
  100120. */
  100121. connectToAnalyser(analyser: Analyser): void;
  100122. }
  100123. }
  100124. declare module BABYLON {
  100125. interface AbstractScene {
  100126. /**
  100127. * The list of sounds used in the scene.
  100128. */
  100129. sounds: Nullable<Array<Sound>>;
  100130. }
  100131. interface Scene {
  100132. /**
  100133. * @hidden
  100134. * Backing field
  100135. */
  100136. _mainSoundTrack: SoundTrack;
  100137. /**
  100138. * The main sound track played by the scene.
  100139. * It cotains your primary collection of sounds.
  100140. */
  100141. mainSoundTrack: SoundTrack;
  100142. /**
  100143. * The list of sound tracks added to the scene
  100144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100145. */
  100146. soundTracks: Nullable<Array<SoundTrack>>;
  100147. /**
  100148. * Gets a sound using a given name
  100149. * @param name defines the name to search for
  100150. * @return the found sound or null if not found at all.
  100151. */
  100152. getSoundByName(name: string): Nullable<Sound>;
  100153. /**
  100154. * Gets or sets if audio support is enabled
  100155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100156. */
  100157. audioEnabled: boolean;
  100158. /**
  100159. * Gets or sets if audio will be output to headphones
  100160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100161. */
  100162. headphone: boolean;
  100163. /**
  100164. * Gets or sets custom audio listener position provider
  100165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100166. */
  100167. audioListenerPositionProvider: Nullable<() => Vector3>;
  100168. }
  100169. /**
  100170. * Defines the sound scene component responsible to manage any sounds
  100171. * in a given scene.
  100172. */
  100173. export class AudioSceneComponent implements ISceneSerializableComponent {
  100174. /**
  100175. * The component name helpfull to identify the component in the list of scene components.
  100176. */
  100177. readonly name: string;
  100178. /**
  100179. * The scene the component belongs to.
  100180. */
  100181. scene: Scene;
  100182. private _audioEnabled;
  100183. /**
  100184. * Gets whether audio is enabled or not.
  100185. * Please use related enable/disable method to switch state.
  100186. */
  100187. readonly audioEnabled: boolean;
  100188. private _headphone;
  100189. /**
  100190. * Gets whether audio is outputing to headphone or not.
  100191. * Please use the according Switch methods to change output.
  100192. */
  100193. readonly headphone: boolean;
  100194. private _audioListenerPositionProvider;
  100195. /**
  100196. * Gets the current audio listener position provider
  100197. */
  100198. /**
  100199. * Sets a custom listener position for all sounds in the scene
  100200. * By default, this is the position of the first active camera
  100201. */
  100202. audioListenerPositionProvider: Nullable<() => Vector3>;
  100203. /**
  100204. * Creates a new instance of the component for the given scene
  100205. * @param scene Defines the scene to register the component in
  100206. */
  100207. constructor(scene: Scene);
  100208. /**
  100209. * Registers the component in a given scene
  100210. */
  100211. register(): void;
  100212. /**
  100213. * Rebuilds the elements related to this component in case of
  100214. * context lost for instance.
  100215. */
  100216. rebuild(): void;
  100217. /**
  100218. * Serializes the component data to the specified json object
  100219. * @param serializationObject The object to serialize to
  100220. */
  100221. serialize(serializationObject: any): void;
  100222. /**
  100223. * Adds all the elements from the container to the scene
  100224. * @param container the container holding the elements
  100225. */
  100226. addFromContainer(container: AbstractScene): void;
  100227. /**
  100228. * Removes all the elements in the container from the scene
  100229. * @param container contains the elements to remove
  100230. * @param dispose if the removed element should be disposed (default: false)
  100231. */
  100232. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  100233. /**
  100234. * Disposes the component and the associated ressources.
  100235. */
  100236. dispose(): void;
  100237. /**
  100238. * Disables audio in the associated scene.
  100239. */
  100240. disableAudio(): void;
  100241. /**
  100242. * Enables audio in the associated scene.
  100243. */
  100244. enableAudio(): void;
  100245. /**
  100246. * Switch audio to headphone output.
  100247. */
  100248. switchAudioModeForHeadphones(): void;
  100249. /**
  100250. * Switch audio to normal speakers.
  100251. */
  100252. switchAudioModeForNormalSpeakers(): void;
  100253. private _afterRender;
  100254. }
  100255. }
  100256. declare module BABYLON {
  100257. /**
  100258. * Wraps one or more Sound objects and selects one with random weight for playback.
  100259. */
  100260. export class WeightedSound {
  100261. /** When true a Sound will be selected and played when the current playing Sound completes. */
  100262. loop: boolean;
  100263. private _coneInnerAngle;
  100264. private _coneOuterAngle;
  100265. private _volume;
  100266. /** A Sound is currently playing. */
  100267. isPlaying: boolean;
  100268. /** A Sound is currently paused. */
  100269. isPaused: boolean;
  100270. private _sounds;
  100271. private _weights;
  100272. private _currentIndex?;
  100273. /**
  100274. * Creates a new WeightedSound from the list of sounds given.
  100275. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  100276. * @param sounds Array of Sounds that will be selected from.
  100277. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  100278. */
  100279. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  100280. /**
  100281. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  100282. */
  100283. /**
  100284. * The size of cone in degress for a directional sound in which there will be no attenuation.
  100285. */
  100286. directionalConeInnerAngle: number;
  100287. /**
  100288. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100289. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100290. */
  100291. /**
  100292. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100293. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100294. */
  100295. directionalConeOuterAngle: number;
  100296. /**
  100297. * Playback volume.
  100298. */
  100299. /**
  100300. * Playback volume.
  100301. */
  100302. volume: number;
  100303. private _onended;
  100304. /**
  100305. * Suspend playback
  100306. */
  100307. pause(): void;
  100308. /**
  100309. * Stop playback
  100310. */
  100311. stop(): void;
  100312. /**
  100313. * Start playback.
  100314. * @param startOffset Position the clip head at a specific time in seconds.
  100315. */
  100316. play(startOffset?: number): void;
  100317. }
  100318. }
  100319. declare module BABYLON {
  100320. /**
  100321. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  100322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100323. */
  100324. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  100325. /**
  100326. * Gets the name of the behavior.
  100327. */
  100328. readonly name: string;
  100329. /**
  100330. * The easing function used by animations
  100331. */
  100332. static EasingFunction: BackEase;
  100333. /**
  100334. * The easing mode used by animations
  100335. */
  100336. static EasingMode: number;
  100337. /**
  100338. * The duration of the animation, in milliseconds
  100339. */
  100340. transitionDuration: number;
  100341. /**
  100342. * Length of the distance animated by the transition when lower radius is reached
  100343. */
  100344. lowerRadiusTransitionRange: number;
  100345. /**
  100346. * Length of the distance animated by the transition when upper radius is reached
  100347. */
  100348. upperRadiusTransitionRange: number;
  100349. private _autoTransitionRange;
  100350. /**
  100351. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100352. */
  100353. /**
  100354. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100355. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  100356. */
  100357. autoTransitionRange: boolean;
  100358. private _attachedCamera;
  100359. private _onAfterCheckInputsObserver;
  100360. private _onMeshTargetChangedObserver;
  100361. /**
  100362. * Initializes the behavior.
  100363. */
  100364. init(): void;
  100365. /**
  100366. * Attaches the behavior to its arc rotate camera.
  100367. * @param camera Defines the camera to attach the behavior to
  100368. */
  100369. attach(camera: ArcRotateCamera): void;
  100370. /**
  100371. * Detaches the behavior from its current arc rotate camera.
  100372. */
  100373. detach(): void;
  100374. private _radiusIsAnimating;
  100375. private _radiusBounceTransition;
  100376. private _animatables;
  100377. private _cachedWheelPrecision;
  100378. /**
  100379. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  100380. * @param radiusLimit The limit to check against.
  100381. * @return Bool to indicate if at limit.
  100382. */
  100383. private _isRadiusAtLimit;
  100384. /**
  100385. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  100386. * @param radiusDelta The delta by which to animate to. Can be negative.
  100387. */
  100388. private _applyBoundRadiusAnimation;
  100389. /**
  100390. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  100391. */
  100392. protected _clearAnimationLocks(): void;
  100393. /**
  100394. * Stops and removes all animations that have been applied to the camera
  100395. */
  100396. stopAllAnimations(): void;
  100397. }
  100398. }
  100399. declare module BABYLON {
  100400. /**
  100401. * 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.
  100402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100403. */
  100404. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  100405. /**
  100406. * Gets the name of the behavior.
  100407. */
  100408. readonly name: string;
  100409. private _mode;
  100410. private _radiusScale;
  100411. private _positionScale;
  100412. private _defaultElevation;
  100413. private _elevationReturnTime;
  100414. private _elevationReturnWaitTime;
  100415. private _zoomStopsAnimation;
  100416. private _framingTime;
  100417. /**
  100418. * The easing function used by animations
  100419. */
  100420. static EasingFunction: ExponentialEase;
  100421. /**
  100422. * The easing mode used by animations
  100423. */
  100424. static EasingMode: number;
  100425. /**
  100426. * Sets the current mode used by the behavior
  100427. */
  100428. /**
  100429. * Gets current mode used by the behavior.
  100430. */
  100431. mode: number;
  100432. /**
  100433. * Sets the scale applied to the radius (1 by default)
  100434. */
  100435. /**
  100436. * Gets the scale applied to the radius
  100437. */
  100438. radiusScale: number;
  100439. /**
  100440. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100441. */
  100442. /**
  100443. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100444. */
  100445. positionScale: number;
  100446. /**
  100447. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100448. * behaviour is triggered, in radians.
  100449. */
  100450. /**
  100451. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100452. * behaviour is triggered, in radians.
  100453. */
  100454. defaultElevation: number;
  100455. /**
  100456. * Sets the time (in milliseconds) taken to return to the default beta position.
  100457. * Negative value indicates camera should not return to default.
  100458. */
  100459. /**
  100460. * Gets the time (in milliseconds) taken to return to the default beta position.
  100461. * Negative value indicates camera should not return to default.
  100462. */
  100463. elevationReturnTime: number;
  100464. /**
  100465. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100466. */
  100467. /**
  100468. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100469. */
  100470. elevationReturnWaitTime: number;
  100471. /**
  100472. * Sets the flag that indicates if user zooming should stop animation.
  100473. */
  100474. /**
  100475. * Gets the flag that indicates if user zooming should stop animation.
  100476. */
  100477. zoomStopsAnimation: boolean;
  100478. /**
  100479. * Sets the transition time when framing the mesh, in milliseconds
  100480. */
  100481. /**
  100482. * Gets the transition time when framing the mesh, in milliseconds
  100483. */
  100484. framingTime: number;
  100485. /**
  100486. * Define if the behavior should automatically change the configured
  100487. * camera limits and sensibilities.
  100488. */
  100489. autoCorrectCameraLimitsAndSensibility: boolean;
  100490. private _onPrePointerObservableObserver;
  100491. private _onAfterCheckInputsObserver;
  100492. private _onMeshTargetChangedObserver;
  100493. private _attachedCamera;
  100494. private _isPointerDown;
  100495. private _lastInteractionTime;
  100496. /**
  100497. * Initializes the behavior.
  100498. */
  100499. init(): void;
  100500. /**
  100501. * Attaches the behavior to its arc rotate camera.
  100502. * @param camera Defines the camera to attach the behavior to
  100503. */
  100504. attach(camera: ArcRotateCamera): void;
  100505. /**
  100506. * Detaches the behavior from its current arc rotate camera.
  100507. */
  100508. detach(): void;
  100509. private _animatables;
  100510. private _betaIsAnimating;
  100511. private _betaTransition;
  100512. private _radiusTransition;
  100513. private _vectorTransition;
  100514. /**
  100515. * Targets the given mesh and updates zoom level accordingly.
  100516. * @param mesh The mesh to target.
  100517. * @param radius Optional. If a cached radius position already exists, overrides default.
  100518. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100519. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100520. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100521. */
  100522. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100523. /**
  100524. * Targets the given mesh with its children and updates zoom level accordingly.
  100525. * @param mesh The mesh to target.
  100526. * @param radius Optional. If a cached radius position already exists, overrides default.
  100527. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100528. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100529. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100530. */
  100531. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100532. /**
  100533. * Targets the given meshes with their children and updates zoom level accordingly.
  100534. * @param meshes The mesh to target.
  100535. * @param radius Optional. If a cached radius position already exists, overrides default.
  100536. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100537. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100538. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100539. */
  100540. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100541. /**
  100542. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  100543. * @param minimumWorld Determines the smaller position of the bounding box extend
  100544. * @param maximumWorld Determines the bigger position of the bounding box extend
  100545. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100546. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100547. */
  100548. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100549. /**
  100550. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  100551. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  100552. * frustum width.
  100553. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  100554. * to fully enclose the mesh in the viewing frustum.
  100555. */
  100556. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  100557. /**
  100558. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  100559. * is automatically returned to its default position (expected to be above ground plane).
  100560. */
  100561. private _maintainCameraAboveGround;
  100562. /**
  100563. * Returns the frustum slope based on the canvas ratio and camera FOV
  100564. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  100565. */
  100566. private _getFrustumSlope;
  100567. /**
  100568. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  100569. */
  100570. private _clearAnimationLocks;
  100571. /**
  100572. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100573. */
  100574. private _applyUserInteraction;
  100575. /**
  100576. * Stops and removes all animations that have been applied to the camera
  100577. */
  100578. stopAllAnimations(): void;
  100579. /**
  100580. * Gets a value indicating if the user is moving the camera
  100581. */
  100582. readonly isUserIsMoving: boolean;
  100583. /**
  100584. * The camera can move all the way towards the mesh.
  100585. */
  100586. static IgnoreBoundsSizeMode: number;
  100587. /**
  100588. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  100589. */
  100590. static FitFrustumSidesMode: number;
  100591. }
  100592. }
  100593. declare module BABYLON {
  100594. /**
  100595. * Base class for Camera Pointer Inputs.
  100596. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  100597. * for example usage.
  100598. */
  100599. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  100600. /**
  100601. * Defines the camera the input is attached to.
  100602. */
  100603. abstract camera: Camera;
  100604. /**
  100605. * Whether keyboard modifier keys are pressed at time of last mouse event.
  100606. */
  100607. protected _altKey: boolean;
  100608. protected _ctrlKey: boolean;
  100609. protected _metaKey: boolean;
  100610. protected _shiftKey: boolean;
  100611. /**
  100612. * Which mouse buttons were pressed at time of last mouse event.
  100613. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  100614. */
  100615. protected _buttonsPressed: number;
  100616. /**
  100617. * Defines the buttons associated with the input to handle camera move.
  100618. */
  100619. buttons: number[];
  100620. /**
  100621. * Attach the input controls to a specific dom element to get the input from.
  100622. * @param element Defines the element the controls should be listened from
  100623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100624. */
  100625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100626. /**
  100627. * Detach the current controls from the specified dom element.
  100628. * @param element Defines the element to stop listening the inputs from
  100629. */
  100630. detachControl(element: Nullable<HTMLElement>): void;
  100631. /**
  100632. * Gets the class name of the current input.
  100633. * @returns the class name
  100634. */
  100635. getClassName(): string;
  100636. /**
  100637. * Get the friendly name associated with the input class.
  100638. * @returns the input friendly name
  100639. */
  100640. getSimpleName(): string;
  100641. /**
  100642. * Called on pointer POINTERDOUBLETAP event.
  100643. * Override this method to provide functionality on POINTERDOUBLETAP event.
  100644. */
  100645. protected onDoubleTap(type: string): void;
  100646. /**
  100647. * Called on pointer POINTERMOVE event if only a single touch is active.
  100648. * Override this method to provide functionality.
  100649. */
  100650. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100651. /**
  100652. * Called on pointer POINTERMOVE event if multiple touches are active.
  100653. * Override this method to provide functionality.
  100654. */
  100655. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100656. /**
  100657. * Called on JS contextmenu event.
  100658. * Override this method to provide functionality.
  100659. */
  100660. protected onContextMenu(evt: PointerEvent): void;
  100661. /**
  100662. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100663. * press.
  100664. * Override this method to provide functionality.
  100665. */
  100666. protected onButtonDown(evt: PointerEvent): void;
  100667. /**
  100668. * Called each time a new POINTERUP event occurs. Ie, for each button
  100669. * release.
  100670. * Override this method to provide functionality.
  100671. */
  100672. protected onButtonUp(evt: PointerEvent): void;
  100673. /**
  100674. * Called when window becomes inactive.
  100675. * Override this method to provide functionality.
  100676. */
  100677. protected onLostFocus(): void;
  100678. private _pointerInput;
  100679. private _observer;
  100680. private _onLostFocus;
  100681. private pointA;
  100682. private pointB;
  100683. }
  100684. }
  100685. declare module BABYLON {
  100686. /**
  100687. * Manage the pointers inputs to control an arc rotate camera.
  100688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100689. */
  100690. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  100691. /**
  100692. * Defines the camera the input is attached to.
  100693. */
  100694. camera: ArcRotateCamera;
  100695. /**
  100696. * Gets the class name of the current input.
  100697. * @returns the class name
  100698. */
  100699. getClassName(): string;
  100700. /**
  100701. * Defines the buttons associated with the input to handle camera move.
  100702. */
  100703. buttons: number[];
  100704. /**
  100705. * Defines the pointer angular sensibility along the X axis or how fast is
  100706. * the camera rotating.
  100707. */
  100708. angularSensibilityX: number;
  100709. /**
  100710. * Defines the pointer angular sensibility along the Y axis or how fast is
  100711. * the camera rotating.
  100712. */
  100713. angularSensibilityY: number;
  100714. /**
  100715. * Defines the pointer pinch precision or how fast is the camera zooming.
  100716. */
  100717. pinchPrecision: number;
  100718. /**
  100719. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100720. * from 0.
  100721. * It defines the percentage of current camera.radius to use as delta when
  100722. * pinch zoom is used.
  100723. */
  100724. pinchDeltaPercentage: number;
  100725. /**
  100726. * Defines the pointer panning sensibility or how fast is the camera moving.
  100727. */
  100728. panningSensibility: number;
  100729. /**
  100730. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  100731. */
  100732. multiTouchPanning: boolean;
  100733. /**
  100734. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  100735. * zoom (pinch) through multitouch.
  100736. */
  100737. multiTouchPanAndZoom: boolean;
  100738. /**
  100739. * Revers pinch action direction.
  100740. */
  100741. pinchInwards: boolean;
  100742. private _isPanClick;
  100743. private _twoFingerActivityCount;
  100744. private _isPinching;
  100745. /**
  100746. * Called on pointer POINTERMOVE event if only a single touch is active.
  100747. */
  100748. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100749. /**
  100750. * Called on pointer POINTERDOUBLETAP event.
  100751. */
  100752. protected onDoubleTap(type: string): void;
  100753. /**
  100754. * Called on pointer POINTERMOVE event if multiple touches are active.
  100755. */
  100756. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100757. /**
  100758. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100759. * press.
  100760. */
  100761. protected onButtonDown(evt: PointerEvent): void;
  100762. /**
  100763. * Called each time a new POINTERUP event occurs. Ie, for each button
  100764. * release.
  100765. */
  100766. protected onButtonUp(evt: PointerEvent): void;
  100767. /**
  100768. * Called when window becomes inactive.
  100769. */
  100770. protected onLostFocus(): void;
  100771. }
  100772. }
  100773. declare module BABYLON {
  100774. /**
  100775. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  100776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100777. */
  100778. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  100779. /**
  100780. * Defines the camera the input is attached to.
  100781. */
  100782. camera: ArcRotateCamera;
  100783. /**
  100784. * Defines the list of key codes associated with the up action (increase alpha)
  100785. */
  100786. keysUp: number[];
  100787. /**
  100788. * Defines the list of key codes associated with the down action (decrease alpha)
  100789. */
  100790. keysDown: number[];
  100791. /**
  100792. * Defines the list of key codes associated with the left action (increase beta)
  100793. */
  100794. keysLeft: number[];
  100795. /**
  100796. * Defines the list of key codes associated with the right action (decrease beta)
  100797. */
  100798. keysRight: number[];
  100799. /**
  100800. * Defines the list of key codes associated with the reset action.
  100801. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  100802. */
  100803. keysReset: number[];
  100804. /**
  100805. * Defines the panning sensibility of the inputs.
  100806. * (How fast is the camera paning)
  100807. */
  100808. panningSensibility: number;
  100809. /**
  100810. * Defines the zooming sensibility of the inputs.
  100811. * (How fast is the camera zooming)
  100812. */
  100813. zoomingSensibility: number;
  100814. /**
  100815. * Defines wether maintaining the alt key down switch the movement mode from
  100816. * orientation to zoom.
  100817. */
  100818. useAltToZoom: boolean;
  100819. /**
  100820. * Rotation speed of the camera
  100821. */
  100822. angularSpeed: number;
  100823. private _keys;
  100824. private _ctrlPressed;
  100825. private _altPressed;
  100826. private _onCanvasBlurObserver;
  100827. private _onKeyboardObserver;
  100828. private _engine;
  100829. private _scene;
  100830. /**
  100831. * Attach the input controls to a specific dom element to get the input from.
  100832. * @param element Defines the element the controls should be listened from
  100833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100834. */
  100835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100836. /**
  100837. * Detach the current controls from the specified dom element.
  100838. * @param element Defines the element to stop listening the inputs from
  100839. */
  100840. detachControl(element: Nullable<HTMLElement>): void;
  100841. /**
  100842. * Update the current camera state depending on the inputs that have been used this frame.
  100843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100844. */
  100845. checkInputs(): void;
  100846. /**
  100847. * Gets the class name of the current intput.
  100848. * @returns the class name
  100849. */
  100850. getClassName(): string;
  100851. /**
  100852. * Get the friendly name associated with the input class.
  100853. * @returns the input friendly name
  100854. */
  100855. getSimpleName(): string;
  100856. }
  100857. }
  100858. declare module BABYLON {
  100859. /**
  100860. * Manage the mouse wheel inputs to control an arc rotate camera.
  100861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100862. */
  100863. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  100864. /**
  100865. * Defines the camera the input is attached to.
  100866. */
  100867. camera: ArcRotateCamera;
  100868. /**
  100869. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100870. */
  100871. wheelPrecision: number;
  100872. /**
  100873. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100874. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100875. */
  100876. wheelDeltaPercentage: number;
  100877. private _wheel;
  100878. private _observer;
  100879. private computeDeltaFromMouseWheelLegacyEvent;
  100880. /**
  100881. * Attach the input controls to a specific dom element to get the input from.
  100882. * @param element Defines the element the controls should be listened from
  100883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100884. */
  100885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100886. /**
  100887. * Detach the current controls from the specified dom element.
  100888. * @param element Defines the element to stop listening the inputs from
  100889. */
  100890. detachControl(element: Nullable<HTMLElement>): void;
  100891. /**
  100892. * Gets the class name of the current intput.
  100893. * @returns the class name
  100894. */
  100895. getClassName(): string;
  100896. /**
  100897. * Get the friendly name associated with the input class.
  100898. * @returns the input friendly name
  100899. */
  100900. getSimpleName(): string;
  100901. }
  100902. }
  100903. declare module BABYLON {
  100904. /**
  100905. * Default Inputs manager for the ArcRotateCamera.
  100906. * It groups all the default supported inputs for ease of use.
  100907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100908. */
  100909. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  100910. /**
  100911. * Instantiates a new ArcRotateCameraInputsManager.
  100912. * @param camera Defines the camera the inputs belong to
  100913. */
  100914. constructor(camera: ArcRotateCamera);
  100915. /**
  100916. * Add mouse wheel input support to the input manager.
  100917. * @returns the current input manager
  100918. */
  100919. addMouseWheel(): ArcRotateCameraInputsManager;
  100920. /**
  100921. * Add pointers input support to the input manager.
  100922. * @returns the current input manager
  100923. */
  100924. addPointers(): ArcRotateCameraInputsManager;
  100925. /**
  100926. * Add keyboard input support to the input manager.
  100927. * @returns the current input manager
  100928. */
  100929. addKeyboard(): ArcRotateCameraInputsManager;
  100930. }
  100931. }
  100932. declare module BABYLON {
  100933. /**
  100934. * This represents an orbital type of camera.
  100935. *
  100936. * 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.
  100937. * 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.
  100938. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  100939. */
  100940. export class ArcRotateCamera extends TargetCamera {
  100941. /**
  100942. * Defines the rotation angle of the camera along the longitudinal axis.
  100943. */
  100944. alpha: number;
  100945. /**
  100946. * Defines the rotation angle of the camera along the latitudinal axis.
  100947. */
  100948. beta: number;
  100949. /**
  100950. * Defines the radius of the camera from it s target point.
  100951. */
  100952. radius: number;
  100953. protected _target: Vector3;
  100954. protected _targetHost: Nullable<AbstractMesh>;
  100955. /**
  100956. * Defines the target point of the camera.
  100957. * The camera looks towards it form the radius distance.
  100958. */
  100959. target: Vector3;
  100960. /**
  100961. * Define the current local position of the camera in the scene
  100962. */
  100963. position: Vector3;
  100964. protected _upVector: Vector3;
  100965. protected _upToYMatrix: Matrix;
  100966. protected _YToUpMatrix: Matrix;
  100967. /**
  100968. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  100969. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  100970. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  100971. */
  100972. upVector: Vector3;
  100973. /**
  100974. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  100975. */
  100976. setMatUp(): void;
  100977. /**
  100978. * Current inertia value on the longitudinal axis.
  100979. * The bigger this number the longer it will take for the camera to stop.
  100980. */
  100981. inertialAlphaOffset: number;
  100982. /**
  100983. * Current inertia value on the latitudinal axis.
  100984. * The bigger this number the longer it will take for the camera to stop.
  100985. */
  100986. inertialBetaOffset: number;
  100987. /**
  100988. * Current inertia value on the radius axis.
  100989. * The bigger this number the longer it will take for the camera to stop.
  100990. */
  100991. inertialRadiusOffset: number;
  100992. /**
  100993. * Minimum allowed angle on the longitudinal axis.
  100994. * This can help limiting how the Camera is able to move in the scene.
  100995. */
  100996. lowerAlphaLimit: Nullable<number>;
  100997. /**
  100998. * Maximum allowed angle on the longitudinal axis.
  100999. * This can help limiting how the Camera is able to move in the scene.
  101000. */
  101001. upperAlphaLimit: Nullable<number>;
  101002. /**
  101003. * Minimum allowed angle on the latitudinal axis.
  101004. * This can help limiting how the Camera is able to move in the scene.
  101005. */
  101006. lowerBetaLimit: number;
  101007. /**
  101008. * Maximum allowed angle on the latitudinal axis.
  101009. * This can help limiting how the Camera is able to move in the scene.
  101010. */
  101011. upperBetaLimit: number;
  101012. /**
  101013. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  101014. * This can help limiting how the Camera is able to move in the scene.
  101015. */
  101016. lowerRadiusLimit: Nullable<number>;
  101017. /**
  101018. * Maximum allowed distance of the camera to the target (The camera can not get further).
  101019. * This can help limiting how the Camera is able to move in the scene.
  101020. */
  101021. upperRadiusLimit: Nullable<number>;
  101022. /**
  101023. * Defines the current inertia value used during panning of the camera along the X axis.
  101024. */
  101025. inertialPanningX: number;
  101026. /**
  101027. * Defines the current inertia value used during panning of the camera along the Y axis.
  101028. */
  101029. inertialPanningY: number;
  101030. /**
  101031. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  101032. * Basically if your fingers moves away from more than this distance you will be considered
  101033. * in pinch mode.
  101034. */
  101035. pinchToPanMaxDistance: number;
  101036. /**
  101037. * Defines the maximum distance the camera can pan.
  101038. * This could help keeping the cammera always in your scene.
  101039. */
  101040. panningDistanceLimit: Nullable<number>;
  101041. /**
  101042. * Defines the target of the camera before paning.
  101043. */
  101044. panningOriginTarget: Vector3;
  101045. /**
  101046. * Defines the value of the inertia used during panning.
  101047. * 0 would mean stop inertia and one would mean no decelleration at all.
  101048. */
  101049. panningInertia: number;
  101050. /**
  101051. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  101052. */
  101053. angularSensibilityX: number;
  101054. /**
  101055. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  101056. */
  101057. angularSensibilityY: number;
  101058. /**
  101059. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  101060. */
  101061. pinchPrecision: number;
  101062. /**
  101063. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  101064. * It will be used instead of pinchDeltaPrecision if different from 0.
  101065. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101066. */
  101067. pinchDeltaPercentage: number;
  101068. /**
  101069. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  101070. */
  101071. panningSensibility: number;
  101072. /**
  101073. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  101074. */
  101075. keysUp: number[];
  101076. /**
  101077. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  101078. */
  101079. keysDown: number[];
  101080. /**
  101081. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  101082. */
  101083. keysLeft: number[];
  101084. /**
  101085. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  101086. */
  101087. keysRight: number[];
  101088. /**
  101089. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101090. */
  101091. wheelPrecision: number;
  101092. /**
  101093. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  101094. * It will be used instead of pinchDeltaPrecision if different from 0.
  101095. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101096. */
  101097. wheelDeltaPercentage: number;
  101098. /**
  101099. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  101100. */
  101101. zoomOnFactor: number;
  101102. /**
  101103. * Defines a screen offset for the camera position.
  101104. */
  101105. targetScreenOffset: Vector2;
  101106. /**
  101107. * Allows the camera to be completely reversed.
  101108. * If false the camera can not arrive upside down.
  101109. */
  101110. allowUpsideDown: boolean;
  101111. /**
  101112. * Define if double tap/click is used to restore the previously saved state of the camera.
  101113. */
  101114. useInputToRestoreState: boolean;
  101115. /** @hidden */
  101116. _viewMatrix: Matrix;
  101117. /** @hidden */
  101118. _useCtrlForPanning: boolean;
  101119. /** @hidden */
  101120. _panningMouseButton: number;
  101121. /**
  101122. * Defines the input associated to the camera.
  101123. */
  101124. inputs: ArcRotateCameraInputsManager;
  101125. /** @hidden */
  101126. _reset: () => void;
  101127. /**
  101128. * Defines the allowed panning axis.
  101129. */
  101130. panningAxis: Vector3;
  101131. protected _localDirection: Vector3;
  101132. protected _transformedDirection: Vector3;
  101133. private _bouncingBehavior;
  101134. /**
  101135. * Gets the bouncing behavior of the camera if it has been enabled.
  101136. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101137. */
  101138. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  101139. /**
  101140. * Defines if the bouncing behavior of the camera is enabled on the camera.
  101141. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101142. */
  101143. useBouncingBehavior: boolean;
  101144. private _framingBehavior;
  101145. /**
  101146. * Gets the framing behavior of the camera if it has been enabled.
  101147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101148. */
  101149. readonly framingBehavior: Nullable<FramingBehavior>;
  101150. /**
  101151. * Defines if the framing behavior of the camera is enabled on the camera.
  101152. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101153. */
  101154. useFramingBehavior: boolean;
  101155. private _autoRotationBehavior;
  101156. /**
  101157. * Gets the auto rotation behavior of the camera if it has been enabled.
  101158. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101159. */
  101160. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  101161. /**
  101162. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  101163. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101164. */
  101165. useAutoRotationBehavior: boolean;
  101166. /**
  101167. * Observable triggered when the mesh target has been changed on the camera.
  101168. */
  101169. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  101170. /**
  101171. * Event raised when the camera is colliding with a mesh.
  101172. */
  101173. onCollide: (collidedMesh: AbstractMesh) => void;
  101174. /**
  101175. * Defines whether the camera should check collision with the objects oh the scene.
  101176. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  101177. */
  101178. checkCollisions: boolean;
  101179. /**
  101180. * Defines the collision radius of the camera.
  101181. * This simulates a sphere around the camera.
  101182. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101183. */
  101184. collisionRadius: Vector3;
  101185. protected _collider: Collider;
  101186. protected _previousPosition: Vector3;
  101187. protected _collisionVelocity: Vector3;
  101188. protected _newPosition: Vector3;
  101189. protected _previousAlpha: number;
  101190. protected _previousBeta: number;
  101191. protected _previousRadius: number;
  101192. protected _collisionTriggered: boolean;
  101193. protected _targetBoundingCenter: Nullable<Vector3>;
  101194. private _computationVector;
  101195. /**
  101196. * Instantiates a new ArcRotateCamera in a given scene
  101197. * @param name Defines the name of the camera
  101198. * @param alpha Defines the camera rotation along the logitudinal axis
  101199. * @param beta Defines the camera rotation along the latitudinal axis
  101200. * @param radius Defines the camera distance from its target
  101201. * @param target Defines the camera target
  101202. * @param scene Defines the scene the camera belongs to
  101203. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  101204. */
  101205. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101206. /** @hidden */
  101207. _initCache(): void;
  101208. /** @hidden */
  101209. _updateCache(ignoreParentClass?: boolean): void;
  101210. protected _getTargetPosition(): Vector3;
  101211. private _storedAlpha;
  101212. private _storedBeta;
  101213. private _storedRadius;
  101214. private _storedTarget;
  101215. private _storedTargetScreenOffset;
  101216. /**
  101217. * Stores the current state of the camera (alpha, beta, radius and target)
  101218. * @returns the camera itself
  101219. */
  101220. storeState(): Camera;
  101221. /**
  101222. * @hidden
  101223. * Restored camera state. You must call storeState() first
  101224. */
  101225. _restoreStateValues(): boolean;
  101226. /** @hidden */
  101227. _isSynchronizedViewMatrix(): boolean;
  101228. /**
  101229. * Attached controls to the current camera.
  101230. * @param element Defines the element the controls should be listened from
  101231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101232. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  101233. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  101234. */
  101235. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  101236. /**
  101237. * Detach the current controls from the camera.
  101238. * The camera will stop reacting to inputs.
  101239. * @param element Defines the element to stop listening the inputs from
  101240. */
  101241. detachControl(element: HTMLElement): void;
  101242. /** @hidden */
  101243. _checkInputs(): void;
  101244. protected _checkLimits(): void;
  101245. /**
  101246. * Rebuilds angles (alpha, beta) and radius from the give position and target
  101247. */
  101248. rebuildAnglesAndRadius(): void;
  101249. /**
  101250. * Use a position to define the current camera related information like aplha, beta and radius
  101251. * @param position Defines the position to set the camera at
  101252. */
  101253. setPosition(position: Vector3): void;
  101254. /**
  101255. * Defines the target the camera should look at.
  101256. * This will automatically adapt alpha beta and radius to fit within the new target.
  101257. * @param target Defines the new target as a Vector or a mesh
  101258. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  101259. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  101260. */
  101261. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  101262. /** @hidden */
  101263. _getViewMatrix(): Matrix;
  101264. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  101265. /**
  101266. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  101267. * @param meshes Defines the mesh to zoom on
  101268. * @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)
  101269. */
  101270. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  101271. /**
  101272. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  101273. * The target will be changed but the radius
  101274. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  101275. * @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)
  101276. */
  101277. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  101278. min: Vector3;
  101279. max: Vector3;
  101280. distance: number;
  101281. }, doNotUpdateMaxZ?: boolean): void;
  101282. /**
  101283. * @override
  101284. * Override Camera.createRigCamera
  101285. */
  101286. createRigCamera(name: string, cameraIndex: number): Camera;
  101287. /**
  101288. * @hidden
  101289. * @override
  101290. * Override Camera._updateRigCameras
  101291. */
  101292. _updateRigCameras(): void;
  101293. /**
  101294. * Destroy the camera and release the current resources hold by it.
  101295. */
  101296. dispose(): void;
  101297. /**
  101298. * Gets the current object class name.
  101299. * @return the class name
  101300. */
  101301. getClassName(): string;
  101302. }
  101303. }
  101304. declare module BABYLON {
  101305. /**
  101306. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  101307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101308. */
  101309. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  101310. /**
  101311. * Gets the name of the behavior.
  101312. */
  101313. readonly name: string;
  101314. private _zoomStopsAnimation;
  101315. private _idleRotationSpeed;
  101316. private _idleRotationWaitTime;
  101317. private _idleRotationSpinupTime;
  101318. /**
  101319. * Sets the flag that indicates if user zooming should stop animation.
  101320. */
  101321. /**
  101322. * Gets the flag that indicates if user zooming should stop animation.
  101323. */
  101324. zoomStopsAnimation: boolean;
  101325. /**
  101326. * Sets the default speed at which the camera rotates around the model.
  101327. */
  101328. /**
  101329. * Gets the default speed at which the camera rotates around the model.
  101330. */
  101331. idleRotationSpeed: number;
  101332. /**
  101333. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  101334. */
  101335. /**
  101336. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  101337. */
  101338. idleRotationWaitTime: number;
  101339. /**
  101340. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101341. */
  101342. /**
  101343. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101344. */
  101345. idleRotationSpinupTime: number;
  101346. /**
  101347. * Gets a value indicating if the camera is currently rotating because of this behavior
  101348. */
  101349. readonly rotationInProgress: boolean;
  101350. private _onPrePointerObservableObserver;
  101351. private _onAfterCheckInputsObserver;
  101352. private _attachedCamera;
  101353. private _isPointerDown;
  101354. private _lastFrameTime;
  101355. private _lastInteractionTime;
  101356. private _cameraRotationSpeed;
  101357. /**
  101358. * Initializes the behavior.
  101359. */
  101360. init(): void;
  101361. /**
  101362. * Attaches the behavior to its arc rotate camera.
  101363. * @param camera Defines the camera to attach the behavior to
  101364. */
  101365. attach(camera: ArcRotateCamera): void;
  101366. /**
  101367. * Detaches the behavior from its current arc rotate camera.
  101368. */
  101369. detach(): void;
  101370. /**
  101371. * Returns true if user is scrolling.
  101372. * @return true if user is scrolling.
  101373. */
  101374. private _userIsZooming;
  101375. private _lastFrameRadius;
  101376. private _shouldAnimationStopForInteraction;
  101377. /**
  101378. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101379. */
  101380. private _applyUserInteraction;
  101381. private _userIsMoving;
  101382. }
  101383. }
  101384. declare module BABYLON {
  101385. /**
  101386. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  101387. */
  101388. export class AttachToBoxBehavior implements Behavior<Mesh> {
  101389. private ui;
  101390. /**
  101391. * The name of the behavior
  101392. */
  101393. name: string;
  101394. /**
  101395. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  101396. */
  101397. distanceAwayFromFace: number;
  101398. /**
  101399. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  101400. */
  101401. distanceAwayFromBottomOfFace: number;
  101402. private _faceVectors;
  101403. private _target;
  101404. private _scene;
  101405. private _onRenderObserver;
  101406. private _tmpMatrix;
  101407. private _tmpVector;
  101408. /**
  101409. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  101410. * @param ui The transform node that should be attched to the mesh
  101411. */
  101412. constructor(ui: TransformNode);
  101413. /**
  101414. * Initializes the behavior
  101415. */
  101416. init(): void;
  101417. private _closestFace;
  101418. private _zeroVector;
  101419. private _lookAtTmpMatrix;
  101420. private _lookAtToRef;
  101421. /**
  101422. * Attaches the AttachToBoxBehavior to the passed in mesh
  101423. * @param target The mesh that the specified node will be attached to
  101424. */
  101425. attach(target: Mesh): void;
  101426. /**
  101427. * Detaches the behavior from the mesh
  101428. */
  101429. detach(): void;
  101430. }
  101431. }
  101432. declare module BABYLON {
  101433. /**
  101434. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  101435. */
  101436. export class FadeInOutBehavior implements Behavior<Mesh> {
  101437. /**
  101438. * Time in milliseconds to delay before fading in (Default: 0)
  101439. */
  101440. delay: number;
  101441. /**
  101442. * Time in milliseconds for the mesh to fade in (Default: 300)
  101443. */
  101444. fadeInTime: number;
  101445. private _millisecondsPerFrame;
  101446. private _hovered;
  101447. private _hoverValue;
  101448. private _ownerNode;
  101449. /**
  101450. * Instatiates the FadeInOutBehavior
  101451. */
  101452. constructor();
  101453. /**
  101454. * The name of the behavior
  101455. */
  101456. readonly name: string;
  101457. /**
  101458. * Initializes the behavior
  101459. */
  101460. init(): void;
  101461. /**
  101462. * Attaches the fade behavior on the passed in mesh
  101463. * @param ownerNode The mesh that will be faded in/out once attached
  101464. */
  101465. attach(ownerNode: Mesh): void;
  101466. /**
  101467. * Detaches the behavior from the mesh
  101468. */
  101469. detach(): void;
  101470. /**
  101471. * Triggers the mesh to begin fading in or out
  101472. * @param value if the object should fade in or out (true to fade in)
  101473. */
  101474. fadeIn(value: boolean): void;
  101475. private _update;
  101476. private _setAllVisibility;
  101477. }
  101478. }
  101479. declare module BABYLON {
  101480. /**
  101481. * Class containing a set of static utilities functions for managing Pivots
  101482. * @hidden
  101483. */
  101484. export class PivotTools {
  101485. private static _PivotCached;
  101486. private static _OldPivotPoint;
  101487. private static _PivotTranslation;
  101488. private static _PivotTmpVector;
  101489. /** @hidden */
  101490. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  101491. /** @hidden */
  101492. static _RestorePivotPoint(mesh: AbstractMesh): void;
  101493. }
  101494. }
  101495. declare module BABYLON {
  101496. /**
  101497. * Class containing static functions to help procedurally build meshes
  101498. */
  101499. export class PlaneBuilder {
  101500. /**
  101501. * Creates a plane mesh
  101502. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  101503. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  101504. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  101505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101508. * @param name defines the name of the mesh
  101509. * @param options defines the options used to create the mesh
  101510. * @param scene defines the hosting scene
  101511. * @returns the plane mesh
  101512. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  101513. */
  101514. static CreatePlane(name: string, options: {
  101515. size?: number;
  101516. width?: number;
  101517. height?: number;
  101518. sideOrientation?: number;
  101519. frontUVs?: Vector4;
  101520. backUVs?: Vector4;
  101521. updatable?: boolean;
  101522. sourcePlane?: Plane;
  101523. }, scene?: Nullable<Scene>): Mesh;
  101524. }
  101525. }
  101526. declare module BABYLON {
  101527. /**
  101528. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  101529. */
  101530. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  101531. private static _AnyMouseID;
  101532. /**
  101533. * Abstract mesh the behavior is set on
  101534. */
  101535. attachedNode: AbstractMesh;
  101536. private _dragPlane;
  101537. private _scene;
  101538. private _pointerObserver;
  101539. private _beforeRenderObserver;
  101540. private static _planeScene;
  101541. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  101542. /**
  101543. * 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)
  101544. */
  101545. maxDragAngle: number;
  101546. /**
  101547. * @hidden
  101548. */
  101549. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  101550. /**
  101551. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101552. */
  101553. currentDraggingPointerID: number;
  101554. /**
  101555. * The last position where the pointer hit the drag plane in world space
  101556. */
  101557. lastDragPosition: Vector3;
  101558. /**
  101559. * If the behavior is currently in a dragging state
  101560. */
  101561. dragging: boolean;
  101562. /**
  101563. * 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)
  101564. */
  101565. dragDeltaRatio: number;
  101566. /**
  101567. * If the drag plane orientation should be updated during the dragging (Default: true)
  101568. */
  101569. updateDragPlane: boolean;
  101570. private _debugMode;
  101571. private _moving;
  101572. /**
  101573. * Fires each time the attached mesh is dragged with the pointer
  101574. * * delta between last drag position and current drag position in world space
  101575. * * dragDistance along the drag axis
  101576. * * dragPlaneNormal normal of the current drag plane used during the drag
  101577. * * dragPlanePoint in world space where the drag intersects the drag plane
  101578. */
  101579. onDragObservable: Observable<{
  101580. delta: Vector3;
  101581. dragPlanePoint: Vector3;
  101582. dragPlaneNormal: Vector3;
  101583. dragDistance: number;
  101584. pointerId: number;
  101585. }>;
  101586. /**
  101587. * Fires each time a drag begins (eg. mouse down on mesh)
  101588. */
  101589. onDragStartObservable: Observable<{
  101590. dragPlanePoint: Vector3;
  101591. pointerId: number;
  101592. }>;
  101593. /**
  101594. * Fires each time a drag ends (eg. mouse release after drag)
  101595. */
  101596. onDragEndObservable: Observable<{
  101597. dragPlanePoint: Vector3;
  101598. pointerId: number;
  101599. }>;
  101600. /**
  101601. * If the attached mesh should be moved when dragged
  101602. */
  101603. moveAttached: boolean;
  101604. /**
  101605. * If the drag behavior will react to drag events (Default: true)
  101606. */
  101607. enabled: boolean;
  101608. /**
  101609. * If pointer events should start and release the drag (Default: true)
  101610. */
  101611. startAndReleaseDragOnPointerEvents: boolean;
  101612. /**
  101613. * If camera controls should be detached during the drag
  101614. */
  101615. detachCameraControls: boolean;
  101616. /**
  101617. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  101618. */
  101619. useObjectOrienationForDragging: boolean;
  101620. private _options;
  101621. /**
  101622. * Creates a pointer drag behavior that can be attached to a mesh
  101623. * @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)
  101624. */
  101625. constructor(options?: {
  101626. dragAxis?: Vector3;
  101627. dragPlaneNormal?: Vector3;
  101628. });
  101629. /**
  101630. * Predicate to determine if it is valid to move the object to a new position when it is moved
  101631. */
  101632. validateDrag: (targetPosition: Vector3) => boolean;
  101633. /**
  101634. * The name of the behavior
  101635. */
  101636. readonly name: string;
  101637. /**
  101638. * Initializes the behavior
  101639. */
  101640. init(): void;
  101641. private _tmpVector;
  101642. private _alternatePickedPoint;
  101643. private _worldDragAxis;
  101644. private _targetPosition;
  101645. private _attachedElement;
  101646. /**
  101647. * Attaches the drag behavior the passed in mesh
  101648. * @param ownerNode The mesh that will be dragged around once attached
  101649. */
  101650. attach(ownerNode: AbstractMesh): void;
  101651. /**
  101652. * Force relase the drag action by code.
  101653. */
  101654. releaseDrag(): void;
  101655. private _startDragRay;
  101656. private _lastPointerRay;
  101657. /**
  101658. * Simulates the start of a pointer drag event on the behavior
  101659. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  101660. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  101661. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  101662. */
  101663. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  101664. private _startDrag;
  101665. private _dragDelta;
  101666. private _moveDrag;
  101667. private _pickWithRayOnDragPlane;
  101668. private _pointA;
  101669. private _pointB;
  101670. private _pointC;
  101671. private _lineA;
  101672. private _lineB;
  101673. private _localAxis;
  101674. private _lookAt;
  101675. private _updateDragPlanePosition;
  101676. /**
  101677. * Detaches the behavior from the mesh
  101678. */
  101679. detach(): void;
  101680. }
  101681. }
  101682. declare module BABYLON {
  101683. /**
  101684. * A behavior that when attached to a mesh will allow the mesh to be scaled
  101685. */
  101686. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  101687. private _dragBehaviorA;
  101688. private _dragBehaviorB;
  101689. private _startDistance;
  101690. private _initialScale;
  101691. private _targetScale;
  101692. private _ownerNode;
  101693. private _sceneRenderObserver;
  101694. /**
  101695. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  101696. */
  101697. constructor();
  101698. /**
  101699. * The name of the behavior
  101700. */
  101701. readonly name: string;
  101702. /**
  101703. * Initializes the behavior
  101704. */
  101705. init(): void;
  101706. private _getCurrentDistance;
  101707. /**
  101708. * Attaches the scale behavior the passed in mesh
  101709. * @param ownerNode The mesh that will be scaled around once attached
  101710. */
  101711. attach(ownerNode: Mesh): void;
  101712. /**
  101713. * Detaches the behavior from the mesh
  101714. */
  101715. detach(): void;
  101716. }
  101717. }
  101718. declare module BABYLON {
  101719. /**
  101720. * 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
  101721. */
  101722. export class SixDofDragBehavior implements Behavior<Mesh> {
  101723. private static _virtualScene;
  101724. private _ownerNode;
  101725. private _sceneRenderObserver;
  101726. private _scene;
  101727. private _targetPosition;
  101728. private _virtualOriginMesh;
  101729. private _virtualDragMesh;
  101730. private _pointerObserver;
  101731. private _moving;
  101732. private _startingOrientation;
  101733. /**
  101734. * 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)
  101735. */
  101736. private zDragFactor;
  101737. /**
  101738. * If the object should rotate to face the drag origin
  101739. */
  101740. rotateDraggedObject: boolean;
  101741. /**
  101742. * If the behavior is currently in a dragging state
  101743. */
  101744. dragging: boolean;
  101745. /**
  101746. * 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)
  101747. */
  101748. dragDeltaRatio: number;
  101749. /**
  101750. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101751. */
  101752. currentDraggingPointerID: number;
  101753. /**
  101754. * If camera controls should be detached during the drag
  101755. */
  101756. detachCameraControls: boolean;
  101757. /**
  101758. * Fires each time a drag starts
  101759. */
  101760. onDragStartObservable: Observable<{}>;
  101761. /**
  101762. * Fires each time a drag ends (eg. mouse release after drag)
  101763. */
  101764. onDragEndObservable: Observable<{}>;
  101765. /**
  101766. * 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
  101767. */
  101768. constructor();
  101769. /**
  101770. * The name of the behavior
  101771. */
  101772. readonly name: string;
  101773. /**
  101774. * Initializes the behavior
  101775. */
  101776. init(): void;
  101777. /**
  101778. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  101779. */
  101780. private readonly _pointerCamera;
  101781. /**
  101782. * Attaches the scale behavior the passed in mesh
  101783. * @param ownerNode The mesh that will be scaled around once attached
  101784. */
  101785. attach(ownerNode: Mesh): void;
  101786. /**
  101787. * Detaches the behavior from the mesh
  101788. */
  101789. detach(): void;
  101790. }
  101791. }
  101792. declare module BABYLON {
  101793. /**
  101794. * Class used to apply inverse kinematics to bones
  101795. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  101796. */
  101797. export class BoneIKController {
  101798. private static _tmpVecs;
  101799. private static _tmpQuat;
  101800. private static _tmpMats;
  101801. /**
  101802. * Gets or sets the target mesh
  101803. */
  101804. targetMesh: AbstractMesh;
  101805. /** Gets or sets the mesh used as pole */
  101806. poleTargetMesh: AbstractMesh;
  101807. /**
  101808. * Gets or sets the bone used as pole
  101809. */
  101810. poleTargetBone: Nullable<Bone>;
  101811. /**
  101812. * Gets or sets the target position
  101813. */
  101814. targetPosition: Vector3;
  101815. /**
  101816. * Gets or sets the pole target position
  101817. */
  101818. poleTargetPosition: Vector3;
  101819. /**
  101820. * Gets or sets the pole target local offset
  101821. */
  101822. poleTargetLocalOffset: Vector3;
  101823. /**
  101824. * Gets or sets the pole angle
  101825. */
  101826. poleAngle: number;
  101827. /**
  101828. * Gets or sets the mesh associated with the controller
  101829. */
  101830. mesh: AbstractMesh;
  101831. /**
  101832. * 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)
  101833. */
  101834. slerpAmount: number;
  101835. private _bone1Quat;
  101836. private _bone1Mat;
  101837. private _bone2Ang;
  101838. private _bone1;
  101839. private _bone2;
  101840. private _bone1Length;
  101841. private _bone2Length;
  101842. private _maxAngle;
  101843. private _maxReach;
  101844. private _rightHandedSystem;
  101845. private _bendAxis;
  101846. private _slerping;
  101847. private _adjustRoll;
  101848. /**
  101849. * Gets or sets maximum allowed angle
  101850. */
  101851. maxAngle: number;
  101852. /**
  101853. * Creates a new BoneIKController
  101854. * @param mesh defines the mesh to control
  101855. * @param bone defines the bone to control
  101856. * @param options defines options to set up the controller
  101857. */
  101858. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  101859. targetMesh?: AbstractMesh;
  101860. poleTargetMesh?: AbstractMesh;
  101861. poleTargetBone?: Bone;
  101862. poleTargetLocalOffset?: Vector3;
  101863. poleAngle?: number;
  101864. bendAxis?: Vector3;
  101865. maxAngle?: number;
  101866. slerpAmount?: number;
  101867. });
  101868. private _setMaxAngle;
  101869. /**
  101870. * Force the controller to update the bones
  101871. */
  101872. update(): void;
  101873. }
  101874. }
  101875. declare module BABYLON {
  101876. /**
  101877. * Class used to make a bone look toward a point in space
  101878. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  101879. */
  101880. export class BoneLookController {
  101881. private static _tmpVecs;
  101882. private static _tmpQuat;
  101883. private static _tmpMats;
  101884. /**
  101885. * The target Vector3 that the bone will look at
  101886. */
  101887. target: Vector3;
  101888. /**
  101889. * The mesh that the bone is attached to
  101890. */
  101891. mesh: AbstractMesh;
  101892. /**
  101893. * The bone that will be looking to the target
  101894. */
  101895. bone: Bone;
  101896. /**
  101897. * The up axis of the coordinate system that is used when the bone is rotated
  101898. */
  101899. upAxis: Vector3;
  101900. /**
  101901. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  101902. */
  101903. upAxisSpace: Space;
  101904. /**
  101905. * Used to make an adjustment to the yaw of the bone
  101906. */
  101907. adjustYaw: number;
  101908. /**
  101909. * Used to make an adjustment to the pitch of the bone
  101910. */
  101911. adjustPitch: number;
  101912. /**
  101913. * Used to make an adjustment to the roll of the bone
  101914. */
  101915. adjustRoll: number;
  101916. /**
  101917. * 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)
  101918. */
  101919. slerpAmount: number;
  101920. private _minYaw;
  101921. private _maxYaw;
  101922. private _minPitch;
  101923. private _maxPitch;
  101924. private _minYawSin;
  101925. private _minYawCos;
  101926. private _maxYawSin;
  101927. private _maxYawCos;
  101928. private _midYawConstraint;
  101929. private _minPitchTan;
  101930. private _maxPitchTan;
  101931. private _boneQuat;
  101932. private _slerping;
  101933. private _transformYawPitch;
  101934. private _transformYawPitchInv;
  101935. private _firstFrameSkipped;
  101936. private _yawRange;
  101937. private _fowardAxis;
  101938. /**
  101939. * Gets or sets the minimum yaw angle that the bone can look to
  101940. */
  101941. minYaw: number;
  101942. /**
  101943. * Gets or sets the maximum yaw angle that the bone can look to
  101944. */
  101945. maxYaw: number;
  101946. /**
  101947. * Gets or sets the minimum pitch angle that the bone can look to
  101948. */
  101949. minPitch: number;
  101950. /**
  101951. * Gets or sets the maximum pitch angle that the bone can look to
  101952. */
  101953. maxPitch: number;
  101954. /**
  101955. * Create a BoneLookController
  101956. * @param mesh the mesh that the bone belongs to
  101957. * @param bone the bone that will be looking to the target
  101958. * @param target the target Vector3 to look at
  101959. * @param options optional settings:
  101960. * * maxYaw: the maximum angle the bone will yaw to
  101961. * * minYaw: the minimum angle the bone will yaw to
  101962. * * maxPitch: the maximum angle the bone will pitch to
  101963. * * minPitch: the minimum angle the bone will yaw to
  101964. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  101965. * * upAxis: the up axis of the coordinate system
  101966. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  101967. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  101968. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  101969. * * adjustYaw: used to make an adjustment to the yaw of the bone
  101970. * * adjustPitch: used to make an adjustment to the pitch of the bone
  101971. * * adjustRoll: used to make an adjustment to the roll of the bone
  101972. **/
  101973. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  101974. maxYaw?: number;
  101975. minYaw?: number;
  101976. maxPitch?: number;
  101977. minPitch?: number;
  101978. slerpAmount?: number;
  101979. upAxis?: Vector3;
  101980. upAxisSpace?: Space;
  101981. yawAxis?: Vector3;
  101982. pitchAxis?: Vector3;
  101983. adjustYaw?: number;
  101984. adjustPitch?: number;
  101985. adjustRoll?: number;
  101986. });
  101987. /**
  101988. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  101989. */
  101990. update(): void;
  101991. private _getAngleDiff;
  101992. private _getAngleBetween;
  101993. private _isAngleBetween;
  101994. }
  101995. }
  101996. declare module BABYLON {
  101997. /**
  101998. * Manage the gamepad inputs to control an arc rotate camera.
  101999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102000. */
  102001. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102002. /**
  102003. * Defines the camera the input is attached to.
  102004. */
  102005. camera: ArcRotateCamera;
  102006. /**
  102007. * Defines the gamepad the input is gathering event from.
  102008. */
  102009. gamepad: Nullable<Gamepad>;
  102010. /**
  102011. * Defines the gamepad rotation sensiblity.
  102012. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102013. */
  102014. gamepadRotationSensibility: number;
  102015. /**
  102016. * Defines the gamepad move sensiblity.
  102017. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102018. */
  102019. gamepadMoveSensibility: number;
  102020. private _onGamepadConnectedObserver;
  102021. private _onGamepadDisconnectedObserver;
  102022. /**
  102023. * Attach the input controls to a specific dom element to get the input from.
  102024. * @param element Defines the element the controls should be listened from
  102025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102026. */
  102027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102028. /**
  102029. * Detach the current controls from the specified dom element.
  102030. * @param element Defines the element to stop listening the inputs from
  102031. */
  102032. detachControl(element: Nullable<HTMLElement>): void;
  102033. /**
  102034. * Update the current camera state depending on the inputs that have been used this frame.
  102035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102036. */
  102037. checkInputs(): void;
  102038. /**
  102039. * Gets the class name of the current intput.
  102040. * @returns the class name
  102041. */
  102042. getClassName(): string;
  102043. /**
  102044. * Get the friendly name associated with the input class.
  102045. * @returns the input friendly name
  102046. */
  102047. getSimpleName(): string;
  102048. }
  102049. }
  102050. declare module BABYLON {
  102051. interface ArcRotateCameraInputsManager {
  102052. /**
  102053. * Add orientation input support to the input manager.
  102054. * @returns the current input manager
  102055. */
  102056. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  102057. }
  102058. /**
  102059. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  102060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102061. */
  102062. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  102063. /**
  102064. * Defines the camera the input is attached to.
  102065. */
  102066. camera: ArcRotateCamera;
  102067. /**
  102068. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  102069. */
  102070. alphaCorrection: number;
  102071. /**
  102072. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  102073. */
  102074. gammaCorrection: number;
  102075. private _alpha;
  102076. private _gamma;
  102077. private _dirty;
  102078. private _deviceOrientationHandler;
  102079. /**
  102080. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  102081. */
  102082. constructor();
  102083. /**
  102084. * Attach the input controls to a specific dom element to get the input from.
  102085. * @param element Defines the element the controls should be listened from
  102086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102087. */
  102088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102089. /** @hidden */
  102090. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  102091. /**
  102092. * Update the current camera state depending on the inputs that have been used this frame.
  102093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102094. */
  102095. checkInputs(): void;
  102096. /**
  102097. * Detach the current controls from the specified dom element.
  102098. * @param element Defines the element to stop listening the inputs from
  102099. */
  102100. detachControl(element: Nullable<HTMLElement>): void;
  102101. /**
  102102. * Gets the class name of the current intput.
  102103. * @returns the class name
  102104. */
  102105. getClassName(): string;
  102106. /**
  102107. * Get the friendly name associated with the input class.
  102108. * @returns the input friendly name
  102109. */
  102110. getSimpleName(): string;
  102111. }
  102112. }
  102113. declare module BABYLON {
  102114. /**
  102115. * Listen to mouse events to control the camera.
  102116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102117. */
  102118. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  102119. /**
  102120. * Defines the camera the input is attached to.
  102121. */
  102122. camera: FlyCamera;
  102123. /**
  102124. * Defines if touch is enabled. (Default is true.)
  102125. */
  102126. touchEnabled: boolean;
  102127. /**
  102128. * Defines the buttons associated with the input to handle camera rotation.
  102129. */
  102130. buttons: number[];
  102131. /**
  102132. * Assign buttons for Yaw control.
  102133. */
  102134. buttonsYaw: number[];
  102135. /**
  102136. * Assign buttons for Pitch control.
  102137. */
  102138. buttonsPitch: number[];
  102139. /**
  102140. * Assign buttons for Roll control.
  102141. */
  102142. buttonsRoll: number[];
  102143. /**
  102144. * Detect if any button is being pressed while mouse is moved.
  102145. * -1 = Mouse locked.
  102146. * 0 = Left button.
  102147. * 1 = Middle Button.
  102148. * 2 = Right Button.
  102149. */
  102150. activeButton: number;
  102151. /**
  102152. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  102153. * Higher values reduce its sensitivity.
  102154. */
  102155. angularSensibility: number;
  102156. private _mousemoveCallback;
  102157. private _observer;
  102158. private _rollObserver;
  102159. private previousPosition;
  102160. private noPreventDefault;
  102161. private element;
  102162. /**
  102163. * Listen to mouse events to control the camera.
  102164. * @param touchEnabled Define if touch is enabled. (Default is true.)
  102165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102166. */
  102167. constructor(touchEnabled?: boolean);
  102168. /**
  102169. * Attach the mouse control to the HTML DOM element.
  102170. * @param element Defines the element that listens to the input events.
  102171. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  102172. */
  102173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102174. /**
  102175. * Detach the current controls from the specified dom element.
  102176. * @param element Defines the element to stop listening the inputs from
  102177. */
  102178. detachControl(element: Nullable<HTMLElement>): void;
  102179. /**
  102180. * Gets the class name of the current input.
  102181. * @returns the class name.
  102182. */
  102183. getClassName(): string;
  102184. /**
  102185. * Get the friendly name associated with the input class.
  102186. * @returns the input's friendly name.
  102187. */
  102188. getSimpleName(): string;
  102189. private _pointerInput;
  102190. private _onMouseMove;
  102191. /**
  102192. * Rotate camera by mouse offset.
  102193. */
  102194. private rotateCamera;
  102195. }
  102196. }
  102197. declare module BABYLON {
  102198. /**
  102199. * Default Inputs manager for the FlyCamera.
  102200. * It groups all the default supported inputs for ease of use.
  102201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102202. */
  102203. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  102204. /**
  102205. * Instantiates a new FlyCameraInputsManager.
  102206. * @param camera Defines the camera the inputs belong to.
  102207. */
  102208. constructor(camera: FlyCamera);
  102209. /**
  102210. * Add keyboard input support to the input manager.
  102211. * @returns the new FlyCameraKeyboardMoveInput().
  102212. */
  102213. addKeyboard(): FlyCameraInputsManager;
  102214. /**
  102215. * Add mouse input support to the input manager.
  102216. * @param touchEnabled Enable touch screen support.
  102217. * @returns the new FlyCameraMouseInput().
  102218. */
  102219. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  102220. }
  102221. }
  102222. declare module BABYLON {
  102223. /**
  102224. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102225. * such as in a 3D Space Shooter or a Flight Simulator.
  102226. */
  102227. export class FlyCamera extends TargetCamera {
  102228. /**
  102229. * Define the collision ellipsoid of the camera.
  102230. * This is helpful for simulating a camera body, like a player's body.
  102231. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102232. */
  102233. ellipsoid: Vector3;
  102234. /**
  102235. * Define an offset for the position of the ellipsoid around the camera.
  102236. * This can be helpful if the camera is attached away from the player's body center,
  102237. * such as at its head.
  102238. */
  102239. ellipsoidOffset: Vector3;
  102240. /**
  102241. * Enable or disable collisions of the camera with the rest of the scene objects.
  102242. */
  102243. checkCollisions: boolean;
  102244. /**
  102245. * Enable or disable gravity on the camera.
  102246. */
  102247. applyGravity: boolean;
  102248. /**
  102249. * Define the current direction the camera is moving to.
  102250. */
  102251. cameraDirection: Vector3;
  102252. /**
  102253. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  102254. * This overrides and empties cameraRotation.
  102255. */
  102256. rotationQuaternion: Quaternion;
  102257. /**
  102258. * Track Roll to maintain the wanted Rolling when looking around.
  102259. */
  102260. _trackRoll: number;
  102261. /**
  102262. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  102263. */
  102264. rollCorrect: number;
  102265. /**
  102266. * Mimic a banked turn, Rolling the camera when Yawing.
  102267. * It's recommended to use rollCorrect = 10 for faster banking correction.
  102268. */
  102269. bankedTurn: boolean;
  102270. /**
  102271. * Limit in radians for how much Roll banking will add. (Default: 90°)
  102272. */
  102273. bankedTurnLimit: number;
  102274. /**
  102275. * Value of 0 disables the banked Roll.
  102276. * Value of 1 is equal to the Yaw angle in radians.
  102277. */
  102278. bankedTurnMultiplier: number;
  102279. /**
  102280. * The inputs manager loads all the input sources, such as keyboard and mouse.
  102281. */
  102282. inputs: FlyCameraInputsManager;
  102283. /**
  102284. * Gets the input sensibility for mouse input.
  102285. * Higher values reduce sensitivity.
  102286. */
  102287. /**
  102288. * Sets the input sensibility for a mouse input.
  102289. * Higher values reduce sensitivity.
  102290. */
  102291. angularSensibility: number;
  102292. /**
  102293. * Get the keys for camera movement forward.
  102294. */
  102295. /**
  102296. * Set the keys for camera movement forward.
  102297. */
  102298. keysForward: number[];
  102299. /**
  102300. * Get the keys for camera movement backward.
  102301. */
  102302. keysBackward: number[];
  102303. /**
  102304. * Get the keys for camera movement up.
  102305. */
  102306. /**
  102307. * Set the keys for camera movement up.
  102308. */
  102309. keysUp: number[];
  102310. /**
  102311. * Get the keys for camera movement down.
  102312. */
  102313. /**
  102314. * Set the keys for camera movement down.
  102315. */
  102316. keysDown: number[];
  102317. /**
  102318. * Get the keys for camera movement left.
  102319. */
  102320. /**
  102321. * Set the keys for camera movement left.
  102322. */
  102323. keysLeft: number[];
  102324. /**
  102325. * Set the keys for camera movement right.
  102326. */
  102327. /**
  102328. * Set the keys for camera movement right.
  102329. */
  102330. keysRight: number[];
  102331. /**
  102332. * Event raised when the camera collides with a mesh in the scene.
  102333. */
  102334. onCollide: (collidedMesh: AbstractMesh) => void;
  102335. private _collider;
  102336. private _needMoveForGravity;
  102337. private _oldPosition;
  102338. private _diffPosition;
  102339. private _newPosition;
  102340. /** @hidden */
  102341. _localDirection: Vector3;
  102342. /** @hidden */
  102343. _transformedDirection: Vector3;
  102344. /**
  102345. * Instantiates a FlyCamera.
  102346. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102347. * such as in a 3D Space Shooter or a Flight Simulator.
  102348. * @param name Define the name of the camera in the scene.
  102349. * @param position Define the starting position of the camera in the scene.
  102350. * @param scene Define the scene the camera belongs to.
  102351. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  102352. */
  102353. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102354. /**
  102355. * Attach a control to the HTML DOM element.
  102356. * @param element Defines the element that listens to the input events.
  102357. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  102358. */
  102359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102360. /**
  102361. * Detach a control from the HTML DOM element.
  102362. * The camera will stop reacting to that input.
  102363. * @param element Defines the element that listens to the input events.
  102364. */
  102365. detachControl(element: HTMLElement): void;
  102366. private _collisionMask;
  102367. /**
  102368. * Get the mask that the camera ignores in collision events.
  102369. */
  102370. /**
  102371. * Set the mask that the camera ignores in collision events.
  102372. */
  102373. collisionMask: number;
  102374. /** @hidden */
  102375. _collideWithWorld(displacement: Vector3): void;
  102376. /** @hidden */
  102377. private _onCollisionPositionChange;
  102378. /** @hidden */
  102379. _checkInputs(): void;
  102380. /** @hidden */
  102381. _decideIfNeedsToMove(): boolean;
  102382. /** @hidden */
  102383. _updatePosition(): void;
  102384. /**
  102385. * Restore the Roll to its target value at the rate specified.
  102386. * @param rate - Higher means slower restoring.
  102387. * @hidden
  102388. */
  102389. restoreRoll(rate: number): void;
  102390. /**
  102391. * Destroy the camera and release the current resources held by it.
  102392. */
  102393. dispose(): void;
  102394. /**
  102395. * Get the current object class name.
  102396. * @returns the class name.
  102397. */
  102398. getClassName(): string;
  102399. }
  102400. }
  102401. declare module BABYLON {
  102402. /**
  102403. * Listen to keyboard events to control the camera.
  102404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102405. */
  102406. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  102407. /**
  102408. * Defines the camera the input is attached to.
  102409. */
  102410. camera: FlyCamera;
  102411. /**
  102412. * The list of keyboard keys used to control the forward move of the camera.
  102413. */
  102414. keysForward: number[];
  102415. /**
  102416. * The list of keyboard keys used to control the backward move of the camera.
  102417. */
  102418. keysBackward: number[];
  102419. /**
  102420. * The list of keyboard keys used to control the forward move of the camera.
  102421. */
  102422. keysUp: number[];
  102423. /**
  102424. * The list of keyboard keys used to control the backward move of the camera.
  102425. */
  102426. keysDown: number[];
  102427. /**
  102428. * The list of keyboard keys used to control the right strafe move of the camera.
  102429. */
  102430. keysRight: number[];
  102431. /**
  102432. * The list of keyboard keys used to control the left strafe move of the camera.
  102433. */
  102434. keysLeft: number[];
  102435. private _keys;
  102436. private _onCanvasBlurObserver;
  102437. private _onKeyboardObserver;
  102438. private _engine;
  102439. private _scene;
  102440. /**
  102441. * Attach the input controls to a specific dom element to get the input from.
  102442. * @param element Defines the element the controls should be listened from
  102443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102444. */
  102445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102446. /**
  102447. * Detach the current controls from the specified dom element.
  102448. * @param element Defines the element to stop listening the inputs from
  102449. */
  102450. detachControl(element: Nullable<HTMLElement>): void;
  102451. /**
  102452. * Gets the class name of the current intput.
  102453. * @returns the class name
  102454. */
  102455. getClassName(): string;
  102456. /** @hidden */
  102457. _onLostFocus(e: FocusEvent): void;
  102458. /**
  102459. * Get the friendly name associated with the input class.
  102460. * @returns the input friendly name
  102461. */
  102462. getSimpleName(): string;
  102463. /**
  102464. * Update the current camera state depending on the inputs that have been used this frame.
  102465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102466. */
  102467. checkInputs(): void;
  102468. }
  102469. }
  102470. declare module BABYLON {
  102471. /**
  102472. * Manage the mouse wheel inputs to control a follow camera.
  102473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102474. */
  102475. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  102476. /**
  102477. * Defines the camera the input is attached to.
  102478. */
  102479. camera: FollowCamera;
  102480. /**
  102481. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  102482. */
  102483. axisControlRadius: boolean;
  102484. /**
  102485. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  102486. */
  102487. axisControlHeight: boolean;
  102488. /**
  102489. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  102490. */
  102491. axisControlRotation: boolean;
  102492. /**
  102493. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  102494. * relation to mouseWheel events.
  102495. */
  102496. wheelPrecision: number;
  102497. /**
  102498. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102499. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102500. */
  102501. wheelDeltaPercentage: number;
  102502. private _wheel;
  102503. private _observer;
  102504. /**
  102505. * Attach the input controls to a specific dom element to get the input from.
  102506. * @param element Defines the element the controls should be listened from
  102507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102508. */
  102509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102510. /**
  102511. * Detach the current controls from the specified dom element.
  102512. * @param element Defines the element to stop listening the inputs from
  102513. */
  102514. detachControl(element: Nullable<HTMLElement>): void;
  102515. /**
  102516. * Gets the class name of the current intput.
  102517. * @returns the class name
  102518. */
  102519. getClassName(): string;
  102520. /**
  102521. * Get the friendly name associated with the input class.
  102522. * @returns the input friendly name
  102523. */
  102524. getSimpleName(): string;
  102525. }
  102526. }
  102527. declare module BABYLON {
  102528. /**
  102529. * Manage the pointers inputs to control an follow camera.
  102530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102531. */
  102532. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  102533. /**
  102534. * Defines the camera the input is attached to.
  102535. */
  102536. camera: FollowCamera;
  102537. /**
  102538. * Gets the class name of the current input.
  102539. * @returns the class name
  102540. */
  102541. getClassName(): string;
  102542. /**
  102543. * Defines the pointer angular sensibility along the X axis or how fast is
  102544. * the camera rotating.
  102545. * A negative number will reverse the axis direction.
  102546. */
  102547. angularSensibilityX: number;
  102548. /**
  102549. * Defines the pointer angular sensibility along the Y axis or how fast is
  102550. * the camera rotating.
  102551. * A negative number will reverse the axis direction.
  102552. */
  102553. angularSensibilityY: number;
  102554. /**
  102555. * Defines the pointer pinch precision or how fast is the camera zooming.
  102556. * A negative number will reverse the axis direction.
  102557. */
  102558. pinchPrecision: number;
  102559. /**
  102560. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102561. * from 0.
  102562. * It defines the percentage of current camera.radius to use as delta when
  102563. * pinch zoom is used.
  102564. */
  102565. pinchDeltaPercentage: number;
  102566. /**
  102567. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  102568. */
  102569. axisXControlRadius: boolean;
  102570. /**
  102571. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  102572. */
  102573. axisXControlHeight: boolean;
  102574. /**
  102575. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  102576. */
  102577. axisXControlRotation: boolean;
  102578. /**
  102579. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  102580. */
  102581. axisYControlRadius: boolean;
  102582. /**
  102583. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  102584. */
  102585. axisYControlHeight: boolean;
  102586. /**
  102587. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  102588. */
  102589. axisYControlRotation: boolean;
  102590. /**
  102591. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  102592. */
  102593. axisPinchControlRadius: boolean;
  102594. /**
  102595. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  102596. */
  102597. axisPinchControlHeight: boolean;
  102598. /**
  102599. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  102600. */
  102601. axisPinchControlRotation: boolean;
  102602. /**
  102603. * Log error messages if basic misconfiguration has occurred.
  102604. */
  102605. warningEnable: boolean;
  102606. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102607. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102608. private _warningCounter;
  102609. private _warning;
  102610. }
  102611. }
  102612. declare module BABYLON {
  102613. /**
  102614. * Default Inputs manager for the FollowCamera.
  102615. * It groups all the default supported inputs for ease of use.
  102616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102617. */
  102618. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  102619. /**
  102620. * Instantiates a new FollowCameraInputsManager.
  102621. * @param camera Defines the camera the inputs belong to
  102622. */
  102623. constructor(camera: FollowCamera);
  102624. /**
  102625. * Add keyboard input support to the input manager.
  102626. * @returns the current input manager
  102627. */
  102628. addKeyboard(): FollowCameraInputsManager;
  102629. /**
  102630. * Add mouse wheel input support to the input manager.
  102631. * @returns the current input manager
  102632. */
  102633. addMouseWheel(): FollowCameraInputsManager;
  102634. /**
  102635. * Add pointers input support to the input manager.
  102636. * @returns the current input manager
  102637. */
  102638. addPointers(): FollowCameraInputsManager;
  102639. /**
  102640. * Add orientation input support to the input manager.
  102641. * @returns the current input manager
  102642. */
  102643. addVRDeviceOrientation(): FollowCameraInputsManager;
  102644. }
  102645. }
  102646. declare module BABYLON {
  102647. /**
  102648. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  102649. * an arc rotate version arcFollowCamera are available.
  102650. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102651. */
  102652. export class FollowCamera extends TargetCamera {
  102653. /**
  102654. * Distance the follow camera should follow an object at
  102655. */
  102656. radius: number;
  102657. /**
  102658. * Minimum allowed distance of the camera to the axis of rotation
  102659. * (The camera can not get closer).
  102660. * This can help limiting how the Camera is able to move in the scene.
  102661. */
  102662. lowerRadiusLimit: Nullable<number>;
  102663. /**
  102664. * Maximum allowed distance of the camera to the axis of rotation
  102665. * (The camera can not get further).
  102666. * This can help limiting how the Camera is able to move in the scene.
  102667. */
  102668. upperRadiusLimit: Nullable<number>;
  102669. /**
  102670. * Define a rotation offset between the camera and the object it follows
  102671. */
  102672. rotationOffset: number;
  102673. /**
  102674. * Minimum allowed angle to camera position relative to target object.
  102675. * This can help limiting how the Camera is able to move in the scene.
  102676. */
  102677. lowerRotationOffsetLimit: Nullable<number>;
  102678. /**
  102679. * Maximum allowed angle to camera position relative to target object.
  102680. * This can help limiting how the Camera is able to move in the scene.
  102681. */
  102682. upperRotationOffsetLimit: Nullable<number>;
  102683. /**
  102684. * Define a height offset between the camera and the object it follows.
  102685. * It can help following an object from the top (like a car chaing a plane)
  102686. */
  102687. heightOffset: number;
  102688. /**
  102689. * Minimum allowed height of camera position relative to target object.
  102690. * This can help limiting how the Camera is able to move in the scene.
  102691. */
  102692. lowerHeightOffsetLimit: Nullable<number>;
  102693. /**
  102694. * Maximum allowed height of camera position relative to target object.
  102695. * This can help limiting how the Camera is able to move in the scene.
  102696. */
  102697. upperHeightOffsetLimit: Nullable<number>;
  102698. /**
  102699. * Define how fast the camera can accelerate to follow it s target.
  102700. */
  102701. cameraAcceleration: number;
  102702. /**
  102703. * Define the speed limit of the camera following an object.
  102704. */
  102705. maxCameraSpeed: number;
  102706. /**
  102707. * Define the target of the camera.
  102708. */
  102709. lockedTarget: Nullable<AbstractMesh>;
  102710. /**
  102711. * Defines the input associated with the camera.
  102712. */
  102713. inputs: FollowCameraInputsManager;
  102714. /**
  102715. * Instantiates the follow camera.
  102716. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102717. * @param name Define the name of the camera in the scene
  102718. * @param position Define the position of the camera
  102719. * @param scene Define the scene the camera belong to
  102720. * @param lockedTarget Define the target of the camera
  102721. */
  102722. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  102723. private _follow;
  102724. /**
  102725. * Attached controls to the current camera.
  102726. * @param element Defines the element the controls should be listened from
  102727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102728. */
  102729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102730. /**
  102731. * Detach the current controls from the camera.
  102732. * The camera will stop reacting to inputs.
  102733. * @param element Defines the element to stop listening the inputs from
  102734. */
  102735. detachControl(element: HTMLElement): void;
  102736. /** @hidden */
  102737. _checkInputs(): void;
  102738. private _checkLimits;
  102739. /**
  102740. * Gets the camera class name.
  102741. * @returns the class name
  102742. */
  102743. getClassName(): string;
  102744. }
  102745. /**
  102746. * Arc Rotate version of the follow camera.
  102747. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  102748. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102749. */
  102750. export class ArcFollowCamera extends TargetCamera {
  102751. /** The longitudinal angle of the camera */
  102752. alpha: number;
  102753. /** The latitudinal angle of the camera */
  102754. beta: number;
  102755. /** The radius of the camera from its target */
  102756. radius: number;
  102757. /** Define the camera target (the messh it should follow) */
  102758. target: Nullable<AbstractMesh>;
  102759. private _cartesianCoordinates;
  102760. /**
  102761. * Instantiates a new ArcFollowCamera
  102762. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102763. * @param name Define the name of the camera
  102764. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  102765. * @param beta Define the rotation angle of the camera around the elevation axis
  102766. * @param radius Define the radius of the camera from its target point
  102767. * @param target Define the target of the camera
  102768. * @param scene Define the scene the camera belongs to
  102769. */
  102770. constructor(name: string,
  102771. /** The longitudinal angle of the camera */
  102772. alpha: number,
  102773. /** The latitudinal angle of the camera */
  102774. beta: number,
  102775. /** The radius of the camera from its target */
  102776. radius: number,
  102777. /** Define the camera target (the messh it should follow) */
  102778. target: Nullable<AbstractMesh>, scene: Scene);
  102779. private _follow;
  102780. /** @hidden */
  102781. _checkInputs(): void;
  102782. /**
  102783. * Returns the class name of the object.
  102784. * It is mostly used internally for serialization purposes.
  102785. */
  102786. getClassName(): string;
  102787. }
  102788. }
  102789. declare module BABYLON {
  102790. /**
  102791. * Manage the keyboard inputs to control the movement of a follow camera.
  102792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102793. */
  102794. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  102795. /**
  102796. * Defines the camera the input is attached to.
  102797. */
  102798. camera: FollowCamera;
  102799. /**
  102800. * Defines the list of key codes associated with the up action (increase heightOffset)
  102801. */
  102802. keysHeightOffsetIncr: number[];
  102803. /**
  102804. * Defines the list of key codes associated with the down action (decrease heightOffset)
  102805. */
  102806. keysHeightOffsetDecr: number[];
  102807. /**
  102808. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  102809. */
  102810. keysHeightOffsetModifierAlt: boolean;
  102811. /**
  102812. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  102813. */
  102814. keysHeightOffsetModifierCtrl: boolean;
  102815. /**
  102816. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102817. */
  102818. keysHeightOffsetModifierShift: boolean;
  102819. /**
  102820. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102821. */
  102822. keysRotationOffsetIncr: number[];
  102823. /**
  102824. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102825. */
  102826. keysRotationOffsetDecr: number[];
  102827. /**
  102828. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102829. */
  102830. keysRotationOffsetModifierAlt: boolean;
  102831. /**
  102832. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102833. */
  102834. keysRotationOffsetModifierCtrl: boolean;
  102835. /**
  102836. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102837. */
  102838. keysRotationOffsetModifierShift: boolean;
  102839. /**
  102840. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102841. */
  102842. keysRadiusIncr: number[];
  102843. /**
  102844. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102845. */
  102846. keysRadiusDecr: number[];
  102847. /**
  102848. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102849. */
  102850. keysRadiusModifierAlt: boolean;
  102851. /**
  102852. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  102853. */
  102854. keysRadiusModifierCtrl: boolean;
  102855. /**
  102856. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  102857. */
  102858. keysRadiusModifierShift: boolean;
  102859. /**
  102860. * Defines the rate of change of heightOffset.
  102861. */
  102862. heightSensibility: number;
  102863. /**
  102864. * Defines the rate of change of rotationOffset.
  102865. */
  102866. rotationSensibility: number;
  102867. /**
  102868. * Defines the rate of change of radius.
  102869. */
  102870. radiusSensibility: number;
  102871. private _keys;
  102872. private _ctrlPressed;
  102873. private _altPressed;
  102874. private _shiftPressed;
  102875. private _onCanvasBlurObserver;
  102876. private _onKeyboardObserver;
  102877. private _engine;
  102878. private _scene;
  102879. /**
  102880. * Attach the input controls to a specific dom element to get the input from.
  102881. * @param element Defines the element the controls should be listened from
  102882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102883. */
  102884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102885. /**
  102886. * Detach the current controls from the specified dom element.
  102887. * @param element Defines the element to stop listening the inputs from
  102888. */
  102889. detachControl(element: Nullable<HTMLElement>): void;
  102890. /**
  102891. * Update the current camera state depending on the inputs that have been used this frame.
  102892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102893. */
  102894. checkInputs(): void;
  102895. /**
  102896. * Gets the class name of the current input.
  102897. * @returns the class name
  102898. */
  102899. getClassName(): string;
  102900. /**
  102901. * Get the friendly name associated with the input class.
  102902. * @returns the input friendly name
  102903. */
  102904. getSimpleName(): string;
  102905. /**
  102906. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102907. * allow modification of the heightOffset value.
  102908. */
  102909. private _modifierHeightOffset;
  102910. /**
  102911. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102912. * allow modification of the rotationOffset value.
  102913. */
  102914. private _modifierRotationOffset;
  102915. /**
  102916. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102917. * allow modification of the radius value.
  102918. */
  102919. private _modifierRadius;
  102920. }
  102921. }
  102922. declare module BABYLON {
  102923. interface FreeCameraInputsManager {
  102924. /**
  102925. * @hidden
  102926. */
  102927. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  102928. /**
  102929. * Add orientation input support to the input manager.
  102930. * @returns the current input manager
  102931. */
  102932. addDeviceOrientation(): FreeCameraInputsManager;
  102933. }
  102934. /**
  102935. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  102936. * Screen rotation is taken into account.
  102937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102938. */
  102939. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  102940. private _camera;
  102941. private _screenOrientationAngle;
  102942. private _constantTranform;
  102943. private _screenQuaternion;
  102944. private _alpha;
  102945. private _beta;
  102946. private _gamma;
  102947. /**
  102948. * Can be used to detect if a device orientation sensor is availible on a device
  102949. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  102950. * @returns a promise that will resolve on orientation change
  102951. */
  102952. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  102953. /**
  102954. * @hidden
  102955. */
  102956. _onDeviceOrientationChangedObservable: Observable<void>;
  102957. /**
  102958. * Instantiates a new input
  102959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102960. */
  102961. constructor();
  102962. /**
  102963. * Define the camera controlled by the input.
  102964. */
  102965. camera: FreeCamera;
  102966. /**
  102967. * Attach the input controls to a specific dom element to get the input from.
  102968. * @param element Defines the element the controls should be listened from
  102969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102970. */
  102971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102972. private _orientationChanged;
  102973. private _deviceOrientation;
  102974. /**
  102975. * Detach the current controls from the specified dom element.
  102976. * @param element Defines the element to stop listening the inputs from
  102977. */
  102978. detachControl(element: Nullable<HTMLElement>): void;
  102979. /**
  102980. * Update the current camera state depending on the inputs that have been used this frame.
  102981. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102982. */
  102983. checkInputs(): void;
  102984. /**
  102985. * Gets the class name of the current intput.
  102986. * @returns the class name
  102987. */
  102988. getClassName(): string;
  102989. /**
  102990. * Get the friendly name associated with the input class.
  102991. * @returns the input friendly name
  102992. */
  102993. getSimpleName(): string;
  102994. }
  102995. }
  102996. declare module BABYLON {
  102997. /**
  102998. * Manage the gamepad inputs to control a free camera.
  102999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103000. */
  103001. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103002. /**
  103003. * Define the camera the input is attached to.
  103004. */
  103005. camera: FreeCamera;
  103006. /**
  103007. * Define the Gamepad controlling the input
  103008. */
  103009. gamepad: Nullable<Gamepad>;
  103010. /**
  103011. * Defines the gamepad rotation sensiblity.
  103012. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103013. */
  103014. gamepadAngularSensibility: number;
  103015. /**
  103016. * Defines the gamepad move sensiblity.
  103017. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103018. */
  103019. gamepadMoveSensibility: number;
  103020. private _onGamepadConnectedObserver;
  103021. private _onGamepadDisconnectedObserver;
  103022. private _cameraTransform;
  103023. private _deltaTransform;
  103024. private _vector3;
  103025. private _vector2;
  103026. /**
  103027. * Attach the input controls to a specific dom element to get the input from.
  103028. * @param element Defines the element the controls should be listened from
  103029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103030. */
  103031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103032. /**
  103033. * Detach the current controls from the specified dom element.
  103034. * @param element Defines the element to stop listening the inputs from
  103035. */
  103036. detachControl(element: Nullable<HTMLElement>): void;
  103037. /**
  103038. * Update the current camera state depending on the inputs that have been used this frame.
  103039. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103040. */
  103041. checkInputs(): void;
  103042. /**
  103043. * Gets the class name of the current intput.
  103044. * @returns the class name
  103045. */
  103046. getClassName(): string;
  103047. /**
  103048. * Get the friendly name associated with the input class.
  103049. * @returns the input friendly name
  103050. */
  103051. getSimpleName(): string;
  103052. }
  103053. }
  103054. declare module BABYLON {
  103055. /**
  103056. * Defines the potential axis of a Joystick
  103057. */
  103058. export enum JoystickAxis {
  103059. /** X axis */
  103060. X = 0,
  103061. /** Y axis */
  103062. Y = 1,
  103063. /** Z axis */
  103064. Z = 2
  103065. }
  103066. /**
  103067. * Class used to define virtual joystick (used in touch mode)
  103068. */
  103069. export class VirtualJoystick {
  103070. /**
  103071. * Gets or sets a boolean indicating that left and right values must be inverted
  103072. */
  103073. reverseLeftRight: boolean;
  103074. /**
  103075. * Gets or sets a boolean indicating that up and down values must be inverted
  103076. */
  103077. reverseUpDown: boolean;
  103078. /**
  103079. * Gets the offset value for the position (ie. the change of the position value)
  103080. */
  103081. deltaPosition: Vector3;
  103082. /**
  103083. * Gets a boolean indicating if the virtual joystick was pressed
  103084. */
  103085. pressed: boolean;
  103086. /**
  103087. * Canvas the virtual joystick will render onto, default z-index of this is 5
  103088. */
  103089. static Canvas: Nullable<HTMLCanvasElement>;
  103090. private static _globalJoystickIndex;
  103091. private static vjCanvasContext;
  103092. private static vjCanvasWidth;
  103093. private static vjCanvasHeight;
  103094. private static halfWidth;
  103095. private _action;
  103096. private _axisTargetedByLeftAndRight;
  103097. private _axisTargetedByUpAndDown;
  103098. private _joystickSensibility;
  103099. private _inversedSensibility;
  103100. private _joystickPointerID;
  103101. private _joystickColor;
  103102. private _joystickPointerPos;
  103103. private _joystickPreviousPointerPos;
  103104. private _joystickPointerStartPos;
  103105. private _deltaJoystickVector;
  103106. private _leftJoystick;
  103107. private _touches;
  103108. private _onPointerDownHandlerRef;
  103109. private _onPointerMoveHandlerRef;
  103110. private _onPointerUpHandlerRef;
  103111. private _onResize;
  103112. /**
  103113. * Creates a new virtual joystick
  103114. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103115. */
  103116. constructor(leftJoystick?: boolean);
  103117. /**
  103118. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  103119. * @param newJoystickSensibility defines the new sensibility
  103120. */
  103121. setJoystickSensibility(newJoystickSensibility: number): void;
  103122. private _onPointerDown;
  103123. private _onPointerMove;
  103124. private _onPointerUp;
  103125. /**
  103126. * Change the color of the virtual joystick
  103127. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  103128. */
  103129. setJoystickColor(newColor: string): void;
  103130. /**
  103131. * Defines a callback to call when the joystick is touched
  103132. * @param action defines the callback
  103133. */
  103134. setActionOnTouch(action: () => any): void;
  103135. /**
  103136. * Defines which axis you'd like to control for left & right
  103137. * @param axis defines the axis to use
  103138. */
  103139. setAxisForLeftRight(axis: JoystickAxis): void;
  103140. /**
  103141. * Defines which axis you'd like to control for up & down
  103142. * @param axis defines the axis to use
  103143. */
  103144. setAxisForUpDown(axis: JoystickAxis): void;
  103145. private _drawVirtualJoystick;
  103146. /**
  103147. * Release internal HTML canvas
  103148. */
  103149. releaseCanvas(): void;
  103150. }
  103151. }
  103152. declare module BABYLON {
  103153. interface FreeCameraInputsManager {
  103154. /**
  103155. * Add virtual joystick input support to the input manager.
  103156. * @returns the current input manager
  103157. */
  103158. addVirtualJoystick(): FreeCameraInputsManager;
  103159. }
  103160. /**
  103161. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  103162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103163. */
  103164. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  103165. /**
  103166. * Defines the camera the input is attached to.
  103167. */
  103168. camera: FreeCamera;
  103169. private _leftjoystick;
  103170. private _rightjoystick;
  103171. /**
  103172. * Gets the left stick of the virtual joystick.
  103173. * @returns The virtual Joystick
  103174. */
  103175. getLeftJoystick(): VirtualJoystick;
  103176. /**
  103177. * Gets the right stick of the virtual joystick.
  103178. * @returns The virtual Joystick
  103179. */
  103180. getRightJoystick(): VirtualJoystick;
  103181. /**
  103182. * Update the current camera state depending on the inputs that have been used this frame.
  103183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103184. */
  103185. checkInputs(): void;
  103186. /**
  103187. * Attach the input controls to a specific dom element to get the input from.
  103188. * @param element Defines the element the controls should be listened from
  103189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103190. */
  103191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103192. /**
  103193. * Detach the current controls from the specified dom element.
  103194. * @param element Defines the element to stop listening the inputs from
  103195. */
  103196. detachControl(element: Nullable<HTMLElement>): void;
  103197. /**
  103198. * Gets the class name of the current intput.
  103199. * @returns the class name
  103200. */
  103201. getClassName(): string;
  103202. /**
  103203. * Get the friendly name associated with the input class.
  103204. * @returns the input friendly name
  103205. */
  103206. getSimpleName(): string;
  103207. }
  103208. }
  103209. declare module BABYLON {
  103210. /**
  103211. * This represents a FPS type of camera controlled by touch.
  103212. * This is like a universal camera minus the Gamepad controls.
  103213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103214. */
  103215. export class TouchCamera extends FreeCamera {
  103216. /**
  103217. * Defines the touch sensibility for rotation.
  103218. * The higher the faster.
  103219. */
  103220. touchAngularSensibility: number;
  103221. /**
  103222. * Defines the touch sensibility for move.
  103223. * The higher the faster.
  103224. */
  103225. touchMoveSensibility: number;
  103226. /**
  103227. * Instantiates a new touch camera.
  103228. * This represents a FPS type of camera controlled by touch.
  103229. * This is like a universal camera minus the Gamepad controls.
  103230. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103231. * @param name Define the name of the camera in the scene
  103232. * @param position Define the start position of the camera in the scene
  103233. * @param scene Define the scene the camera belongs to
  103234. */
  103235. constructor(name: string, position: Vector3, scene: Scene);
  103236. /**
  103237. * Gets the current object class name.
  103238. * @return the class name
  103239. */
  103240. getClassName(): string;
  103241. /** @hidden */
  103242. _setupInputs(): void;
  103243. }
  103244. }
  103245. declare module BABYLON {
  103246. /**
  103247. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  103248. * being tilted forward or back and left or right.
  103249. */
  103250. export class DeviceOrientationCamera extends FreeCamera {
  103251. private _initialQuaternion;
  103252. private _quaternionCache;
  103253. private _tmpDragQuaternion;
  103254. private _disablePointerInputWhenUsingDeviceOrientation;
  103255. /**
  103256. * Creates a new device orientation camera
  103257. * @param name The name of the camera
  103258. * @param position The start position camera
  103259. * @param scene The scene the camera belongs to
  103260. */
  103261. constructor(name: string, position: Vector3, scene: Scene);
  103262. /**
  103263. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  103264. */
  103265. disablePointerInputWhenUsingDeviceOrientation: boolean;
  103266. private _dragFactor;
  103267. /**
  103268. * Enabled turning on the y axis when the orientation sensor is active
  103269. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  103270. */
  103271. enableHorizontalDragging(dragFactor?: number): void;
  103272. /**
  103273. * Gets the current instance class name ("DeviceOrientationCamera").
  103274. * This helps avoiding instanceof at run time.
  103275. * @returns the class name
  103276. */
  103277. getClassName(): string;
  103278. /**
  103279. * @hidden
  103280. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  103281. */
  103282. _checkInputs(): void;
  103283. /**
  103284. * Reset the camera to its default orientation on the specified axis only.
  103285. * @param axis The axis to reset
  103286. */
  103287. resetToCurrentRotation(axis?: Axis): void;
  103288. }
  103289. }
  103290. declare module BABYLON {
  103291. /**
  103292. * Defines supported buttons for XBox360 compatible gamepads
  103293. */
  103294. export enum Xbox360Button {
  103295. /** A */
  103296. A = 0,
  103297. /** B */
  103298. B = 1,
  103299. /** X */
  103300. X = 2,
  103301. /** Y */
  103302. Y = 3,
  103303. /** Start */
  103304. Start = 4,
  103305. /** Back */
  103306. Back = 5,
  103307. /** Left button */
  103308. LB = 6,
  103309. /** Right button */
  103310. RB = 7,
  103311. /** Left stick */
  103312. LeftStick = 8,
  103313. /** Right stick */
  103314. RightStick = 9
  103315. }
  103316. /** Defines values for XBox360 DPad */
  103317. export enum Xbox360Dpad {
  103318. /** Up */
  103319. Up = 0,
  103320. /** Down */
  103321. Down = 1,
  103322. /** Left */
  103323. Left = 2,
  103324. /** Right */
  103325. Right = 3
  103326. }
  103327. /**
  103328. * Defines a XBox360 gamepad
  103329. */
  103330. export class Xbox360Pad extends Gamepad {
  103331. private _leftTrigger;
  103332. private _rightTrigger;
  103333. private _onlefttriggerchanged;
  103334. private _onrighttriggerchanged;
  103335. private _onbuttondown;
  103336. private _onbuttonup;
  103337. private _ondpaddown;
  103338. private _ondpadup;
  103339. /** Observable raised when a button is pressed */
  103340. onButtonDownObservable: Observable<Xbox360Button>;
  103341. /** Observable raised when a button is released */
  103342. onButtonUpObservable: Observable<Xbox360Button>;
  103343. /** Observable raised when a pad is pressed */
  103344. onPadDownObservable: Observable<Xbox360Dpad>;
  103345. /** Observable raised when a pad is released */
  103346. onPadUpObservable: Observable<Xbox360Dpad>;
  103347. private _buttonA;
  103348. private _buttonB;
  103349. private _buttonX;
  103350. private _buttonY;
  103351. private _buttonBack;
  103352. private _buttonStart;
  103353. private _buttonLB;
  103354. private _buttonRB;
  103355. private _buttonLeftStick;
  103356. private _buttonRightStick;
  103357. private _dPadUp;
  103358. private _dPadDown;
  103359. private _dPadLeft;
  103360. private _dPadRight;
  103361. private _isXboxOnePad;
  103362. /**
  103363. * Creates a new XBox360 gamepad object
  103364. * @param id defines the id of this gamepad
  103365. * @param index defines its index
  103366. * @param gamepad defines the internal HTML gamepad object
  103367. * @param xboxOne defines if it is a XBox One gamepad
  103368. */
  103369. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  103370. /**
  103371. * Defines the callback to call when left trigger is pressed
  103372. * @param callback defines the callback to use
  103373. */
  103374. onlefttriggerchanged(callback: (value: number) => void): void;
  103375. /**
  103376. * Defines the callback to call when right trigger is pressed
  103377. * @param callback defines the callback to use
  103378. */
  103379. onrighttriggerchanged(callback: (value: number) => void): void;
  103380. /**
  103381. * Gets the left trigger value
  103382. */
  103383. /**
  103384. * Sets the left trigger value
  103385. */
  103386. leftTrigger: number;
  103387. /**
  103388. * Gets the right trigger value
  103389. */
  103390. /**
  103391. * Sets the right trigger value
  103392. */
  103393. rightTrigger: number;
  103394. /**
  103395. * Defines the callback to call when a button is pressed
  103396. * @param callback defines the callback to use
  103397. */
  103398. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  103399. /**
  103400. * Defines the callback to call when a button is released
  103401. * @param callback defines the callback to use
  103402. */
  103403. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  103404. /**
  103405. * Defines the callback to call when a pad is pressed
  103406. * @param callback defines the callback to use
  103407. */
  103408. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  103409. /**
  103410. * Defines the callback to call when a pad is released
  103411. * @param callback defines the callback to use
  103412. */
  103413. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  103414. private _setButtonValue;
  103415. private _setDPadValue;
  103416. /**
  103417. * Gets the value of the `A` button
  103418. */
  103419. /**
  103420. * Sets the value of the `A` button
  103421. */
  103422. buttonA: number;
  103423. /**
  103424. * Gets the value of the `B` button
  103425. */
  103426. /**
  103427. * Sets the value of the `B` button
  103428. */
  103429. buttonB: number;
  103430. /**
  103431. * Gets the value of the `X` button
  103432. */
  103433. /**
  103434. * Sets the value of the `X` button
  103435. */
  103436. buttonX: number;
  103437. /**
  103438. * Gets the value of the `Y` button
  103439. */
  103440. /**
  103441. * Sets the value of the `Y` button
  103442. */
  103443. buttonY: number;
  103444. /**
  103445. * Gets the value of the `Start` button
  103446. */
  103447. /**
  103448. * Sets the value of the `Start` button
  103449. */
  103450. buttonStart: number;
  103451. /**
  103452. * Gets the value of the `Back` button
  103453. */
  103454. /**
  103455. * Sets the value of the `Back` button
  103456. */
  103457. buttonBack: number;
  103458. /**
  103459. * Gets the value of the `Left` button
  103460. */
  103461. /**
  103462. * Sets the value of the `Left` button
  103463. */
  103464. buttonLB: number;
  103465. /**
  103466. * Gets the value of the `Right` button
  103467. */
  103468. /**
  103469. * Sets the value of the `Right` button
  103470. */
  103471. buttonRB: number;
  103472. /**
  103473. * Gets the value of the Left joystick
  103474. */
  103475. /**
  103476. * Sets the value of the Left joystick
  103477. */
  103478. buttonLeftStick: number;
  103479. /**
  103480. * Gets the value of the Right joystick
  103481. */
  103482. /**
  103483. * Sets the value of the Right joystick
  103484. */
  103485. buttonRightStick: number;
  103486. /**
  103487. * Gets the value of D-pad up
  103488. */
  103489. /**
  103490. * Sets the value of D-pad up
  103491. */
  103492. dPadUp: number;
  103493. /**
  103494. * Gets the value of D-pad down
  103495. */
  103496. /**
  103497. * Sets the value of D-pad down
  103498. */
  103499. dPadDown: number;
  103500. /**
  103501. * Gets the value of D-pad left
  103502. */
  103503. /**
  103504. * Sets the value of D-pad left
  103505. */
  103506. dPadLeft: number;
  103507. /**
  103508. * Gets the value of D-pad right
  103509. */
  103510. /**
  103511. * Sets the value of D-pad right
  103512. */
  103513. dPadRight: number;
  103514. /**
  103515. * Force the gamepad to synchronize with device values
  103516. */
  103517. update(): void;
  103518. /**
  103519. * Disposes the gamepad
  103520. */
  103521. dispose(): void;
  103522. }
  103523. }
  103524. declare module BABYLON {
  103525. /**
  103526. * Defines supported buttons for DualShock compatible gamepads
  103527. */
  103528. export enum DualShockButton {
  103529. /** Cross */
  103530. Cross = 0,
  103531. /** Circle */
  103532. Circle = 1,
  103533. /** Square */
  103534. Square = 2,
  103535. /** Triangle */
  103536. Triangle = 3,
  103537. /** Options */
  103538. Options = 4,
  103539. /** Share */
  103540. Share = 5,
  103541. /** L1 */
  103542. L1 = 6,
  103543. /** R1 */
  103544. R1 = 7,
  103545. /** Left stick */
  103546. LeftStick = 8,
  103547. /** Right stick */
  103548. RightStick = 9
  103549. }
  103550. /** Defines values for DualShock DPad */
  103551. export enum DualShockDpad {
  103552. /** Up */
  103553. Up = 0,
  103554. /** Down */
  103555. Down = 1,
  103556. /** Left */
  103557. Left = 2,
  103558. /** Right */
  103559. Right = 3
  103560. }
  103561. /**
  103562. * Defines a DualShock gamepad
  103563. */
  103564. export class DualShockPad extends Gamepad {
  103565. private _leftTrigger;
  103566. private _rightTrigger;
  103567. private _onlefttriggerchanged;
  103568. private _onrighttriggerchanged;
  103569. private _onbuttondown;
  103570. private _onbuttonup;
  103571. private _ondpaddown;
  103572. private _ondpadup;
  103573. /** Observable raised when a button is pressed */
  103574. onButtonDownObservable: Observable<DualShockButton>;
  103575. /** Observable raised when a button is released */
  103576. onButtonUpObservable: Observable<DualShockButton>;
  103577. /** Observable raised when a pad is pressed */
  103578. onPadDownObservable: Observable<DualShockDpad>;
  103579. /** Observable raised when a pad is released */
  103580. onPadUpObservable: Observable<DualShockDpad>;
  103581. private _buttonCross;
  103582. private _buttonCircle;
  103583. private _buttonSquare;
  103584. private _buttonTriangle;
  103585. private _buttonShare;
  103586. private _buttonOptions;
  103587. private _buttonL1;
  103588. private _buttonR1;
  103589. private _buttonLeftStick;
  103590. private _buttonRightStick;
  103591. private _dPadUp;
  103592. private _dPadDown;
  103593. private _dPadLeft;
  103594. private _dPadRight;
  103595. /**
  103596. * Creates a new DualShock gamepad object
  103597. * @param id defines the id of this gamepad
  103598. * @param index defines its index
  103599. * @param gamepad defines the internal HTML gamepad object
  103600. */
  103601. constructor(id: string, index: number, gamepad: any);
  103602. /**
  103603. * Defines the callback to call when left trigger is pressed
  103604. * @param callback defines the callback to use
  103605. */
  103606. onlefttriggerchanged(callback: (value: number) => void): void;
  103607. /**
  103608. * Defines the callback to call when right trigger is pressed
  103609. * @param callback defines the callback to use
  103610. */
  103611. onrighttriggerchanged(callback: (value: number) => void): void;
  103612. /**
  103613. * Gets the left trigger value
  103614. */
  103615. /**
  103616. * Sets the left trigger value
  103617. */
  103618. leftTrigger: number;
  103619. /**
  103620. * Gets the right trigger value
  103621. */
  103622. /**
  103623. * Sets the right trigger value
  103624. */
  103625. rightTrigger: number;
  103626. /**
  103627. * Defines the callback to call when a button is pressed
  103628. * @param callback defines the callback to use
  103629. */
  103630. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  103631. /**
  103632. * Defines the callback to call when a button is released
  103633. * @param callback defines the callback to use
  103634. */
  103635. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  103636. /**
  103637. * Defines the callback to call when a pad is pressed
  103638. * @param callback defines the callback to use
  103639. */
  103640. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  103641. /**
  103642. * Defines the callback to call when a pad is released
  103643. * @param callback defines the callback to use
  103644. */
  103645. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  103646. private _setButtonValue;
  103647. private _setDPadValue;
  103648. /**
  103649. * Gets the value of the `Cross` button
  103650. */
  103651. /**
  103652. * Sets the value of the `Cross` button
  103653. */
  103654. buttonCross: number;
  103655. /**
  103656. * Gets the value of the `Circle` button
  103657. */
  103658. /**
  103659. * Sets the value of the `Circle` button
  103660. */
  103661. buttonCircle: number;
  103662. /**
  103663. * Gets the value of the `Square` button
  103664. */
  103665. /**
  103666. * Sets the value of the `Square` button
  103667. */
  103668. buttonSquare: number;
  103669. /**
  103670. * Gets the value of the `Triangle` button
  103671. */
  103672. /**
  103673. * Sets the value of the `Triangle` button
  103674. */
  103675. buttonTriangle: number;
  103676. /**
  103677. * Gets the value of the `Options` button
  103678. */
  103679. /**
  103680. * Sets the value of the `Options` button
  103681. */
  103682. buttonOptions: number;
  103683. /**
  103684. * Gets the value of the `Share` button
  103685. */
  103686. /**
  103687. * Sets the value of the `Share` button
  103688. */
  103689. buttonShare: number;
  103690. /**
  103691. * Gets the value of the `L1` button
  103692. */
  103693. /**
  103694. * Sets the value of the `L1` button
  103695. */
  103696. buttonL1: number;
  103697. /**
  103698. * Gets the value of the `R1` button
  103699. */
  103700. /**
  103701. * Sets the value of the `R1` button
  103702. */
  103703. buttonR1: number;
  103704. /**
  103705. * Gets the value of the Left joystick
  103706. */
  103707. /**
  103708. * Sets the value of the Left joystick
  103709. */
  103710. buttonLeftStick: number;
  103711. /**
  103712. * Gets the value of the Right joystick
  103713. */
  103714. /**
  103715. * Sets the value of the Right joystick
  103716. */
  103717. buttonRightStick: number;
  103718. /**
  103719. * Gets the value of D-pad up
  103720. */
  103721. /**
  103722. * Sets the value of D-pad up
  103723. */
  103724. dPadUp: number;
  103725. /**
  103726. * Gets the value of D-pad down
  103727. */
  103728. /**
  103729. * Sets the value of D-pad down
  103730. */
  103731. dPadDown: number;
  103732. /**
  103733. * Gets the value of D-pad left
  103734. */
  103735. /**
  103736. * Sets the value of D-pad left
  103737. */
  103738. dPadLeft: number;
  103739. /**
  103740. * Gets the value of D-pad right
  103741. */
  103742. /**
  103743. * Sets the value of D-pad right
  103744. */
  103745. dPadRight: number;
  103746. /**
  103747. * Force the gamepad to synchronize with device values
  103748. */
  103749. update(): void;
  103750. /**
  103751. * Disposes the gamepad
  103752. */
  103753. dispose(): void;
  103754. }
  103755. }
  103756. declare module BABYLON {
  103757. /**
  103758. * Manager for handling gamepads
  103759. */
  103760. export class GamepadManager {
  103761. private _scene?;
  103762. private _babylonGamepads;
  103763. private _oneGamepadConnected;
  103764. /** @hidden */
  103765. _isMonitoring: boolean;
  103766. private _gamepadEventSupported;
  103767. private _gamepadSupport;
  103768. /**
  103769. * observable to be triggered when the gamepad controller has been connected
  103770. */
  103771. onGamepadConnectedObservable: Observable<Gamepad>;
  103772. /**
  103773. * observable to be triggered when the gamepad controller has been disconnected
  103774. */
  103775. onGamepadDisconnectedObservable: Observable<Gamepad>;
  103776. private _onGamepadConnectedEvent;
  103777. private _onGamepadDisconnectedEvent;
  103778. /**
  103779. * Initializes the gamepad manager
  103780. * @param _scene BabylonJS scene
  103781. */
  103782. constructor(_scene?: Scene | undefined);
  103783. /**
  103784. * The gamepads in the game pad manager
  103785. */
  103786. readonly gamepads: Gamepad[];
  103787. /**
  103788. * Get the gamepad controllers based on type
  103789. * @param type The type of gamepad controller
  103790. * @returns Nullable gamepad
  103791. */
  103792. getGamepadByType(type?: number): Nullable<Gamepad>;
  103793. /**
  103794. * Disposes the gamepad manager
  103795. */
  103796. dispose(): void;
  103797. private _addNewGamepad;
  103798. private _startMonitoringGamepads;
  103799. private _stopMonitoringGamepads;
  103800. /** @hidden */
  103801. _checkGamepadsStatus(): void;
  103802. private _updateGamepadObjects;
  103803. }
  103804. }
  103805. declare module BABYLON {
  103806. interface Scene {
  103807. /** @hidden */
  103808. _gamepadManager: Nullable<GamepadManager>;
  103809. /**
  103810. * Gets the gamepad manager associated with the scene
  103811. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  103812. */
  103813. gamepadManager: GamepadManager;
  103814. }
  103815. /**
  103816. * Interface representing a free camera inputs manager
  103817. */
  103818. interface FreeCameraInputsManager {
  103819. /**
  103820. * Adds gamepad input support to the FreeCameraInputsManager.
  103821. * @returns the FreeCameraInputsManager
  103822. */
  103823. addGamepad(): FreeCameraInputsManager;
  103824. }
  103825. /**
  103826. * Interface representing an arc rotate camera inputs manager
  103827. */
  103828. interface ArcRotateCameraInputsManager {
  103829. /**
  103830. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103831. * @returns the camera inputs manager
  103832. */
  103833. addGamepad(): ArcRotateCameraInputsManager;
  103834. }
  103835. /**
  103836. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103837. */
  103838. export class GamepadSystemSceneComponent implements ISceneComponent {
  103839. /**
  103840. * The component name helpfull to identify the component in the list of scene components.
  103841. */
  103842. readonly name: string;
  103843. /**
  103844. * The scene the component belongs to.
  103845. */
  103846. scene: Scene;
  103847. /**
  103848. * Creates a new instance of the component for the given scene
  103849. * @param scene Defines the scene to register the component in
  103850. */
  103851. constructor(scene: Scene);
  103852. /**
  103853. * Registers the component in a given scene
  103854. */
  103855. register(): void;
  103856. /**
  103857. * Rebuilds the elements related to this component in case of
  103858. * context lost for instance.
  103859. */
  103860. rebuild(): void;
  103861. /**
  103862. * Disposes the component and the associated ressources
  103863. */
  103864. dispose(): void;
  103865. private _beforeCameraUpdate;
  103866. }
  103867. }
  103868. declare module BABYLON {
  103869. /**
  103870. * 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,
  103871. * which still works and will still be found in many Playgrounds.
  103872. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103873. */
  103874. export class UniversalCamera extends TouchCamera {
  103875. /**
  103876. * Defines the gamepad rotation sensiblity.
  103877. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103878. */
  103879. gamepadAngularSensibility: number;
  103880. /**
  103881. * Defines the gamepad move sensiblity.
  103882. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103883. */
  103884. gamepadMoveSensibility: number;
  103885. /**
  103886. * 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,
  103887. * which still works and will still be found in many Playgrounds.
  103888. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103889. * @param name Define the name of the camera in the scene
  103890. * @param position Define the start position of the camera in the scene
  103891. * @param scene Define the scene the camera belongs to
  103892. */
  103893. constructor(name: string, position: Vector3, scene: Scene);
  103894. /**
  103895. * Gets the current object class name.
  103896. * @return the class name
  103897. */
  103898. getClassName(): string;
  103899. }
  103900. }
  103901. declare module BABYLON {
  103902. /**
  103903. * This represents a FPS type of camera. This is only here for back compat purpose.
  103904. * Please use the UniversalCamera instead as both are identical.
  103905. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103906. */
  103907. export class GamepadCamera extends UniversalCamera {
  103908. /**
  103909. * Instantiates a new Gamepad Camera
  103910. * This represents a FPS type of camera. This is only here for back compat purpose.
  103911. * Please use the UniversalCamera instead as both are identical.
  103912. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103913. * @param name Define the name of the camera in the scene
  103914. * @param position Define the start position of the camera in the scene
  103915. * @param scene Define the scene the camera belongs to
  103916. */
  103917. constructor(name: string, position: Vector3, scene: Scene);
  103918. /**
  103919. * Gets the current object class name.
  103920. * @return the class name
  103921. */
  103922. getClassName(): string;
  103923. }
  103924. }
  103925. declare module BABYLON {
  103926. /** @hidden */
  103927. export var passPixelShader: {
  103928. name: string;
  103929. shader: string;
  103930. };
  103931. }
  103932. declare module BABYLON {
  103933. /** @hidden */
  103934. export var passCubePixelShader: {
  103935. name: string;
  103936. shader: string;
  103937. };
  103938. }
  103939. declare module BABYLON {
  103940. /**
  103941. * PassPostProcess which produces an output the same as it's input
  103942. */
  103943. export class PassPostProcess extends PostProcess {
  103944. /**
  103945. * Creates the PassPostProcess
  103946. * @param name The name of the effect.
  103947. * @param options The required width/height ratio to downsize to before computing the render pass.
  103948. * @param camera The camera to apply the render pass to.
  103949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103950. * @param engine The engine which the post process will be applied. (default: current engine)
  103951. * @param reusable If the post process can be reused on the same frame. (default: false)
  103952. * @param textureType The type of texture to be used when performing the post processing.
  103953. * @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)
  103954. */
  103955. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103956. }
  103957. /**
  103958. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  103959. */
  103960. export class PassCubePostProcess extends PostProcess {
  103961. private _face;
  103962. /**
  103963. * Gets or sets the cube face to display.
  103964. * * 0 is +X
  103965. * * 1 is -X
  103966. * * 2 is +Y
  103967. * * 3 is -Y
  103968. * * 4 is +Z
  103969. * * 5 is -Z
  103970. */
  103971. face: number;
  103972. /**
  103973. * Creates the PassCubePostProcess
  103974. * @param name The name of the effect.
  103975. * @param options The required width/height ratio to downsize to before computing the render pass.
  103976. * @param camera The camera to apply the render pass to.
  103977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103978. * @param engine The engine which the post process will be applied. (default: current engine)
  103979. * @param reusable If the post process can be reused on the same frame. (default: false)
  103980. * @param textureType The type of texture to be used when performing the post processing.
  103981. * @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)
  103982. */
  103983. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103984. }
  103985. }
  103986. declare module BABYLON {
  103987. /** @hidden */
  103988. export var anaglyphPixelShader: {
  103989. name: string;
  103990. shader: string;
  103991. };
  103992. }
  103993. declare module BABYLON {
  103994. /**
  103995. * Postprocess used to generate anaglyphic rendering
  103996. */
  103997. export class AnaglyphPostProcess extends PostProcess {
  103998. private _passedProcess;
  103999. /**
  104000. * Creates a new AnaglyphPostProcess
  104001. * @param name defines postprocess name
  104002. * @param options defines creation options or target ratio scale
  104003. * @param rigCameras defines cameras using this postprocess
  104004. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  104005. * @param engine defines hosting engine
  104006. * @param reusable defines if the postprocess will be reused multiple times per frame
  104007. */
  104008. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  104009. }
  104010. }
  104011. declare module BABYLON {
  104012. /**
  104013. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  104014. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104015. */
  104016. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  104017. /**
  104018. * Creates a new AnaglyphArcRotateCamera
  104019. * @param name defines camera name
  104020. * @param alpha defines alpha angle (in radians)
  104021. * @param beta defines beta angle (in radians)
  104022. * @param radius defines radius
  104023. * @param target defines camera target
  104024. * @param interaxialDistance defines distance between each color axis
  104025. * @param scene defines the hosting scene
  104026. */
  104027. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  104028. /**
  104029. * Gets camera class name
  104030. * @returns AnaglyphArcRotateCamera
  104031. */
  104032. getClassName(): string;
  104033. }
  104034. }
  104035. declare module BABYLON {
  104036. /**
  104037. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  104038. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104039. */
  104040. export class AnaglyphFreeCamera extends FreeCamera {
  104041. /**
  104042. * Creates a new AnaglyphFreeCamera
  104043. * @param name defines camera name
  104044. * @param position defines initial position
  104045. * @param interaxialDistance defines distance between each color axis
  104046. * @param scene defines the hosting scene
  104047. */
  104048. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104049. /**
  104050. * Gets camera class name
  104051. * @returns AnaglyphFreeCamera
  104052. */
  104053. getClassName(): string;
  104054. }
  104055. }
  104056. declare module BABYLON {
  104057. /**
  104058. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  104059. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104060. */
  104061. export class AnaglyphGamepadCamera extends GamepadCamera {
  104062. /**
  104063. * Creates a new AnaglyphGamepadCamera
  104064. * @param name defines camera name
  104065. * @param position defines initial position
  104066. * @param interaxialDistance defines distance between each color axis
  104067. * @param scene defines the hosting scene
  104068. */
  104069. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104070. /**
  104071. * Gets camera class name
  104072. * @returns AnaglyphGamepadCamera
  104073. */
  104074. getClassName(): string;
  104075. }
  104076. }
  104077. declare module BABYLON {
  104078. /**
  104079. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  104080. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104081. */
  104082. export class AnaglyphUniversalCamera extends UniversalCamera {
  104083. /**
  104084. * Creates a new AnaglyphUniversalCamera
  104085. * @param name defines camera name
  104086. * @param position defines initial position
  104087. * @param interaxialDistance defines distance between each color axis
  104088. * @param scene defines the hosting scene
  104089. */
  104090. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104091. /**
  104092. * Gets camera class name
  104093. * @returns AnaglyphUniversalCamera
  104094. */
  104095. getClassName(): string;
  104096. }
  104097. }
  104098. declare module BABYLON {
  104099. /** @hidden */
  104100. export var stereoscopicInterlacePixelShader: {
  104101. name: string;
  104102. shader: string;
  104103. };
  104104. }
  104105. declare module BABYLON {
  104106. /**
  104107. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  104108. */
  104109. export class StereoscopicInterlacePostProcess extends PostProcess {
  104110. private _stepSize;
  104111. private _passedProcess;
  104112. /**
  104113. * Initializes a StereoscopicInterlacePostProcess
  104114. * @param name The name of the effect.
  104115. * @param rigCameras The rig cameras to be appled to the post process
  104116. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  104117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104118. * @param engine The engine which the post process will be applied. (default: current engine)
  104119. * @param reusable If the post process can be reused on the same frame. (default: false)
  104120. */
  104121. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  104122. }
  104123. }
  104124. declare module BABYLON {
  104125. /**
  104126. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  104127. * @see http://doc.babylonjs.com/features/cameras
  104128. */
  104129. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  104130. /**
  104131. * Creates a new StereoscopicArcRotateCamera
  104132. * @param name defines camera name
  104133. * @param alpha defines alpha angle (in radians)
  104134. * @param beta defines beta angle (in radians)
  104135. * @param radius defines radius
  104136. * @param target defines camera target
  104137. * @param interaxialDistance defines distance between each color axis
  104138. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104139. * @param scene defines the hosting scene
  104140. */
  104141. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104142. /**
  104143. * Gets camera class name
  104144. * @returns StereoscopicArcRotateCamera
  104145. */
  104146. getClassName(): string;
  104147. }
  104148. }
  104149. declare module BABYLON {
  104150. /**
  104151. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  104152. * @see http://doc.babylonjs.com/features/cameras
  104153. */
  104154. export class StereoscopicFreeCamera extends FreeCamera {
  104155. /**
  104156. * Creates a new StereoscopicFreeCamera
  104157. * @param name defines camera name
  104158. * @param position defines initial position
  104159. * @param interaxialDistance defines distance between each color axis
  104160. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104161. * @param scene defines the hosting scene
  104162. */
  104163. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104164. /**
  104165. * Gets camera class name
  104166. * @returns StereoscopicFreeCamera
  104167. */
  104168. getClassName(): string;
  104169. }
  104170. }
  104171. declare module BABYLON {
  104172. /**
  104173. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  104174. * @see http://doc.babylonjs.com/features/cameras
  104175. */
  104176. export class StereoscopicGamepadCamera extends GamepadCamera {
  104177. /**
  104178. * Creates a new StereoscopicGamepadCamera
  104179. * @param name defines camera name
  104180. * @param position defines initial position
  104181. * @param interaxialDistance defines distance between each color axis
  104182. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104183. * @param scene defines the hosting scene
  104184. */
  104185. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104186. /**
  104187. * Gets camera class name
  104188. * @returns StereoscopicGamepadCamera
  104189. */
  104190. getClassName(): string;
  104191. }
  104192. }
  104193. declare module BABYLON {
  104194. /**
  104195. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  104196. * @see http://doc.babylonjs.com/features/cameras
  104197. */
  104198. export class StereoscopicUniversalCamera extends UniversalCamera {
  104199. /**
  104200. * Creates a new StereoscopicUniversalCamera
  104201. * @param name defines camera name
  104202. * @param position defines initial position
  104203. * @param interaxialDistance defines distance between each color axis
  104204. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104205. * @param scene defines the hosting scene
  104206. */
  104207. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104208. /**
  104209. * Gets camera class name
  104210. * @returns StereoscopicUniversalCamera
  104211. */
  104212. getClassName(): string;
  104213. }
  104214. }
  104215. declare module BABYLON {
  104216. /**
  104217. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  104218. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104219. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104220. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104221. */
  104222. export class VirtualJoysticksCamera extends FreeCamera {
  104223. /**
  104224. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  104225. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104226. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104227. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104228. * @param name Define the name of the camera in the scene
  104229. * @param position Define the start position of the camera in the scene
  104230. * @param scene Define the scene the camera belongs to
  104231. */
  104232. constructor(name: string, position: Vector3, scene: Scene);
  104233. /**
  104234. * Gets the current object class name.
  104235. * @return the class name
  104236. */
  104237. getClassName(): string;
  104238. }
  104239. }
  104240. declare module BABYLON {
  104241. /**
  104242. * This represents all the required metrics to create a VR camera.
  104243. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  104244. */
  104245. export class VRCameraMetrics {
  104246. /**
  104247. * Define the horizontal resolution off the screen.
  104248. */
  104249. hResolution: number;
  104250. /**
  104251. * Define the vertical resolution off the screen.
  104252. */
  104253. vResolution: number;
  104254. /**
  104255. * Define the horizontal screen size.
  104256. */
  104257. hScreenSize: number;
  104258. /**
  104259. * Define the vertical screen size.
  104260. */
  104261. vScreenSize: number;
  104262. /**
  104263. * Define the vertical screen center position.
  104264. */
  104265. vScreenCenter: number;
  104266. /**
  104267. * Define the distance of the eyes to the screen.
  104268. */
  104269. eyeToScreenDistance: number;
  104270. /**
  104271. * Define the distance between both lenses
  104272. */
  104273. lensSeparationDistance: number;
  104274. /**
  104275. * Define the distance between both viewer's eyes.
  104276. */
  104277. interpupillaryDistance: number;
  104278. /**
  104279. * Define the distortion factor of the VR postprocess.
  104280. * Please, touch with care.
  104281. */
  104282. distortionK: number[];
  104283. /**
  104284. * Define the chromatic aberration correction factors for the VR post process.
  104285. */
  104286. chromaAbCorrection: number[];
  104287. /**
  104288. * Define the scale factor of the post process.
  104289. * The smaller the better but the slower.
  104290. */
  104291. postProcessScaleFactor: number;
  104292. /**
  104293. * Define an offset for the lens center.
  104294. */
  104295. lensCenterOffset: number;
  104296. /**
  104297. * Define if the current vr camera should compensate the distortion of the lense or not.
  104298. */
  104299. compensateDistortion: boolean;
  104300. /**
  104301. * Defines if multiview should be enabled when rendering (Default: false)
  104302. */
  104303. multiviewEnabled: boolean;
  104304. /**
  104305. * Gets the rendering aspect ratio based on the provided resolutions.
  104306. */
  104307. readonly aspectRatio: number;
  104308. /**
  104309. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  104310. */
  104311. readonly aspectRatioFov: number;
  104312. /**
  104313. * @hidden
  104314. */
  104315. readonly leftHMatrix: Matrix;
  104316. /**
  104317. * @hidden
  104318. */
  104319. readonly rightHMatrix: Matrix;
  104320. /**
  104321. * @hidden
  104322. */
  104323. readonly leftPreViewMatrix: Matrix;
  104324. /**
  104325. * @hidden
  104326. */
  104327. readonly rightPreViewMatrix: Matrix;
  104328. /**
  104329. * Get the default VRMetrics based on the most generic setup.
  104330. * @returns the default vr metrics
  104331. */
  104332. static GetDefault(): VRCameraMetrics;
  104333. }
  104334. }
  104335. declare module BABYLON {
  104336. /** @hidden */
  104337. export var vrDistortionCorrectionPixelShader: {
  104338. name: string;
  104339. shader: string;
  104340. };
  104341. }
  104342. declare module BABYLON {
  104343. /**
  104344. * VRDistortionCorrectionPostProcess used for mobile VR
  104345. */
  104346. export class VRDistortionCorrectionPostProcess extends PostProcess {
  104347. private _isRightEye;
  104348. private _distortionFactors;
  104349. private _postProcessScaleFactor;
  104350. private _lensCenterOffset;
  104351. private _scaleIn;
  104352. private _scaleFactor;
  104353. private _lensCenter;
  104354. /**
  104355. * Initializes the VRDistortionCorrectionPostProcess
  104356. * @param name The name of the effect.
  104357. * @param camera The camera to apply the render pass to.
  104358. * @param isRightEye If this is for the right eye distortion
  104359. * @param vrMetrics All the required metrics for the VR camera
  104360. */
  104361. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  104362. }
  104363. }
  104364. declare module BABYLON {
  104365. /**
  104366. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  104367. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104368. */
  104369. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  104370. /**
  104371. * Creates a new VRDeviceOrientationArcRotateCamera
  104372. * @param name defines camera name
  104373. * @param alpha defines the camera rotation along the logitudinal axis
  104374. * @param beta defines the camera rotation along the latitudinal axis
  104375. * @param radius defines the camera distance from its target
  104376. * @param target defines the camera target
  104377. * @param scene defines the scene the camera belongs to
  104378. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104379. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104380. */
  104381. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104382. /**
  104383. * Gets camera class name
  104384. * @returns VRDeviceOrientationArcRotateCamera
  104385. */
  104386. getClassName(): string;
  104387. }
  104388. }
  104389. declare module BABYLON {
  104390. /**
  104391. * Camera used to simulate VR rendering (based on FreeCamera)
  104392. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104393. */
  104394. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  104395. /**
  104396. * Creates a new VRDeviceOrientationFreeCamera
  104397. * @param name defines camera name
  104398. * @param position defines the start position of the camera
  104399. * @param scene defines the scene the camera belongs to
  104400. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104401. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104402. */
  104403. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104404. /**
  104405. * Gets camera class name
  104406. * @returns VRDeviceOrientationFreeCamera
  104407. */
  104408. getClassName(): string;
  104409. }
  104410. }
  104411. declare module BABYLON {
  104412. /**
  104413. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  104414. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104415. */
  104416. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  104417. /**
  104418. * Creates a new VRDeviceOrientationGamepadCamera
  104419. * @param name defines camera name
  104420. * @param position defines the start position of the camera
  104421. * @param scene defines the scene the camera belongs to
  104422. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104423. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104424. */
  104425. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104426. /**
  104427. * Gets camera class name
  104428. * @returns VRDeviceOrientationGamepadCamera
  104429. */
  104430. getClassName(): string;
  104431. }
  104432. }
  104433. declare module BABYLON {
  104434. /**
  104435. * Base class of materials working in push mode in babylon JS
  104436. * @hidden
  104437. */
  104438. export class PushMaterial extends Material {
  104439. protected _activeEffect: Effect;
  104440. protected _normalMatrix: Matrix;
  104441. /**
  104442. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  104443. * This means that the material can keep using a previous shader while a new one is being compiled.
  104444. * This is mostly used when shader parallel compilation is supported (true by default)
  104445. */
  104446. allowShaderHotSwapping: boolean;
  104447. constructor(name: string, scene: Scene);
  104448. getEffect(): Effect;
  104449. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104450. /**
  104451. * Binds the given world matrix to the active effect
  104452. *
  104453. * @param world the matrix to bind
  104454. */
  104455. bindOnlyWorldMatrix(world: Matrix): void;
  104456. /**
  104457. * Binds the given normal matrix to the active effect
  104458. *
  104459. * @param normalMatrix the matrix to bind
  104460. */
  104461. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  104462. bind(world: Matrix, mesh?: Mesh): void;
  104463. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  104464. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  104465. }
  104466. }
  104467. declare module BABYLON {
  104468. /**
  104469. * This groups all the flags used to control the materials channel.
  104470. */
  104471. export class MaterialFlags {
  104472. private static _DiffuseTextureEnabled;
  104473. /**
  104474. * Are diffuse textures enabled in the application.
  104475. */
  104476. static DiffuseTextureEnabled: boolean;
  104477. private static _AmbientTextureEnabled;
  104478. /**
  104479. * Are ambient textures enabled in the application.
  104480. */
  104481. static AmbientTextureEnabled: boolean;
  104482. private static _OpacityTextureEnabled;
  104483. /**
  104484. * Are opacity textures enabled in the application.
  104485. */
  104486. static OpacityTextureEnabled: boolean;
  104487. private static _ReflectionTextureEnabled;
  104488. /**
  104489. * Are reflection textures enabled in the application.
  104490. */
  104491. static ReflectionTextureEnabled: boolean;
  104492. private static _EmissiveTextureEnabled;
  104493. /**
  104494. * Are emissive textures enabled in the application.
  104495. */
  104496. static EmissiveTextureEnabled: boolean;
  104497. private static _SpecularTextureEnabled;
  104498. /**
  104499. * Are specular textures enabled in the application.
  104500. */
  104501. static SpecularTextureEnabled: boolean;
  104502. private static _BumpTextureEnabled;
  104503. /**
  104504. * Are bump textures enabled in the application.
  104505. */
  104506. static BumpTextureEnabled: boolean;
  104507. private static _LightmapTextureEnabled;
  104508. /**
  104509. * Are lightmap textures enabled in the application.
  104510. */
  104511. static LightmapTextureEnabled: boolean;
  104512. private static _RefractionTextureEnabled;
  104513. /**
  104514. * Are refraction textures enabled in the application.
  104515. */
  104516. static RefractionTextureEnabled: boolean;
  104517. private static _ColorGradingTextureEnabled;
  104518. /**
  104519. * Are color grading textures enabled in the application.
  104520. */
  104521. static ColorGradingTextureEnabled: boolean;
  104522. private static _FresnelEnabled;
  104523. /**
  104524. * Are fresnels enabled in the application.
  104525. */
  104526. static FresnelEnabled: boolean;
  104527. private static _ClearCoatTextureEnabled;
  104528. /**
  104529. * Are clear coat textures enabled in the application.
  104530. */
  104531. static ClearCoatTextureEnabled: boolean;
  104532. private static _ClearCoatBumpTextureEnabled;
  104533. /**
  104534. * Are clear coat bump textures enabled in the application.
  104535. */
  104536. static ClearCoatBumpTextureEnabled: boolean;
  104537. private static _ClearCoatTintTextureEnabled;
  104538. /**
  104539. * Are clear coat tint textures enabled in the application.
  104540. */
  104541. static ClearCoatTintTextureEnabled: boolean;
  104542. private static _SheenTextureEnabled;
  104543. /**
  104544. * Are sheen textures enabled in the application.
  104545. */
  104546. static SheenTextureEnabled: boolean;
  104547. private static _AnisotropicTextureEnabled;
  104548. /**
  104549. * Are anisotropic textures enabled in the application.
  104550. */
  104551. static AnisotropicTextureEnabled: boolean;
  104552. private static _ThicknessTextureEnabled;
  104553. /**
  104554. * Are thickness textures enabled in the application.
  104555. */
  104556. static ThicknessTextureEnabled: boolean;
  104557. }
  104558. }
  104559. declare module BABYLON {
  104560. /** @hidden */
  104561. export var defaultFragmentDeclaration: {
  104562. name: string;
  104563. shader: string;
  104564. };
  104565. }
  104566. declare module BABYLON {
  104567. /** @hidden */
  104568. export var defaultUboDeclaration: {
  104569. name: string;
  104570. shader: string;
  104571. };
  104572. }
  104573. declare module BABYLON {
  104574. /** @hidden */
  104575. export var lightFragmentDeclaration: {
  104576. name: string;
  104577. shader: string;
  104578. };
  104579. }
  104580. declare module BABYLON {
  104581. /** @hidden */
  104582. export var lightUboDeclaration: {
  104583. name: string;
  104584. shader: string;
  104585. };
  104586. }
  104587. declare module BABYLON {
  104588. /** @hidden */
  104589. export var lightsFragmentFunctions: {
  104590. name: string;
  104591. shader: string;
  104592. };
  104593. }
  104594. declare module BABYLON {
  104595. /** @hidden */
  104596. export var shadowsFragmentFunctions: {
  104597. name: string;
  104598. shader: string;
  104599. };
  104600. }
  104601. declare module BABYLON {
  104602. /** @hidden */
  104603. export var fresnelFunction: {
  104604. name: string;
  104605. shader: string;
  104606. };
  104607. }
  104608. declare module BABYLON {
  104609. /** @hidden */
  104610. export var reflectionFunction: {
  104611. name: string;
  104612. shader: string;
  104613. };
  104614. }
  104615. declare module BABYLON {
  104616. /** @hidden */
  104617. export var bumpFragmentFunctions: {
  104618. name: string;
  104619. shader: string;
  104620. };
  104621. }
  104622. declare module BABYLON {
  104623. /** @hidden */
  104624. export var logDepthDeclaration: {
  104625. name: string;
  104626. shader: string;
  104627. };
  104628. }
  104629. declare module BABYLON {
  104630. /** @hidden */
  104631. export var bumpFragment: {
  104632. name: string;
  104633. shader: string;
  104634. };
  104635. }
  104636. declare module BABYLON {
  104637. /** @hidden */
  104638. export var depthPrePass: {
  104639. name: string;
  104640. shader: string;
  104641. };
  104642. }
  104643. declare module BABYLON {
  104644. /** @hidden */
  104645. export var lightFragment: {
  104646. name: string;
  104647. shader: string;
  104648. };
  104649. }
  104650. declare module BABYLON {
  104651. /** @hidden */
  104652. export var logDepthFragment: {
  104653. name: string;
  104654. shader: string;
  104655. };
  104656. }
  104657. declare module BABYLON {
  104658. /** @hidden */
  104659. export var defaultPixelShader: {
  104660. name: string;
  104661. shader: string;
  104662. };
  104663. }
  104664. declare module BABYLON {
  104665. /** @hidden */
  104666. export var defaultVertexDeclaration: {
  104667. name: string;
  104668. shader: string;
  104669. };
  104670. }
  104671. declare module BABYLON {
  104672. /** @hidden */
  104673. export var bumpVertexDeclaration: {
  104674. name: string;
  104675. shader: string;
  104676. };
  104677. }
  104678. declare module BABYLON {
  104679. /** @hidden */
  104680. export var bumpVertex: {
  104681. name: string;
  104682. shader: string;
  104683. };
  104684. }
  104685. declare module BABYLON {
  104686. /** @hidden */
  104687. export var fogVertex: {
  104688. name: string;
  104689. shader: string;
  104690. };
  104691. }
  104692. declare module BABYLON {
  104693. /** @hidden */
  104694. export var shadowsVertex: {
  104695. name: string;
  104696. shader: string;
  104697. };
  104698. }
  104699. declare module BABYLON {
  104700. /** @hidden */
  104701. export var pointCloudVertex: {
  104702. name: string;
  104703. shader: string;
  104704. };
  104705. }
  104706. declare module BABYLON {
  104707. /** @hidden */
  104708. export var logDepthVertex: {
  104709. name: string;
  104710. shader: string;
  104711. };
  104712. }
  104713. declare module BABYLON {
  104714. /** @hidden */
  104715. export var defaultVertexShader: {
  104716. name: string;
  104717. shader: string;
  104718. };
  104719. }
  104720. declare module BABYLON {
  104721. /** @hidden */
  104722. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  104723. MAINUV1: boolean;
  104724. MAINUV2: boolean;
  104725. DIFFUSE: boolean;
  104726. DIFFUSEDIRECTUV: number;
  104727. AMBIENT: boolean;
  104728. AMBIENTDIRECTUV: number;
  104729. OPACITY: boolean;
  104730. OPACITYDIRECTUV: number;
  104731. OPACITYRGB: boolean;
  104732. REFLECTION: boolean;
  104733. EMISSIVE: boolean;
  104734. EMISSIVEDIRECTUV: number;
  104735. SPECULAR: boolean;
  104736. SPECULARDIRECTUV: number;
  104737. BUMP: boolean;
  104738. BUMPDIRECTUV: number;
  104739. PARALLAX: boolean;
  104740. PARALLAXOCCLUSION: boolean;
  104741. SPECULAROVERALPHA: boolean;
  104742. CLIPPLANE: boolean;
  104743. CLIPPLANE2: boolean;
  104744. CLIPPLANE3: boolean;
  104745. CLIPPLANE4: boolean;
  104746. ALPHATEST: boolean;
  104747. DEPTHPREPASS: boolean;
  104748. ALPHAFROMDIFFUSE: boolean;
  104749. POINTSIZE: boolean;
  104750. FOG: boolean;
  104751. SPECULARTERM: boolean;
  104752. DIFFUSEFRESNEL: boolean;
  104753. OPACITYFRESNEL: boolean;
  104754. REFLECTIONFRESNEL: boolean;
  104755. REFRACTIONFRESNEL: boolean;
  104756. EMISSIVEFRESNEL: boolean;
  104757. FRESNEL: boolean;
  104758. NORMAL: boolean;
  104759. UV1: boolean;
  104760. UV2: boolean;
  104761. VERTEXCOLOR: boolean;
  104762. VERTEXALPHA: boolean;
  104763. NUM_BONE_INFLUENCERS: number;
  104764. BonesPerMesh: number;
  104765. BONETEXTURE: boolean;
  104766. INSTANCES: boolean;
  104767. GLOSSINESS: boolean;
  104768. ROUGHNESS: boolean;
  104769. EMISSIVEASILLUMINATION: boolean;
  104770. LINKEMISSIVEWITHDIFFUSE: boolean;
  104771. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104772. LIGHTMAP: boolean;
  104773. LIGHTMAPDIRECTUV: number;
  104774. OBJECTSPACE_NORMALMAP: boolean;
  104775. USELIGHTMAPASSHADOWMAP: boolean;
  104776. REFLECTIONMAP_3D: boolean;
  104777. REFLECTIONMAP_SPHERICAL: boolean;
  104778. REFLECTIONMAP_PLANAR: boolean;
  104779. REFLECTIONMAP_CUBIC: boolean;
  104780. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104781. REFLECTIONMAP_PROJECTION: boolean;
  104782. REFLECTIONMAP_SKYBOX: boolean;
  104783. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104784. REFLECTIONMAP_EXPLICIT: boolean;
  104785. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104786. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104787. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104788. INVERTCUBICMAP: boolean;
  104789. LOGARITHMICDEPTH: boolean;
  104790. REFRACTION: boolean;
  104791. REFRACTIONMAP_3D: boolean;
  104792. REFLECTIONOVERALPHA: boolean;
  104793. TWOSIDEDLIGHTING: boolean;
  104794. SHADOWFLOAT: boolean;
  104795. MORPHTARGETS: boolean;
  104796. MORPHTARGETS_NORMAL: boolean;
  104797. MORPHTARGETS_TANGENT: boolean;
  104798. MORPHTARGETS_UV: boolean;
  104799. NUM_MORPH_INFLUENCERS: number;
  104800. NONUNIFORMSCALING: boolean;
  104801. PREMULTIPLYALPHA: boolean;
  104802. IMAGEPROCESSING: boolean;
  104803. VIGNETTE: boolean;
  104804. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104805. VIGNETTEBLENDMODEOPAQUE: boolean;
  104806. TONEMAPPING: boolean;
  104807. TONEMAPPING_ACES: boolean;
  104808. CONTRAST: boolean;
  104809. COLORCURVES: boolean;
  104810. COLORGRADING: boolean;
  104811. COLORGRADING3D: boolean;
  104812. SAMPLER3DGREENDEPTH: boolean;
  104813. SAMPLER3DBGRMAP: boolean;
  104814. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104815. MULTIVIEW: boolean;
  104816. /**
  104817. * If the reflection texture on this material is in linear color space
  104818. * @hidden
  104819. */
  104820. IS_REFLECTION_LINEAR: boolean;
  104821. /**
  104822. * If the refraction texture on this material is in linear color space
  104823. * @hidden
  104824. */
  104825. IS_REFRACTION_LINEAR: boolean;
  104826. EXPOSURE: boolean;
  104827. constructor();
  104828. setReflectionMode(modeToEnable: string): void;
  104829. }
  104830. /**
  104831. * This is the default material used in Babylon. It is the best trade off between quality
  104832. * and performances.
  104833. * @see http://doc.babylonjs.com/babylon101/materials
  104834. */
  104835. export class StandardMaterial extends PushMaterial {
  104836. private _diffuseTexture;
  104837. /**
  104838. * The basic texture of the material as viewed under a light.
  104839. */
  104840. diffuseTexture: Nullable<BaseTexture>;
  104841. private _ambientTexture;
  104842. /**
  104843. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104844. */
  104845. ambientTexture: Nullable<BaseTexture>;
  104846. private _opacityTexture;
  104847. /**
  104848. * Define the transparency of the material from a texture.
  104849. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104850. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104851. */
  104852. opacityTexture: Nullable<BaseTexture>;
  104853. private _reflectionTexture;
  104854. /**
  104855. * Define the texture used to display the reflection.
  104856. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104857. */
  104858. reflectionTexture: Nullable<BaseTexture>;
  104859. private _emissiveTexture;
  104860. /**
  104861. * Define texture of the material as if self lit.
  104862. * This will be mixed in the final result even in the absence of light.
  104863. */
  104864. emissiveTexture: Nullable<BaseTexture>;
  104865. private _specularTexture;
  104866. /**
  104867. * Define how the color and intensity of the highlight given by the light in the material.
  104868. */
  104869. specularTexture: Nullable<BaseTexture>;
  104870. private _bumpTexture;
  104871. /**
  104872. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104873. * 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.
  104874. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  104875. */
  104876. bumpTexture: Nullable<BaseTexture>;
  104877. private _lightmapTexture;
  104878. /**
  104879. * Complex lighting can be computationally expensive to compute at runtime.
  104880. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104881. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  104882. */
  104883. lightmapTexture: Nullable<BaseTexture>;
  104884. private _refractionTexture;
  104885. /**
  104886. * Define the texture used to display the refraction.
  104887. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104888. */
  104889. refractionTexture: Nullable<BaseTexture>;
  104890. /**
  104891. * The color of the material lit by the environmental background lighting.
  104892. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104893. */
  104894. ambientColor: Color3;
  104895. /**
  104896. * The basic color of the material as viewed under a light.
  104897. */
  104898. diffuseColor: Color3;
  104899. /**
  104900. * Define how the color and intensity of the highlight given by the light in the material.
  104901. */
  104902. specularColor: Color3;
  104903. /**
  104904. * Define the color of the material as if self lit.
  104905. * This will be mixed in the final result even in the absence of light.
  104906. */
  104907. emissiveColor: Color3;
  104908. /**
  104909. * Defines how sharp are the highlights in the material.
  104910. * The bigger the value the sharper giving a more glossy feeling to the result.
  104911. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104912. */
  104913. specularPower: number;
  104914. private _useAlphaFromDiffuseTexture;
  104915. /**
  104916. * Does the transparency come from the diffuse texture alpha channel.
  104917. */
  104918. useAlphaFromDiffuseTexture: boolean;
  104919. private _useEmissiveAsIllumination;
  104920. /**
  104921. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104922. */
  104923. useEmissiveAsIllumination: boolean;
  104924. private _linkEmissiveWithDiffuse;
  104925. /**
  104926. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104927. * the emissive level when the final color is close to one.
  104928. */
  104929. linkEmissiveWithDiffuse: boolean;
  104930. private _useSpecularOverAlpha;
  104931. /**
  104932. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104933. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104934. */
  104935. useSpecularOverAlpha: boolean;
  104936. private _useReflectionOverAlpha;
  104937. /**
  104938. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104939. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104940. */
  104941. useReflectionOverAlpha: boolean;
  104942. private _disableLighting;
  104943. /**
  104944. * Does lights from the scene impacts this material.
  104945. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104946. */
  104947. disableLighting: boolean;
  104948. private _useObjectSpaceNormalMap;
  104949. /**
  104950. * Allows using an object space normal map (instead of tangent space).
  104951. */
  104952. useObjectSpaceNormalMap: boolean;
  104953. private _useParallax;
  104954. /**
  104955. * Is parallax enabled or not.
  104956. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104957. */
  104958. useParallax: boolean;
  104959. private _useParallaxOcclusion;
  104960. /**
  104961. * Is parallax occlusion enabled or not.
  104962. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104963. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104964. */
  104965. useParallaxOcclusion: boolean;
  104966. /**
  104967. * 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.
  104968. */
  104969. parallaxScaleBias: number;
  104970. private _roughness;
  104971. /**
  104972. * Helps to define how blurry the reflections should appears in the material.
  104973. */
  104974. roughness: number;
  104975. /**
  104976. * In case of refraction, define the value of the index of refraction.
  104977. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104978. */
  104979. indexOfRefraction: number;
  104980. /**
  104981. * Invert the refraction texture alongside the y axis.
  104982. * It can be useful with procedural textures or probe for instance.
  104983. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104984. */
  104985. invertRefractionY: boolean;
  104986. /**
  104987. * Defines the alpha limits in alpha test mode.
  104988. */
  104989. alphaCutOff: number;
  104990. private _useLightmapAsShadowmap;
  104991. /**
  104992. * In case of light mapping, define whether the map contains light or shadow informations.
  104993. */
  104994. useLightmapAsShadowmap: boolean;
  104995. private _diffuseFresnelParameters;
  104996. /**
  104997. * Define the diffuse fresnel parameters of the material.
  104998. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104999. */
  105000. diffuseFresnelParameters: FresnelParameters;
  105001. private _opacityFresnelParameters;
  105002. /**
  105003. * Define the opacity fresnel parameters of the material.
  105004. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105005. */
  105006. opacityFresnelParameters: FresnelParameters;
  105007. private _reflectionFresnelParameters;
  105008. /**
  105009. * Define the reflection fresnel parameters of the material.
  105010. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105011. */
  105012. reflectionFresnelParameters: FresnelParameters;
  105013. private _refractionFresnelParameters;
  105014. /**
  105015. * Define the refraction fresnel parameters of the material.
  105016. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105017. */
  105018. refractionFresnelParameters: FresnelParameters;
  105019. private _emissiveFresnelParameters;
  105020. /**
  105021. * Define the emissive fresnel parameters of the material.
  105022. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105023. */
  105024. emissiveFresnelParameters: FresnelParameters;
  105025. private _useReflectionFresnelFromSpecular;
  105026. /**
  105027. * If true automatically deducts the fresnels values from the material specularity.
  105028. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105029. */
  105030. useReflectionFresnelFromSpecular: boolean;
  105031. private _useGlossinessFromSpecularMapAlpha;
  105032. /**
  105033. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105034. */
  105035. useGlossinessFromSpecularMapAlpha: boolean;
  105036. private _maxSimultaneousLights;
  105037. /**
  105038. * Defines the maximum number of lights that can be used in the material
  105039. */
  105040. maxSimultaneousLights: number;
  105041. private _invertNormalMapX;
  105042. /**
  105043. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105044. */
  105045. invertNormalMapX: boolean;
  105046. private _invertNormalMapY;
  105047. /**
  105048. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105049. */
  105050. invertNormalMapY: boolean;
  105051. private _twoSidedLighting;
  105052. /**
  105053. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105054. */
  105055. twoSidedLighting: boolean;
  105056. /**
  105057. * Default configuration related to image processing available in the standard Material.
  105058. */
  105059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105060. /**
  105061. * Gets the image processing configuration used either in this material.
  105062. */
  105063. /**
  105064. * Sets the Default image processing configuration used either in the this material.
  105065. *
  105066. * If sets to null, the scene one is in use.
  105067. */
  105068. imageProcessingConfiguration: ImageProcessingConfiguration;
  105069. /**
  105070. * Keep track of the image processing observer to allow dispose and replace.
  105071. */
  105072. private _imageProcessingObserver;
  105073. /**
  105074. * Attaches a new image processing configuration to the Standard Material.
  105075. * @param configuration
  105076. */
  105077. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105078. /**
  105079. * Gets wether the color curves effect is enabled.
  105080. */
  105081. /**
  105082. * Sets wether the color curves effect is enabled.
  105083. */
  105084. cameraColorCurvesEnabled: boolean;
  105085. /**
  105086. * Gets wether the color grading effect is enabled.
  105087. */
  105088. /**
  105089. * Gets wether the color grading effect is enabled.
  105090. */
  105091. cameraColorGradingEnabled: boolean;
  105092. /**
  105093. * Gets wether tonemapping is enabled or not.
  105094. */
  105095. /**
  105096. * Sets wether tonemapping is enabled or not
  105097. */
  105098. cameraToneMappingEnabled: boolean;
  105099. /**
  105100. * The camera exposure used on this material.
  105101. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105102. * This corresponds to a photographic exposure.
  105103. */
  105104. /**
  105105. * The camera exposure used on this material.
  105106. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105107. * This corresponds to a photographic exposure.
  105108. */
  105109. cameraExposure: number;
  105110. /**
  105111. * Gets The camera contrast used on this material.
  105112. */
  105113. /**
  105114. * Sets The camera contrast used on this material.
  105115. */
  105116. cameraContrast: number;
  105117. /**
  105118. * Gets the Color Grading 2D Lookup Texture.
  105119. */
  105120. /**
  105121. * Sets the Color Grading 2D Lookup Texture.
  105122. */
  105123. cameraColorGradingTexture: Nullable<BaseTexture>;
  105124. /**
  105125. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105126. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105127. * 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;
  105128. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105129. */
  105130. /**
  105131. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105132. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105133. * 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;
  105134. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105135. */
  105136. cameraColorCurves: Nullable<ColorCurves>;
  105137. /**
  105138. * Custom callback helping to override the default shader used in the material.
  105139. */
  105140. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  105141. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105142. protected _worldViewProjectionMatrix: Matrix;
  105143. protected _globalAmbientColor: Color3;
  105144. protected _useLogarithmicDepth: boolean;
  105145. protected _rebuildInParallel: boolean;
  105146. /**
  105147. * Instantiates a new standard material.
  105148. * This is the default material used in Babylon. It is the best trade off between quality
  105149. * and performances.
  105150. * @see http://doc.babylonjs.com/babylon101/materials
  105151. * @param name Define the name of the material in the scene
  105152. * @param scene Define the scene the material belong to
  105153. */
  105154. constructor(name: string, scene: Scene);
  105155. /**
  105156. * Gets a boolean indicating that current material needs to register RTT
  105157. */
  105158. readonly hasRenderTargetTextures: boolean;
  105159. /**
  105160. * Gets the current class name of the material e.g. "StandardMaterial"
  105161. * Mainly use in serialization.
  105162. * @returns the class name
  105163. */
  105164. getClassName(): string;
  105165. /**
  105166. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105167. * You can try switching to logarithmic depth.
  105168. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105169. */
  105170. useLogarithmicDepth: boolean;
  105171. /**
  105172. * Specifies if the material will require alpha blending
  105173. * @returns a boolean specifying if alpha blending is needed
  105174. */
  105175. needAlphaBlending(): boolean;
  105176. /**
  105177. * Specifies if this material should be rendered in alpha test mode
  105178. * @returns a boolean specifying if an alpha test is needed.
  105179. */
  105180. needAlphaTesting(): boolean;
  105181. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105182. /**
  105183. * Get the texture used for alpha test purpose.
  105184. * @returns the diffuse texture in case of the standard material.
  105185. */
  105186. getAlphaTestTexture(): Nullable<BaseTexture>;
  105187. /**
  105188. * Get if the submesh is ready to be used and all its information available.
  105189. * Child classes can use it to update shaders
  105190. * @param mesh defines the mesh to check
  105191. * @param subMesh defines which submesh to check
  105192. * @param useInstances specifies that instances should be used
  105193. * @returns a boolean indicating that the submesh is ready or not
  105194. */
  105195. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105196. /**
  105197. * Builds the material UBO layouts.
  105198. * Used internally during the effect preparation.
  105199. */
  105200. buildUniformLayout(): void;
  105201. /**
  105202. * Unbinds the material from the mesh
  105203. */
  105204. unbind(): void;
  105205. /**
  105206. * Binds the submesh to this material by preparing the effect and shader to draw
  105207. * @param world defines the world transformation matrix
  105208. * @param mesh defines the mesh containing the submesh
  105209. * @param subMesh defines the submesh to bind the material to
  105210. */
  105211. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105212. /**
  105213. * Get the list of animatables in the material.
  105214. * @returns the list of animatables object used in the material
  105215. */
  105216. getAnimatables(): IAnimatable[];
  105217. /**
  105218. * Gets the active textures from the material
  105219. * @returns an array of textures
  105220. */
  105221. getActiveTextures(): BaseTexture[];
  105222. /**
  105223. * Specifies if the material uses a texture
  105224. * @param texture defines the texture to check against the material
  105225. * @returns a boolean specifying if the material uses the texture
  105226. */
  105227. hasTexture(texture: BaseTexture): boolean;
  105228. /**
  105229. * Disposes the material
  105230. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105231. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105232. */
  105233. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105234. /**
  105235. * Makes a duplicate of the material, and gives it a new name
  105236. * @param name defines the new name for the duplicated material
  105237. * @returns the cloned material
  105238. */
  105239. clone(name: string): StandardMaterial;
  105240. /**
  105241. * Serializes this material in a JSON representation
  105242. * @returns the serialized material object
  105243. */
  105244. serialize(): any;
  105245. /**
  105246. * Creates a standard material from parsed material data
  105247. * @param source defines the JSON representation of the material
  105248. * @param scene defines the hosting scene
  105249. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105250. * @returns a new standard material
  105251. */
  105252. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105253. /**
  105254. * Are diffuse textures enabled in the application.
  105255. */
  105256. static DiffuseTextureEnabled: boolean;
  105257. /**
  105258. * Are ambient textures enabled in the application.
  105259. */
  105260. static AmbientTextureEnabled: boolean;
  105261. /**
  105262. * Are opacity textures enabled in the application.
  105263. */
  105264. static OpacityTextureEnabled: boolean;
  105265. /**
  105266. * Are reflection textures enabled in the application.
  105267. */
  105268. static ReflectionTextureEnabled: boolean;
  105269. /**
  105270. * Are emissive textures enabled in the application.
  105271. */
  105272. static EmissiveTextureEnabled: boolean;
  105273. /**
  105274. * Are specular textures enabled in the application.
  105275. */
  105276. static SpecularTextureEnabled: boolean;
  105277. /**
  105278. * Are bump textures enabled in the application.
  105279. */
  105280. static BumpTextureEnabled: boolean;
  105281. /**
  105282. * Are lightmap textures enabled in the application.
  105283. */
  105284. static LightmapTextureEnabled: boolean;
  105285. /**
  105286. * Are refraction textures enabled in the application.
  105287. */
  105288. static RefractionTextureEnabled: boolean;
  105289. /**
  105290. * Are color grading textures enabled in the application.
  105291. */
  105292. static ColorGradingTextureEnabled: boolean;
  105293. /**
  105294. * Are fresnels enabled in the application.
  105295. */
  105296. static FresnelEnabled: boolean;
  105297. }
  105298. }
  105299. declare module BABYLON {
  105300. /**
  105301. * A class extending Texture allowing drawing on a texture
  105302. * @see http://doc.babylonjs.com/how_to/dynamictexture
  105303. */
  105304. export class DynamicTexture extends Texture {
  105305. private _generateMipMaps;
  105306. private _canvas;
  105307. private _context;
  105308. private _engine;
  105309. /**
  105310. * Creates a DynamicTexture
  105311. * @param name defines the name of the texture
  105312. * @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
  105313. * @param scene defines the scene where you want the texture
  105314. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  105315. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  105316. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  105317. */
  105318. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  105319. /**
  105320. * Get the current class name of the texture useful for serialization or dynamic coding.
  105321. * @returns "DynamicTexture"
  105322. */
  105323. getClassName(): string;
  105324. /**
  105325. * Gets the current state of canRescale
  105326. */
  105327. readonly canRescale: boolean;
  105328. private _recreate;
  105329. /**
  105330. * Scales the texture
  105331. * @param ratio the scale factor to apply to both width and height
  105332. */
  105333. scale(ratio: number): void;
  105334. /**
  105335. * Resizes the texture
  105336. * @param width the new width
  105337. * @param height the new height
  105338. */
  105339. scaleTo(width: number, height: number): void;
  105340. /**
  105341. * Gets the context of the canvas used by the texture
  105342. * @returns the canvas context of the dynamic texture
  105343. */
  105344. getContext(): CanvasRenderingContext2D;
  105345. /**
  105346. * Clears the texture
  105347. */
  105348. clear(): void;
  105349. /**
  105350. * Updates the texture
  105351. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105352. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  105353. */
  105354. update(invertY?: boolean, premulAlpha?: boolean): void;
  105355. /**
  105356. * Draws text onto the texture
  105357. * @param text defines the text to be drawn
  105358. * @param x defines the placement of the text from the left
  105359. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  105360. * @param font defines the font to be used with font-style, font-size, font-name
  105361. * @param color defines the color used for the text
  105362. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  105363. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105364. * @param update defines whether texture is immediately update (default is true)
  105365. */
  105366. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  105367. /**
  105368. * Clones the texture
  105369. * @returns the clone of the texture.
  105370. */
  105371. clone(): DynamicTexture;
  105372. /**
  105373. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  105374. * @returns a serialized dynamic texture object
  105375. */
  105376. serialize(): any;
  105377. /** @hidden */
  105378. _rebuild(): void;
  105379. }
  105380. }
  105381. declare module BABYLON {
  105382. /** @hidden */
  105383. export var imageProcessingPixelShader: {
  105384. name: string;
  105385. shader: string;
  105386. };
  105387. }
  105388. declare module BABYLON {
  105389. /**
  105390. * ImageProcessingPostProcess
  105391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  105392. */
  105393. export class ImageProcessingPostProcess extends PostProcess {
  105394. /**
  105395. * Default configuration related to image processing available in the PBR Material.
  105396. */
  105397. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105398. /**
  105399. * Gets the image processing configuration used either in this material.
  105400. */
  105401. /**
  105402. * Sets the Default image processing configuration used either in the this material.
  105403. *
  105404. * If sets to null, the scene one is in use.
  105405. */
  105406. imageProcessingConfiguration: ImageProcessingConfiguration;
  105407. /**
  105408. * Keep track of the image processing observer to allow dispose and replace.
  105409. */
  105410. private _imageProcessingObserver;
  105411. /**
  105412. * Attaches a new image processing configuration to the PBR Material.
  105413. * @param configuration
  105414. */
  105415. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  105416. /**
  105417. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105418. */
  105419. /**
  105420. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105421. */
  105422. colorCurves: Nullable<ColorCurves>;
  105423. /**
  105424. * Gets wether the color curves effect is enabled.
  105425. */
  105426. /**
  105427. * Sets wether the color curves effect is enabled.
  105428. */
  105429. colorCurvesEnabled: boolean;
  105430. /**
  105431. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105432. */
  105433. /**
  105434. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105435. */
  105436. colorGradingTexture: Nullable<BaseTexture>;
  105437. /**
  105438. * Gets wether the color grading effect is enabled.
  105439. */
  105440. /**
  105441. * Gets wether the color grading effect is enabled.
  105442. */
  105443. colorGradingEnabled: boolean;
  105444. /**
  105445. * Gets exposure used in the effect.
  105446. */
  105447. /**
  105448. * Sets exposure used in the effect.
  105449. */
  105450. exposure: number;
  105451. /**
  105452. * Gets wether tonemapping is enabled or not.
  105453. */
  105454. /**
  105455. * Sets wether tonemapping is enabled or not
  105456. */
  105457. toneMappingEnabled: boolean;
  105458. /**
  105459. * Gets the type of tone mapping effect.
  105460. */
  105461. /**
  105462. * Sets the type of tone mapping effect.
  105463. */
  105464. toneMappingType: number;
  105465. /**
  105466. * Gets contrast used in the effect.
  105467. */
  105468. /**
  105469. * Sets contrast used in the effect.
  105470. */
  105471. contrast: number;
  105472. /**
  105473. * Gets Vignette stretch size.
  105474. */
  105475. /**
  105476. * Sets Vignette stretch size.
  105477. */
  105478. vignetteStretch: number;
  105479. /**
  105480. * Gets Vignette centre X Offset.
  105481. */
  105482. /**
  105483. * Sets Vignette centre X Offset.
  105484. */
  105485. vignetteCentreX: number;
  105486. /**
  105487. * Gets Vignette centre Y Offset.
  105488. */
  105489. /**
  105490. * Sets Vignette centre Y Offset.
  105491. */
  105492. vignetteCentreY: number;
  105493. /**
  105494. * Gets Vignette weight or intensity of the vignette effect.
  105495. */
  105496. /**
  105497. * Sets Vignette weight or intensity of the vignette effect.
  105498. */
  105499. vignetteWeight: number;
  105500. /**
  105501. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105502. * if vignetteEnabled is set to true.
  105503. */
  105504. /**
  105505. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105506. * if vignetteEnabled is set to true.
  105507. */
  105508. vignetteColor: Color4;
  105509. /**
  105510. * Gets Camera field of view used by the Vignette effect.
  105511. */
  105512. /**
  105513. * Sets Camera field of view used by the Vignette effect.
  105514. */
  105515. vignetteCameraFov: number;
  105516. /**
  105517. * Gets the vignette blend mode allowing different kind of effect.
  105518. */
  105519. /**
  105520. * Sets the vignette blend mode allowing different kind of effect.
  105521. */
  105522. vignetteBlendMode: number;
  105523. /**
  105524. * Gets wether the vignette effect is enabled.
  105525. */
  105526. /**
  105527. * Sets wether the vignette effect is enabled.
  105528. */
  105529. vignetteEnabled: boolean;
  105530. private _fromLinearSpace;
  105531. /**
  105532. * Gets wether the input of the processing is in Gamma or Linear Space.
  105533. */
  105534. /**
  105535. * Sets wether the input of the processing is in Gamma or Linear Space.
  105536. */
  105537. fromLinearSpace: boolean;
  105538. /**
  105539. * Defines cache preventing GC.
  105540. */
  105541. private _defines;
  105542. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  105543. /**
  105544. * "ImageProcessingPostProcess"
  105545. * @returns "ImageProcessingPostProcess"
  105546. */
  105547. getClassName(): string;
  105548. protected _updateParameters(): void;
  105549. dispose(camera?: Camera): void;
  105550. }
  105551. }
  105552. declare module BABYLON {
  105553. /**
  105554. * Class containing static functions to help procedurally build meshes
  105555. */
  105556. export class GroundBuilder {
  105557. /**
  105558. * Creates a ground mesh
  105559. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105560. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105562. * @param name defines the name of the mesh
  105563. * @param options defines the options used to create the mesh
  105564. * @param scene defines the hosting scene
  105565. * @returns the ground mesh
  105566. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105567. */
  105568. static CreateGround(name: string, options: {
  105569. width?: number;
  105570. height?: number;
  105571. subdivisions?: number;
  105572. subdivisionsX?: number;
  105573. subdivisionsY?: number;
  105574. updatable?: boolean;
  105575. }, scene: any): Mesh;
  105576. /**
  105577. * Creates a tiled ground mesh
  105578. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105579. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105580. * * 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
  105581. * * 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
  105582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105583. * @param name defines the name of the mesh
  105584. * @param options defines the options used to create the mesh
  105585. * @param scene defines the hosting scene
  105586. * @returns the tiled ground mesh
  105587. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105588. */
  105589. static CreateTiledGround(name: string, options: {
  105590. xmin: number;
  105591. zmin: number;
  105592. xmax: number;
  105593. zmax: number;
  105594. subdivisions?: {
  105595. w: number;
  105596. h: number;
  105597. };
  105598. precision?: {
  105599. w: number;
  105600. h: number;
  105601. };
  105602. updatable?: boolean;
  105603. }, scene?: Nullable<Scene>): Mesh;
  105604. /**
  105605. * Creates a ground mesh from a height map
  105606. * * The parameter `url` sets the URL of the height map image resource.
  105607. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105608. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105609. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105610. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105611. * * 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.
  105612. * * 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).
  105613. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105615. * @param name defines the name of the mesh
  105616. * @param url defines the url to the height map
  105617. * @param options defines the options used to create the mesh
  105618. * @param scene defines the hosting scene
  105619. * @returns the ground mesh
  105620. * @see https://doc.babylonjs.com/babylon101/height_map
  105621. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105622. */
  105623. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105624. width?: number;
  105625. height?: number;
  105626. subdivisions?: number;
  105627. minHeight?: number;
  105628. maxHeight?: number;
  105629. colorFilter?: Color3;
  105630. alphaFilter?: number;
  105631. updatable?: boolean;
  105632. onReady?: (mesh: GroundMesh) => void;
  105633. }, scene?: Nullable<Scene>): GroundMesh;
  105634. }
  105635. }
  105636. declare module BABYLON {
  105637. /**
  105638. * Class containing static functions to help procedurally build meshes
  105639. */
  105640. export class TorusBuilder {
  105641. /**
  105642. * Creates a torus mesh
  105643. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105644. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105645. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105649. * @param name defines the name of the mesh
  105650. * @param options defines the options used to create the mesh
  105651. * @param scene defines the hosting scene
  105652. * @returns the torus mesh
  105653. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105654. */
  105655. static CreateTorus(name: string, options: {
  105656. diameter?: number;
  105657. thickness?: number;
  105658. tessellation?: number;
  105659. updatable?: boolean;
  105660. sideOrientation?: number;
  105661. frontUVs?: Vector4;
  105662. backUVs?: Vector4;
  105663. }, scene: any): Mesh;
  105664. }
  105665. }
  105666. declare module BABYLON {
  105667. /**
  105668. * Class containing static functions to help procedurally build meshes
  105669. */
  105670. export class CylinderBuilder {
  105671. /**
  105672. * Creates a cylinder or a cone mesh
  105673. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105674. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105675. * * 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.
  105676. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105677. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105678. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105679. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105680. * * 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).
  105681. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105682. * * 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).
  105683. * * 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
  105684. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105685. * * 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
  105686. * * 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.
  105687. * * If `enclose` is false, a ring surface is one element.
  105688. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105689. * * 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
  105690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105693. * @param name defines the name of the mesh
  105694. * @param options defines the options used to create the mesh
  105695. * @param scene defines the hosting scene
  105696. * @returns the cylinder mesh
  105697. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105698. */
  105699. static CreateCylinder(name: string, options: {
  105700. height?: number;
  105701. diameterTop?: number;
  105702. diameterBottom?: number;
  105703. diameter?: number;
  105704. tessellation?: number;
  105705. subdivisions?: number;
  105706. arc?: number;
  105707. faceColors?: Color4[];
  105708. faceUV?: Vector4[];
  105709. updatable?: boolean;
  105710. hasRings?: boolean;
  105711. enclose?: boolean;
  105712. cap?: number;
  105713. sideOrientation?: number;
  105714. frontUVs?: Vector4;
  105715. backUVs?: Vector4;
  105716. }, scene: any): Mesh;
  105717. }
  105718. }
  105719. declare module BABYLON {
  105720. /**
  105721. * Options to modify the vr teleportation behavior.
  105722. */
  105723. export interface VRTeleportationOptions {
  105724. /**
  105725. * The name of the mesh which should be used as the teleportation floor. (default: null)
  105726. */
  105727. floorMeshName?: string;
  105728. /**
  105729. * A list of meshes to be used as the teleportation floor. (default: empty)
  105730. */
  105731. floorMeshes?: Mesh[];
  105732. }
  105733. /**
  105734. * Options to modify the vr experience helper's behavior.
  105735. */
  105736. export interface VRExperienceHelperOptions extends WebVROptions {
  105737. /**
  105738. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  105739. */
  105740. createDeviceOrientationCamera?: boolean;
  105741. /**
  105742. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  105743. */
  105744. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  105745. /**
  105746. * Uses the main button on the controller to toggle the laser casted. (default: true)
  105747. */
  105748. laserToggle?: boolean;
  105749. /**
  105750. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  105751. */
  105752. floorMeshes?: Mesh[];
  105753. /**
  105754. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  105755. */
  105756. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  105757. }
  105758. /**
  105759. * Event containing information after VR has been entered
  105760. */
  105761. export class OnAfterEnteringVRObservableEvent {
  105762. /**
  105763. * If entering vr was successful
  105764. */
  105765. success: boolean;
  105766. }
  105767. /**
  105768. * Helps to quickly add VR support to an existing scene.
  105769. * See http://doc.babylonjs.com/how_to/webvr_helper
  105770. */
  105771. export class VRExperienceHelper {
  105772. /** Options to modify the vr experience helper's behavior. */
  105773. webVROptions: VRExperienceHelperOptions;
  105774. private _scene;
  105775. private _position;
  105776. private _btnVR;
  105777. private _btnVRDisplayed;
  105778. private _webVRsupported;
  105779. private _webVRready;
  105780. private _webVRrequesting;
  105781. private _webVRpresenting;
  105782. private _hasEnteredVR;
  105783. private _fullscreenVRpresenting;
  105784. private _canvas;
  105785. private _webVRCamera;
  105786. private _vrDeviceOrientationCamera;
  105787. private _deviceOrientationCamera;
  105788. private _existingCamera;
  105789. private _onKeyDown;
  105790. private _onVrDisplayPresentChange;
  105791. private _onVRDisplayChanged;
  105792. private _onVRRequestPresentStart;
  105793. private _onVRRequestPresentComplete;
  105794. /**
  105795. * 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)
  105796. */
  105797. enableGazeEvenWhenNoPointerLock: boolean;
  105798. /**
  105799. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  105800. */
  105801. exitVROnDoubleTap: boolean;
  105802. /**
  105803. * Observable raised right before entering VR.
  105804. */
  105805. onEnteringVRObservable: Observable<VRExperienceHelper>;
  105806. /**
  105807. * Observable raised when entering VR has completed.
  105808. */
  105809. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  105810. /**
  105811. * Observable raised when exiting VR.
  105812. */
  105813. onExitingVRObservable: Observable<VRExperienceHelper>;
  105814. /**
  105815. * Observable raised when controller mesh is loaded.
  105816. */
  105817. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105818. /** Return this.onEnteringVRObservable
  105819. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105820. */
  105821. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105822. /** Return this.onExitingVRObservable
  105823. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105824. */
  105825. readonly onExitingVR: Observable<VRExperienceHelper>;
  105826. /** Return this.onControllerMeshLoadedObservable
  105827. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105828. */
  105829. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105830. private _rayLength;
  105831. private _useCustomVRButton;
  105832. private _teleportationRequested;
  105833. private _teleportActive;
  105834. private _floorMeshName;
  105835. private _floorMeshesCollection;
  105836. private _rotationAllowed;
  105837. private _teleportBackwardsVector;
  105838. private _teleportationTarget;
  105839. private _isDefaultTeleportationTarget;
  105840. private _postProcessMove;
  105841. private _teleportationFillColor;
  105842. private _teleportationBorderColor;
  105843. private _rotationAngle;
  105844. private _haloCenter;
  105845. private _cameraGazer;
  105846. private _padSensibilityUp;
  105847. private _padSensibilityDown;
  105848. private _leftController;
  105849. private _rightController;
  105850. /**
  105851. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  105852. */
  105853. onNewMeshSelected: Observable<AbstractMesh>;
  105854. /**
  105855. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  105856. * This observable will provide the mesh and the controller used to select the mesh
  105857. */
  105858. onMeshSelectedWithController: Observable<{
  105859. mesh: AbstractMesh;
  105860. controller: WebVRController;
  105861. }>;
  105862. /**
  105863. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  105864. */
  105865. onNewMeshPicked: Observable<PickingInfo>;
  105866. private _circleEase;
  105867. /**
  105868. * Observable raised before camera teleportation
  105869. */
  105870. onBeforeCameraTeleport: Observable<Vector3>;
  105871. /**
  105872. * Observable raised after camera teleportation
  105873. */
  105874. onAfterCameraTeleport: Observable<Vector3>;
  105875. /**
  105876. * Observable raised when current selected mesh gets unselected
  105877. */
  105878. onSelectedMeshUnselected: Observable<AbstractMesh>;
  105879. private _raySelectionPredicate;
  105880. /**
  105881. * To be optionaly changed by user to define custom ray selection
  105882. */
  105883. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  105884. /**
  105885. * To be optionaly changed by user to define custom selection logic (after ray selection)
  105886. */
  105887. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105888. /**
  105889. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  105890. */
  105891. teleportationEnabled: boolean;
  105892. private _defaultHeight;
  105893. private _teleportationInitialized;
  105894. private _interactionsEnabled;
  105895. private _interactionsRequested;
  105896. private _displayGaze;
  105897. private _displayLaserPointer;
  105898. /**
  105899. * The mesh used to display where the user is going to teleport.
  105900. */
  105901. /**
  105902. * Sets the mesh to be used to display where the user is going to teleport.
  105903. */
  105904. teleportationTarget: Mesh;
  105905. /**
  105906. * 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
  105907. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  105908. * See http://doc.babylonjs.com/resources/baking_transformations
  105909. */
  105910. gazeTrackerMesh: Mesh;
  105911. /**
  105912. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  105913. */
  105914. updateGazeTrackerScale: boolean;
  105915. /**
  105916. * If the gaze trackers color should be updated when selecting meshes
  105917. */
  105918. updateGazeTrackerColor: boolean;
  105919. /**
  105920. * The gaze tracking mesh corresponding to the left controller
  105921. */
  105922. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  105923. /**
  105924. * The gaze tracking mesh corresponding to the right controller
  105925. */
  105926. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  105927. /**
  105928. * If the ray of the gaze should be displayed.
  105929. */
  105930. /**
  105931. * Sets if the ray of the gaze should be displayed.
  105932. */
  105933. displayGaze: boolean;
  105934. /**
  105935. * If the ray of the LaserPointer should be displayed.
  105936. */
  105937. /**
  105938. * Sets if the ray of the LaserPointer should be displayed.
  105939. */
  105940. displayLaserPointer: boolean;
  105941. /**
  105942. * The deviceOrientationCamera used as the camera when not in VR.
  105943. */
  105944. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  105945. /**
  105946. * Based on the current WebVR support, returns the current VR camera used.
  105947. */
  105948. readonly currentVRCamera: Nullable<Camera>;
  105949. /**
  105950. * The webVRCamera which is used when in VR.
  105951. */
  105952. readonly webVRCamera: WebVRFreeCamera;
  105953. /**
  105954. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  105955. */
  105956. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  105957. /**
  105958. * The html button that is used to trigger entering into VR.
  105959. */
  105960. readonly vrButton: Nullable<HTMLButtonElement>;
  105961. private readonly _teleportationRequestInitiated;
  105962. /**
  105963. * Defines wether or not Pointer lock should be requested when switching to
  105964. * full screen.
  105965. */
  105966. requestPointerLockOnFullScreen: boolean;
  105967. /**
  105968. * Instantiates a VRExperienceHelper.
  105969. * Helps to quickly add VR support to an existing scene.
  105970. * @param scene The scene the VRExperienceHelper belongs to.
  105971. * @param webVROptions Options to modify the vr experience helper's behavior.
  105972. */
  105973. constructor(scene: Scene,
  105974. /** Options to modify the vr experience helper's behavior. */
  105975. webVROptions?: VRExperienceHelperOptions);
  105976. private _onDefaultMeshLoaded;
  105977. private _onResize;
  105978. private _onFullscreenChange;
  105979. /**
  105980. * Gets a value indicating if we are currently in VR mode.
  105981. */
  105982. readonly isInVRMode: boolean;
  105983. private onVrDisplayPresentChange;
  105984. private onVRDisplayChanged;
  105985. private moveButtonToBottomRight;
  105986. private displayVRButton;
  105987. private updateButtonVisibility;
  105988. private _cachedAngularSensibility;
  105989. /**
  105990. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  105991. * Otherwise, will use the fullscreen API.
  105992. */
  105993. enterVR(): void;
  105994. /**
  105995. * Attempt to exit VR, or fullscreen.
  105996. */
  105997. exitVR(): void;
  105998. /**
  105999. * The position of the vr experience helper.
  106000. */
  106001. /**
  106002. * Sets the position of the vr experience helper.
  106003. */
  106004. position: Vector3;
  106005. /**
  106006. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106007. */
  106008. enableInteractions(): void;
  106009. private readonly _noControllerIsActive;
  106010. private beforeRender;
  106011. private _isTeleportationFloor;
  106012. /**
  106013. * Adds a floor mesh to be used for teleportation.
  106014. * @param floorMesh the mesh to be used for teleportation.
  106015. */
  106016. addFloorMesh(floorMesh: Mesh): void;
  106017. /**
  106018. * Removes a floor mesh from being used for teleportation.
  106019. * @param floorMesh the mesh to be removed.
  106020. */
  106021. removeFloorMesh(floorMesh: Mesh): void;
  106022. /**
  106023. * Enables interactions and teleportation using the VR controllers and gaze.
  106024. * @param vrTeleportationOptions options to modify teleportation behavior.
  106025. */
  106026. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106027. private _onNewGamepadConnected;
  106028. private _tryEnableInteractionOnController;
  106029. private _onNewGamepadDisconnected;
  106030. private _enableInteractionOnController;
  106031. private _checkTeleportWithRay;
  106032. private _checkRotate;
  106033. private _checkTeleportBackwards;
  106034. private _enableTeleportationOnController;
  106035. private _createTeleportationCircles;
  106036. private _displayTeleportationTarget;
  106037. private _hideTeleportationTarget;
  106038. private _rotateCamera;
  106039. private _moveTeleportationSelectorTo;
  106040. private _workingVector;
  106041. private _workingQuaternion;
  106042. private _workingMatrix;
  106043. /**
  106044. * Teleports the users feet to the desired location
  106045. * @param location The location where the user's feet should be placed
  106046. */
  106047. teleportCamera(location: Vector3): void;
  106048. private _convertNormalToDirectionOfRay;
  106049. private _castRayAndSelectObject;
  106050. private _notifySelectedMeshUnselected;
  106051. /**
  106052. * Sets the color of the laser ray from the vr controllers.
  106053. * @param color new color for the ray.
  106054. */
  106055. changeLaserColor(color: Color3): void;
  106056. /**
  106057. * Sets the color of the ray from the vr headsets gaze.
  106058. * @param color new color for the ray.
  106059. */
  106060. changeGazeColor(color: Color3): void;
  106061. /**
  106062. * Exits VR and disposes of the vr experience helper
  106063. */
  106064. dispose(): void;
  106065. /**
  106066. * Gets the name of the VRExperienceHelper class
  106067. * @returns "VRExperienceHelper"
  106068. */
  106069. getClassName(): string;
  106070. }
  106071. }
  106072. declare module BABYLON {
  106073. /**
  106074. * Manages an XRSession to work with Babylon's engine
  106075. * @see https://doc.babylonjs.com/how_to/webxr
  106076. */
  106077. export class WebXRSessionManager implements IDisposable {
  106078. private scene;
  106079. /**
  106080. * Fires every time a new xrFrame arrives which can be used to update the camera
  106081. */
  106082. onXRFrameObservable: Observable<any>;
  106083. /**
  106084. * Fires when the xr session is ended either by the device or manually done
  106085. */
  106086. onXRSessionEnded: Observable<any>;
  106087. /**
  106088. * Underlying xr session
  106089. */
  106090. session: XRSession;
  106091. /**
  106092. * Type of reference space used when creating the session
  106093. */
  106094. referenceSpace: XRReferenceSpace;
  106095. /** @hidden */
  106096. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  106097. /**
  106098. * Current XR frame
  106099. */
  106100. currentFrame: Nullable<XRFrame>;
  106101. private _xrNavigator;
  106102. private baseLayer;
  106103. /**
  106104. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  106105. * @param scene The scene which the session should be created for
  106106. */
  106107. constructor(scene: Scene);
  106108. /**
  106109. * Initializes the manager
  106110. * After initialization enterXR can be called to start an XR session
  106111. * @returns Promise which resolves after it is initialized
  106112. */
  106113. initializeAsync(): Promise<void>;
  106114. /**
  106115. * Initializes an xr session
  106116. * @param xrSessionMode mode to initialize
  106117. * @returns a promise which will resolve once the session has been initialized
  106118. */
  106119. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  106120. /**
  106121. * Sets the reference space on the xr session
  106122. * @param referenceSpace space to set
  106123. * @returns a promise that will resolve once the reference space has been set
  106124. */
  106125. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  106126. /**
  106127. * Updates the render state of the session
  106128. * @param state state to set
  106129. * @returns a promise that resolves once the render state has been updated
  106130. */
  106131. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  106132. /**
  106133. * Starts rendering to the xr layer
  106134. * @returns a promise that will resolve once rendering has started
  106135. */
  106136. startRenderingToXRAsync(): Promise<void>;
  106137. /**
  106138. * Stops the xrSession and restores the renderloop
  106139. * @returns Promise which resolves after it exits XR
  106140. */
  106141. exitXRAsync(): Promise<unknown>;
  106142. /**
  106143. * Checks if a session would be supported for the creation options specified
  106144. * @param sessionMode session mode to check if supported eg. immersive-vr
  106145. * @returns true if supported
  106146. */
  106147. supportsSessionAsync(sessionMode: XRSessionMode): any;
  106148. /**
  106149. * @hidden
  106150. * Converts the render layer of xrSession to a render target
  106151. * @param session session to create render target for
  106152. * @param scene scene the new render target should be created for
  106153. */
  106154. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  106155. /**
  106156. * Disposes of the session manager
  106157. */
  106158. dispose(): void;
  106159. }
  106160. }
  106161. declare module BABYLON {
  106162. /**
  106163. * WebXR Camera which holds the views for the xrSession
  106164. * @see https://doc.babylonjs.com/how_to/webxr
  106165. */
  106166. export class WebXRCamera extends FreeCamera {
  106167. private static _TmpMatrix;
  106168. /**
  106169. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  106170. * @param name the name of the camera
  106171. * @param scene the scene to add the camera to
  106172. */
  106173. constructor(name: string, scene: Scene);
  106174. private _updateNumberOfRigCameras;
  106175. /** @hidden */
  106176. _updateForDualEyeDebugging(pupilDistance?: number): void;
  106177. /**
  106178. * Updates the cameras position from the current pose information of the XR session
  106179. * @param xrSessionManager the session containing pose information
  106180. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  106181. */
  106182. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  106183. }
  106184. }
  106185. declare module BABYLON {
  106186. /**
  106187. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  106188. */
  106189. export class WebXRManagedOutputCanvas implements IDisposable {
  106190. private helper;
  106191. private _canvas;
  106192. /**
  106193. * xrpresent context of the canvas which can be used to display/mirror xr content
  106194. */
  106195. canvasContext: WebGLRenderingContext;
  106196. /**
  106197. * xr layer for the canvas
  106198. */
  106199. xrLayer: Nullable<XRWebGLLayer>;
  106200. /**
  106201. * Initializes the xr layer for the session
  106202. * @param xrSession xr session
  106203. * @returns a promise that will resolve once the XR Layer has been created
  106204. */
  106205. initializeXRLayerAsync(xrSession: any): any;
  106206. /**
  106207. * Initializes the canvas to be added/removed upon entering/exiting xr
  106208. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  106209. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  106210. */
  106211. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  106212. /**
  106213. * Disposes of the object
  106214. */
  106215. dispose(): void;
  106216. private _setManagedOutputCanvas;
  106217. private _addCanvas;
  106218. private _removeCanvas;
  106219. }
  106220. }
  106221. declare module BABYLON {
  106222. /**
  106223. * States of the webXR experience
  106224. */
  106225. export enum WebXRState {
  106226. /**
  106227. * Transitioning to being in XR mode
  106228. */
  106229. ENTERING_XR = 0,
  106230. /**
  106231. * Transitioning to non XR mode
  106232. */
  106233. EXITING_XR = 1,
  106234. /**
  106235. * In XR mode and presenting
  106236. */
  106237. IN_XR = 2,
  106238. /**
  106239. * Not entered XR mode
  106240. */
  106241. NOT_IN_XR = 3
  106242. }
  106243. /**
  106244. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  106245. * @see https://doc.babylonjs.com/how_to/webxr
  106246. */
  106247. export class WebXRExperienceHelper implements IDisposable {
  106248. private scene;
  106249. /**
  106250. * 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
  106251. */
  106252. container: AbstractMesh;
  106253. /**
  106254. * Camera used to render xr content
  106255. */
  106256. camera: WebXRCamera;
  106257. /**
  106258. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  106259. */
  106260. state: WebXRState;
  106261. private _setState;
  106262. private static _TmpVector;
  106263. /**
  106264. * Fires when the state of the experience helper has changed
  106265. */
  106266. onStateChangedObservable: Observable<WebXRState>;
  106267. /** Session manager used to keep track of xr session */
  106268. sessionManager: WebXRSessionManager;
  106269. private _nonVRCamera;
  106270. private _originalSceneAutoClear;
  106271. private _supported;
  106272. /**
  106273. * Creates the experience helper
  106274. * @param scene the scene to attach the experience helper to
  106275. * @returns a promise for the experience helper
  106276. */
  106277. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  106278. /**
  106279. * Creates a WebXRExperienceHelper
  106280. * @param scene The scene the helper should be created in
  106281. */
  106282. private constructor();
  106283. /**
  106284. * Exits XR mode and returns the scene to its original state
  106285. * @returns promise that resolves after xr mode has exited
  106286. */
  106287. exitXRAsync(): Promise<unknown>;
  106288. /**
  106289. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  106290. * @param sessionCreationOptions options for the XR session
  106291. * @param referenceSpaceType frame of reference of the XR session
  106292. * @param outputCanvas the output canvas that will be used to enter XR mode
  106293. * @returns promise that resolves after xr mode has entered
  106294. */
  106295. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  106296. /**
  106297. * Updates the global position of the camera by moving the camera's container
  106298. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  106299. * @param position The desired global position of the camera
  106300. */
  106301. setPositionOfCameraUsingContainer(position: Vector3): void;
  106302. /**
  106303. * Rotates the xr camera by rotating the camera's container around the camera's position
  106304. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  106305. * @param rotation the desired quaternion rotation to apply to the camera
  106306. */
  106307. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  106308. /**
  106309. * Disposes of the experience helper
  106310. */
  106311. dispose(): void;
  106312. }
  106313. }
  106314. declare module BABYLON {
  106315. /**
  106316. * Button which can be used to enter a different mode of XR
  106317. */
  106318. export class WebXREnterExitUIButton {
  106319. /** button element */
  106320. element: HTMLElement;
  106321. /** XR initialization options for the button */
  106322. sessionMode: XRSessionMode;
  106323. /** Reference space type */
  106324. referenceSpaceType: XRReferenceSpaceType;
  106325. /**
  106326. * Creates a WebXREnterExitUIButton
  106327. * @param element button element
  106328. * @param sessionMode XR initialization session mode
  106329. * @param referenceSpaceType the type of reference space to be used
  106330. */
  106331. constructor(
  106332. /** button element */
  106333. element: HTMLElement,
  106334. /** XR initialization options for the button */
  106335. sessionMode: XRSessionMode,
  106336. /** Reference space type */
  106337. referenceSpaceType: XRReferenceSpaceType);
  106338. /**
  106339. * Overwritable function which can be used to update the button's visuals when the state changes
  106340. * @param activeButton the current active button in the UI
  106341. */
  106342. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  106343. }
  106344. /**
  106345. * Options to create the webXR UI
  106346. */
  106347. export class WebXREnterExitUIOptions {
  106348. /**
  106349. * Context to enter xr with
  106350. */
  106351. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  106352. /**
  106353. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  106354. */
  106355. customButtons?: Array<WebXREnterExitUIButton>;
  106356. }
  106357. /**
  106358. * UI to allow the user to enter/exit XR mode
  106359. */
  106360. export class WebXREnterExitUI implements IDisposable {
  106361. private scene;
  106362. private _overlay;
  106363. private _buttons;
  106364. private _activeButton;
  106365. /**
  106366. * Fired every time the active button is changed.
  106367. *
  106368. * When xr is entered via a button that launches xr that button will be the callback parameter
  106369. *
  106370. * When exiting xr the callback parameter will be null)
  106371. */
  106372. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  106373. /**
  106374. * Creates UI to allow the user to enter/exit XR mode
  106375. * @param scene the scene to add the ui to
  106376. * @param helper the xr experience helper to enter/exit xr with
  106377. * @param options options to configure the UI
  106378. * @returns the created ui
  106379. */
  106380. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  106381. private constructor();
  106382. private _updateButtons;
  106383. /**
  106384. * Disposes of the object
  106385. */
  106386. dispose(): void;
  106387. }
  106388. }
  106389. declare module BABYLON {
  106390. /**
  106391. * Represents an XR input
  106392. */
  106393. export class WebXRController {
  106394. private scene;
  106395. /** The underlying input source for the controller */
  106396. inputSource: XRInputSource;
  106397. private parentContainer;
  106398. /**
  106399. * 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
  106400. */
  106401. grip?: AbstractMesh;
  106402. /**
  106403. * Pointer which can be used to select objects or attach a visible laser to
  106404. */
  106405. pointer: AbstractMesh;
  106406. /**
  106407. * Event that fires when the controller is removed/disposed
  106408. */
  106409. onDisposeObservable: Observable<{}>;
  106410. private _tmpMatrix;
  106411. private _tmpQuaternion;
  106412. private _tmpVector;
  106413. /**
  106414. * Creates the controller
  106415. * @see https://doc.babylonjs.com/how_to/webxr
  106416. * @param scene the scene which the controller should be associated to
  106417. * @param inputSource the underlying input source for the controller
  106418. * @param parentContainer parent that the controller meshes should be children of
  106419. */
  106420. constructor(scene: Scene,
  106421. /** The underlying input source for the controller */
  106422. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  106423. /**
  106424. * Updates the controller pose based on the given XRFrame
  106425. * @param xrFrame xr frame to update the pose with
  106426. * @param referenceSpace reference space to use
  106427. */
  106428. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  106429. /**
  106430. * Gets a world space ray coming from the controller
  106431. * @param result the resulting ray
  106432. */
  106433. getWorldPointerRayToRef(result: Ray): void;
  106434. /**
  106435. * Disposes of the object
  106436. */
  106437. dispose(): void;
  106438. }
  106439. }
  106440. declare module BABYLON {
  106441. /**
  106442. * XR input used to track XR inputs such as controllers/rays
  106443. */
  106444. export class WebXRInput implements IDisposable {
  106445. /**
  106446. * Base experience the input listens to
  106447. */
  106448. baseExperience: WebXRExperienceHelper;
  106449. /**
  106450. * XR controllers being tracked
  106451. */
  106452. controllers: Array<WebXRController>;
  106453. private _frameObserver;
  106454. private _stateObserver;
  106455. /**
  106456. * Event when a controller has been connected/added
  106457. */
  106458. onControllerAddedObservable: Observable<WebXRController>;
  106459. /**
  106460. * Event when a controller has been removed/disconnected
  106461. */
  106462. onControllerRemovedObservable: Observable<WebXRController>;
  106463. /**
  106464. * Initializes the WebXRInput
  106465. * @param baseExperience experience helper which the input should be created for
  106466. */
  106467. constructor(
  106468. /**
  106469. * Base experience the input listens to
  106470. */
  106471. baseExperience: WebXRExperienceHelper);
  106472. private _onInputSourcesChange;
  106473. private _addAndRemoveControllers;
  106474. /**
  106475. * Disposes of the object
  106476. */
  106477. dispose(): void;
  106478. }
  106479. }
  106480. declare module BABYLON {
  106481. /**
  106482. * Enables teleportation
  106483. */
  106484. export class WebXRControllerTeleportation {
  106485. private _teleportationFillColor;
  106486. private _teleportationBorderColor;
  106487. private _tmpRay;
  106488. private _tmpVector;
  106489. /**
  106490. * Creates a WebXRControllerTeleportation
  106491. * @param input input manager to add teleportation to
  106492. * @param floorMeshes floormeshes which can be teleported to
  106493. */
  106494. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  106495. }
  106496. }
  106497. declare module BABYLON {
  106498. /**
  106499. * Handles pointer input automatically for the pointer of XR controllers
  106500. */
  106501. export class WebXRControllerPointerSelection {
  106502. private static _idCounter;
  106503. private _tmpRay;
  106504. /**
  106505. * Creates a WebXRControllerPointerSelection
  106506. * @param input input manager to setup pointer selection
  106507. */
  106508. constructor(input: WebXRInput);
  106509. private _convertNormalToDirectionOfRay;
  106510. private _updatePointerDistance;
  106511. }
  106512. }
  106513. declare module BABYLON {
  106514. /**
  106515. * Class used to represent data loading progression
  106516. */
  106517. export class SceneLoaderProgressEvent {
  106518. /** defines if data length to load can be evaluated */
  106519. readonly lengthComputable: boolean;
  106520. /** defines the loaded data length */
  106521. readonly loaded: number;
  106522. /** defines the data length to load */
  106523. readonly total: number;
  106524. /**
  106525. * Create a new progress event
  106526. * @param lengthComputable defines if data length to load can be evaluated
  106527. * @param loaded defines the loaded data length
  106528. * @param total defines the data length to load
  106529. */
  106530. constructor(
  106531. /** defines if data length to load can be evaluated */
  106532. lengthComputable: boolean,
  106533. /** defines the loaded data length */
  106534. loaded: number,
  106535. /** defines the data length to load */
  106536. total: number);
  106537. /**
  106538. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  106539. * @param event defines the source event
  106540. * @returns a new SceneLoaderProgressEvent
  106541. */
  106542. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  106543. }
  106544. /**
  106545. * Interface used by SceneLoader plugins to define supported file extensions
  106546. */
  106547. export interface ISceneLoaderPluginExtensions {
  106548. /**
  106549. * Defines the list of supported extensions
  106550. */
  106551. [extension: string]: {
  106552. isBinary: boolean;
  106553. };
  106554. }
  106555. /**
  106556. * Interface used by SceneLoader plugin factory
  106557. */
  106558. export interface ISceneLoaderPluginFactory {
  106559. /**
  106560. * Defines the name of the factory
  106561. */
  106562. name: string;
  106563. /**
  106564. * Function called to create a new plugin
  106565. * @return the new plugin
  106566. */
  106567. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  106568. /**
  106569. * Boolean indicating if the plugin can direct load specific data
  106570. */
  106571. canDirectLoad?: (data: string) => boolean;
  106572. }
  106573. /**
  106574. * Interface used to define a SceneLoader plugin
  106575. */
  106576. export interface ISceneLoaderPlugin {
  106577. /**
  106578. * The friendly name of this plugin.
  106579. */
  106580. name: string;
  106581. /**
  106582. * The file extensions supported by this plugin.
  106583. */
  106584. extensions: string | ISceneLoaderPluginExtensions;
  106585. /**
  106586. * Import meshes into a scene.
  106587. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106588. * @param scene The scene to import into
  106589. * @param data The data to import
  106590. * @param rootUrl The root url for scene and resources
  106591. * @param meshes The meshes array to import into
  106592. * @param particleSystems The particle systems array to import into
  106593. * @param skeletons The skeletons array to import into
  106594. * @param onError The callback when import fails
  106595. * @returns True if successful or false otherwise
  106596. */
  106597. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  106598. /**
  106599. * Load into a scene.
  106600. * @param scene The scene to load into
  106601. * @param data The data to import
  106602. * @param rootUrl The root url for scene and resources
  106603. * @param onError The callback when import fails
  106604. * @returns true if successful or false otherwise
  106605. */
  106606. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  106607. /**
  106608. * The callback that returns true if the data can be directly loaded.
  106609. */
  106610. canDirectLoad?: (data: string) => boolean;
  106611. /**
  106612. * The callback that allows custom handling of the root url based on the response url.
  106613. */
  106614. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106615. /**
  106616. * Load into an asset container.
  106617. * @param scene The scene to load into
  106618. * @param data The data to import
  106619. * @param rootUrl The root url for scene and resources
  106620. * @param onError The callback when import fails
  106621. * @returns The loaded asset container
  106622. */
  106623. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  106624. }
  106625. /**
  106626. * Interface used to define an async SceneLoader plugin
  106627. */
  106628. export interface ISceneLoaderPluginAsync {
  106629. /**
  106630. * The friendly name of this plugin.
  106631. */
  106632. name: string;
  106633. /**
  106634. * The file extensions supported by this plugin.
  106635. */
  106636. extensions: string | ISceneLoaderPluginExtensions;
  106637. /**
  106638. * Import meshes into a scene.
  106639. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106640. * @param scene The scene to import into
  106641. * @param data The data to import
  106642. * @param rootUrl The root url for scene and resources
  106643. * @param onProgress The callback when the load progresses
  106644. * @param fileName Defines the name of the file to load
  106645. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  106646. */
  106647. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  106648. meshes: AbstractMesh[];
  106649. particleSystems: IParticleSystem[];
  106650. skeletons: Skeleton[];
  106651. animationGroups: AnimationGroup[];
  106652. }>;
  106653. /**
  106654. * Load into a scene.
  106655. * @param scene The scene to load into
  106656. * @param data The data to import
  106657. * @param rootUrl The root url for scene and resources
  106658. * @param onProgress The callback when the load progresses
  106659. * @param fileName Defines the name of the file to load
  106660. * @returns Nothing
  106661. */
  106662. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  106663. /**
  106664. * The callback that returns true if the data can be directly loaded.
  106665. */
  106666. canDirectLoad?: (data: string) => boolean;
  106667. /**
  106668. * The callback that allows custom handling of the root url based on the response url.
  106669. */
  106670. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106671. /**
  106672. * Load into an asset container.
  106673. * @param scene The scene to load into
  106674. * @param data The data to import
  106675. * @param rootUrl The root url for scene and resources
  106676. * @param onProgress The callback when the load progresses
  106677. * @param fileName Defines the name of the file to load
  106678. * @returns The loaded asset container
  106679. */
  106680. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  106681. }
  106682. /**
  106683. * Class used to load scene from various file formats using registered plugins
  106684. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  106685. */
  106686. export class SceneLoader {
  106687. /**
  106688. * No logging while loading
  106689. */
  106690. static readonly NO_LOGGING: number;
  106691. /**
  106692. * Minimal logging while loading
  106693. */
  106694. static readonly MINIMAL_LOGGING: number;
  106695. /**
  106696. * Summary logging while loading
  106697. */
  106698. static readonly SUMMARY_LOGGING: number;
  106699. /**
  106700. * Detailled logging while loading
  106701. */
  106702. static readonly DETAILED_LOGGING: number;
  106703. /**
  106704. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106705. */
  106706. static ForceFullSceneLoadingForIncremental: boolean;
  106707. /**
  106708. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106709. */
  106710. static ShowLoadingScreen: boolean;
  106711. /**
  106712. * Defines the current logging level (while loading the scene)
  106713. * @ignorenaming
  106714. */
  106715. static loggingLevel: number;
  106716. /**
  106717. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106718. */
  106719. static CleanBoneMatrixWeights: boolean;
  106720. /**
  106721. * Event raised when a plugin is used to load a scene
  106722. */
  106723. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  106724. private static _registeredPlugins;
  106725. private static _getDefaultPlugin;
  106726. private static _getPluginForExtension;
  106727. private static _getPluginForDirectLoad;
  106728. private static _getPluginForFilename;
  106729. private static _getDirectLoad;
  106730. private static _loadData;
  106731. private static _getFileInfo;
  106732. /**
  106733. * Gets a plugin that can load the given extension
  106734. * @param extension defines the extension to load
  106735. * @returns a plugin or null if none works
  106736. */
  106737. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  106738. /**
  106739. * Gets a boolean indicating that the given extension can be loaded
  106740. * @param extension defines the extension to load
  106741. * @returns true if the extension is supported
  106742. */
  106743. static IsPluginForExtensionAvailable(extension: string): boolean;
  106744. /**
  106745. * Adds a new plugin to the list of registered plugins
  106746. * @param plugin defines the plugin to add
  106747. */
  106748. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  106749. /**
  106750. * Import meshes into a scene
  106751. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106752. * @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)
  106753. * @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)
  106754. * @param scene the instance of BABYLON.Scene to append to
  106755. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  106756. * @param onProgress a callback with a progress event for each file being loaded
  106757. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106758. * @param pluginExtension the extension used to determine the plugin
  106759. * @returns The loaded plugin
  106760. */
  106761. 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>;
  106762. /**
  106763. * Import meshes into a scene
  106764. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106765. * @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)
  106766. * @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)
  106767. * @param scene the instance of BABYLON.Scene to append to
  106768. * @param onProgress a callback with a progress event for each file being loaded
  106769. * @param pluginExtension the extension used to determine the plugin
  106770. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  106771. */
  106772. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  106773. meshes: AbstractMesh[];
  106774. particleSystems: IParticleSystem[];
  106775. skeletons: Skeleton[];
  106776. animationGroups: AnimationGroup[];
  106777. }>;
  106778. /**
  106779. * Load a scene
  106780. * @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)
  106781. * @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)
  106782. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106783. * @param onSuccess a callback with the scene when import succeeds
  106784. * @param onProgress a callback with a progress event for each file being loaded
  106785. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106786. * @param pluginExtension the extension used to determine the plugin
  106787. * @returns The loaded plugin
  106788. */
  106789. 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>;
  106790. /**
  106791. * Load a scene
  106792. * @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)
  106793. * @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)
  106794. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106795. * @param onProgress a callback with a progress event for each file being loaded
  106796. * @param pluginExtension the extension used to determine the plugin
  106797. * @returns The loaded scene
  106798. */
  106799. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106800. /**
  106801. * Append a scene
  106802. * @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)
  106803. * @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)
  106804. * @param scene is the instance of BABYLON.Scene to append to
  106805. * @param onSuccess a callback with the scene when import succeeds
  106806. * @param onProgress a callback with a progress event for each file being loaded
  106807. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106808. * @param pluginExtension the extension used to determine the plugin
  106809. * @returns The loaded plugin
  106810. */
  106811. 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>;
  106812. /**
  106813. * Append a scene
  106814. * @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)
  106815. * @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)
  106816. * @param scene is the instance of BABYLON.Scene to append to
  106817. * @param onProgress a callback with a progress event for each file being loaded
  106818. * @param pluginExtension the extension used to determine the plugin
  106819. * @returns The given scene
  106820. */
  106821. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106822. /**
  106823. * Load a scene into an asset container
  106824. * @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)
  106825. * @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)
  106826. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106827. * @param onSuccess a callback with the scene when import succeeds
  106828. * @param onProgress a callback with a progress event for each file being loaded
  106829. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106830. * @param pluginExtension the extension used to determine the plugin
  106831. * @returns The loaded plugin
  106832. */
  106833. 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>;
  106834. /**
  106835. * Load a scene into an asset container
  106836. * @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)
  106837. * @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)
  106838. * @param scene is the instance of Scene to append to
  106839. * @param onProgress a callback with a progress event for each file being loaded
  106840. * @param pluginExtension the extension used to determine the plugin
  106841. * @returns The loaded asset container
  106842. */
  106843. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106844. }
  106845. }
  106846. declare module BABYLON {
  106847. /**
  106848. * Generic Controller
  106849. */
  106850. export class GenericController extends WebVRController {
  106851. /**
  106852. * Base Url for the controller model.
  106853. */
  106854. static readonly MODEL_BASE_URL: string;
  106855. /**
  106856. * File name for the controller model.
  106857. */
  106858. static readonly MODEL_FILENAME: string;
  106859. /**
  106860. * Creates a new GenericController from a gamepad
  106861. * @param vrGamepad the gamepad that the controller should be created from
  106862. */
  106863. constructor(vrGamepad: any);
  106864. /**
  106865. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106866. * @param scene scene in which to add meshes
  106867. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106868. */
  106869. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106870. /**
  106871. * Called once for each button that changed state since the last frame
  106872. * @param buttonIdx Which button index changed
  106873. * @param state New state of the button
  106874. * @param changes Which properties on the state changed since last frame
  106875. */
  106876. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106877. }
  106878. }
  106879. declare module BABYLON {
  106880. /**
  106881. * Defines the WindowsMotionController object that the state of the windows motion controller
  106882. */
  106883. export class WindowsMotionController extends WebVRController {
  106884. /**
  106885. * The base url used to load the left and right controller models
  106886. */
  106887. static MODEL_BASE_URL: string;
  106888. /**
  106889. * The name of the left controller model file
  106890. */
  106891. static MODEL_LEFT_FILENAME: string;
  106892. /**
  106893. * The name of the right controller model file
  106894. */
  106895. static MODEL_RIGHT_FILENAME: string;
  106896. /**
  106897. * The controller name prefix for this controller type
  106898. */
  106899. static readonly GAMEPAD_ID_PREFIX: string;
  106900. /**
  106901. * The controller id pattern for this controller type
  106902. */
  106903. private static readonly GAMEPAD_ID_PATTERN;
  106904. private _loadedMeshInfo;
  106905. private readonly _mapping;
  106906. /**
  106907. * Fired when the trackpad on this controller is clicked
  106908. */
  106909. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106910. /**
  106911. * Fired when the trackpad on this controller is modified
  106912. */
  106913. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106914. /**
  106915. * The current x and y values of this controller's trackpad
  106916. */
  106917. trackpad: StickValues;
  106918. /**
  106919. * Creates a new WindowsMotionController from a gamepad
  106920. * @param vrGamepad the gamepad that the controller should be created from
  106921. */
  106922. constructor(vrGamepad: any);
  106923. /**
  106924. * Fired when the trigger on this controller is modified
  106925. */
  106926. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106927. /**
  106928. * Fired when the menu button on this controller is modified
  106929. */
  106930. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106931. /**
  106932. * Fired when the grip button on this controller is modified
  106933. */
  106934. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106935. /**
  106936. * Fired when the thumbstick button on this controller is modified
  106937. */
  106938. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106939. /**
  106940. * Fired when the touchpad button on this controller is modified
  106941. */
  106942. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106943. /**
  106944. * Fired when the touchpad values on this controller are modified
  106945. */
  106946. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106947. private _updateTrackpad;
  106948. /**
  106949. * Called once per frame by the engine.
  106950. */
  106951. update(): void;
  106952. /**
  106953. * Called once for each button that changed state since the last frame
  106954. * @param buttonIdx Which button index changed
  106955. * @param state New state of the button
  106956. * @param changes Which properties on the state changed since last frame
  106957. */
  106958. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106959. /**
  106960. * Moves the buttons on the controller mesh based on their current state
  106961. * @param buttonName the name of the button to move
  106962. * @param buttonValue the value of the button which determines the buttons new position
  106963. */
  106964. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106965. /**
  106966. * Moves the axis on the controller mesh based on its current state
  106967. * @param axis the index of the axis
  106968. * @param axisValue the value of the axis which determines the meshes new position
  106969. * @hidden
  106970. */
  106971. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106972. /**
  106973. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106974. * @param scene scene in which to add meshes
  106975. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106976. */
  106977. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106978. /**
  106979. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106980. * can be transformed by button presses and axes values, based on this._mapping.
  106981. *
  106982. * @param scene scene in which the meshes exist
  106983. * @param meshes list of meshes that make up the controller model to process
  106984. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106985. */
  106986. private processModel;
  106987. private createMeshInfo;
  106988. /**
  106989. * Gets the ray of the controller in the direction the controller is pointing
  106990. * @param length the length the resulting ray should be
  106991. * @returns a ray in the direction the controller is pointing
  106992. */
  106993. getForwardRay(length?: number): Ray;
  106994. /**
  106995. * Disposes of the controller
  106996. */
  106997. dispose(): void;
  106998. }
  106999. }
  107000. declare module BABYLON {
  107001. /**
  107002. * Oculus Touch Controller
  107003. */
  107004. export class OculusTouchController extends WebVRController {
  107005. /**
  107006. * Base Url for the controller model.
  107007. */
  107008. static MODEL_BASE_URL: string;
  107009. /**
  107010. * File name for the left controller model.
  107011. */
  107012. static MODEL_LEFT_FILENAME: string;
  107013. /**
  107014. * File name for the right controller model.
  107015. */
  107016. static MODEL_RIGHT_FILENAME: string;
  107017. /**
  107018. * Base Url for the Quest controller model.
  107019. */
  107020. static QUEST_MODEL_BASE_URL: string;
  107021. /**
  107022. * @hidden
  107023. * If the controllers are running on a device that needs the updated Quest controller models
  107024. */
  107025. static _IsQuest: boolean;
  107026. /**
  107027. * Fired when the secondary trigger on this controller is modified
  107028. */
  107029. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107030. /**
  107031. * Fired when the thumb rest on this controller is modified
  107032. */
  107033. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107034. /**
  107035. * Creates a new OculusTouchController from a gamepad
  107036. * @param vrGamepad the gamepad that the controller should be created from
  107037. */
  107038. constructor(vrGamepad: any);
  107039. /**
  107040. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107041. * @param scene scene in which to add meshes
  107042. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107043. */
  107044. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107045. /**
  107046. * Fired when the A button on this controller is modified
  107047. */
  107048. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107049. /**
  107050. * Fired when the B button on this controller is modified
  107051. */
  107052. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107053. /**
  107054. * Fired when the X button on this controller is modified
  107055. */
  107056. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107057. /**
  107058. * Fired when the Y button on this controller is modified
  107059. */
  107060. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107061. /**
  107062. * Called once for each button that changed state since the last frame
  107063. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107064. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107065. * 2) secondary trigger (same)
  107066. * 3) A (right) X (left), touch, pressed = value
  107067. * 4) B / Y
  107068. * 5) thumb rest
  107069. * @param buttonIdx Which button index changed
  107070. * @param state New state of the button
  107071. * @param changes Which properties on the state changed since last frame
  107072. */
  107073. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107074. }
  107075. }
  107076. declare module BABYLON {
  107077. /**
  107078. * Vive Controller
  107079. */
  107080. export class ViveController extends WebVRController {
  107081. /**
  107082. * Base Url for the controller model.
  107083. */
  107084. static MODEL_BASE_URL: string;
  107085. /**
  107086. * File name for the controller model.
  107087. */
  107088. static MODEL_FILENAME: string;
  107089. /**
  107090. * Creates a new ViveController from a gamepad
  107091. * @param vrGamepad the gamepad that the controller should be created from
  107092. */
  107093. constructor(vrGamepad: any);
  107094. /**
  107095. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107096. * @param scene scene in which to add meshes
  107097. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107098. */
  107099. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107100. /**
  107101. * Fired when the left button on this controller is modified
  107102. */
  107103. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107104. /**
  107105. * Fired when the right button on this controller is modified
  107106. */
  107107. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107108. /**
  107109. * Fired when the menu button on this controller is modified
  107110. */
  107111. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107112. /**
  107113. * Called once for each button that changed state since the last frame
  107114. * Vive mapping:
  107115. * 0: touchpad
  107116. * 1: trigger
  107117. * 2: left AND right buttons
  107118. * 3: menu button
  107119. * @param buttonIdx Which button index changed
  107120. * @param state New state of the button
  107121. * @param changes Which properties on the state changed since last frame
  107122. */
  107123. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107124. }
  107125. }
  107126. declare module BABYLON {
  107127. /**
  107128. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  107129. */
  107130. export class WebXRControllerModelLoader {
  107131. /**
  107132. * Creates the WebXRControllerModelLoader
  107133. * @param input xr input that creates the controllers
  107134. */
  107135. constructor(input: WebXRInput);
  107136. }
  107137. }
  107138. declare module BABYLON {
  107139. /**
  107140. * Contains an array of blocks representing the octree
  107141. */
  107142. export interface IOctreeContainer<T> {
  107143. /**
  107144. * Blocks within the octree
  107145. */
  107146. blocks: Array<OctreeBlock<T>>;
  107147. }
  107148. /**
  107149. * Class used to store a cell in an octree
  107150. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107151. */
  107152. export class OctreeBlock<T> {
  107153. /**
  107154. * Gets the content of the current block
  107155. */
  107156. entries: T[];
  107157. /**
  107158. * Gets the list of block children
  107159. */
  107160. blocks: Array<OctreeBlock<T>>;
  107161. private _depth;
  107162. private _maxDepth;
  107163. private _capacity;
  107164. private _minPoint;
  107165. private _maxPoint;
  107166. private _boundingVectors;
  107167. private _creationFunc;
  107168. /**
  107169. * Creates a new block
  107170. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  107171. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  107172. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107173. * @param depth defines the current depth of this block in the octree
  107174. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  107175. * @param creationFunc defines a callback to call when an element is added to the block
  107176. */
  107177. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  107178. /**
  107179. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107180. */
  107181. readonly capacity: number;
  107182. /**
  107183. * Gets the minimum vector (in world space) of the block's bounding box
  107184. */
  107185. readonly minPoint: Vector3;
  107186. /**
  107187. * Gets the maximum vector (in world space) of the block's bounding box
  107188. */
  107189. readonly maxPoint: Vector3;
  107190. /**
  107191. * Add a new element to this block
  107192. * @param entry defines the element to add
  107193. */
  107194. addEntry(entry: T): void;
  107195. /**
  107196. * Remove an element from this block
  107197. * @param entry defines the element to remove
  107198. */
  107199. removeEntry(entry: T): void;
  107200. /**
  107201. * Add an array of elements to this block
  107202. * @param entries defines the array of elements to add
  107203. */
  107204. addEntries(entries: T[]): void;
  107205. /**
  107206. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  107207. * @param frustumPlanes defines the frustum planes to test
  107208. * @param selection defines the array to store current content if selection is positive
  107209. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107210. */
  107211. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107212. /**
  107213. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  107214. * @param sphereCenter defines the bounding sphere center
  107215. * @param sphereRadius defines the bounding sphere radius
  107216. * @param selection defines the array to store current content if selection is positive
  107217. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107218. */
  107219. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107220. /**
  107221. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  107222. * @param ray defines the ray to test with
  107223. * @param selection defines the array to store current content if selection is positive
  107224. */
  107225. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  107226. /**
  107227. * Subdivide the content into child blocks (this block will then be empty)
  107228. */
  107229. createInnerBlocks(): void;
  107230. /**
  107231. * @hidden
  107232. */
  107233. 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;
  107234. }
  107235. }
  107236. declare module BABYLON {
  107237. /**
  107238. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  107239. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107240. */
  107241. export class Octree<T> {
  107242. /** 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.) */
  107243. maxDepth: number;
  107244. /**
  107245. * Blocks within the octree containing objects
  107246. */
  107247. blocks: Array<OctreeBlock<T>>;
  107248. /**
  107249. * Content stored in the octree
  107250. */
  107251. dynamicContent: T[];
  107252. private _maxBlockCapacity;
  107253. private _selectionContent;
  107254. private _creationFunc;
  107255. /**
  107256. * Creates a octree
  107257. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107258. * @param creationFunc function to be used to instatiate the octree
  107259. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  107260. * @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.)
  107261. */
  107262. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  107263. /** 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.) */
  107264. maxDepth?: number);
  107265. /**
  107266. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  107267. * @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);
  107268. * @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);
  107269. * @param entries meshes to be added to the octree blocks
  107270. */
  107271. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  107272. /**
  107273. * Adds a mesh to the octree
  107274. * @param entry Mesh to add to the octree
  107275. */
  107276. addMesh(entry: T): void;
  107277. /**
  107278. * Remove an element from the octree
  107279. * @param entry defines the element to remove
  107280. */
  107281. removeMesh(entry: T): void;
  107282. /**
  107283. * Selects an array of meshes within the frustum
  107284. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  107285. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  107286. * @returns array of meshes within the frustum
  107287. */
  107288. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  107289. /**
  107290. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  107291. * @param sphereCenter defines the bounding sphere center
  107292. * @param sphereRadius defines the bounding sphere radius
  107293. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107294. * @returns an array of objects that intersect the sphere
  107295. */
  107296. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  107297. /**
  107298. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  107299. * @param ray defines the ray to test with
  107300. * @returns array of intersected objects
  107301. */
  107302. intersectsRay(ray: Ray): SmartArray<T>;
  107303. /**
  107304. * Adds a mesh into the octree block if it intersects the block
  107305. */
  107306. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  107307. /**
  107308. * Adds a submesh into the octree block if it intersects the block
  107309. */
  107310. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  107311. }
  107312. }
  107313. declare module BABYLON {
  107314. interface Scene {
  107315. /**
  107316. * @hidden
  107317. * Backing Filed
  107318. */
  107319. _selectionOctree: Octree<AbstractMesh>;
  107320. /**
  107321. * Gets the octree used to boost mesh selection (picking)
  107322. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107323. */
  107324. selectionOctree: Octree<AbstractMesh>;
  107325. /**
  107326. * Creates or updates the octree used to boost selection (picking)
  107327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107328. * @param maxCapacity defines the maximum capacity per leaf
  107329. * @param maxDepth defines the maximum depth of the octree
  107330. * @returns an octree of AbstractMesh
  107331. */
  107332. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  107333. }
  107334. interface AbstractMesh {
  107335. /**
  107336. * @hidden
  107337. * Backing Field
  107338. */
  107339. _submeshesOctree: Octree<SubMesh>;
  107340. /**
  107341. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  107342. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107343. * @param maxCapacity defines the maximum size of each block (64 by default)
  107344. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  107345. * @returns the new octree
  107346. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  107347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107348. */
  107349. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  107350. }
  107351. /**
  107352. * Defines the octree scene component responsible to manage any octrees
  107353. * in a given scene.
  107354. */
  107355. export class OctreeSceneComponent {
  107356. /**
  107357. * The component name help to identify the component in the list of scene components.
  107358. */
  107359. readonly name: string;
  107360. /**
  107361. * The scene the component belongs to.
  107362. */
  107363. scene: Scene;
  107364. /**
  107365. * Indicates if the meshes have been checked to make sure they are isEnabled()
  107366. */
  107367. readonly checksIsEnabled: boolean;
  107368. /**
  107369. * Creates a new instance of the component for the given scene
  107370. * @param scene Defines the scene to register the component in
  107371. */
  107372. constructor(scene: Scene);
  107373. /**
  107374. * Registers the component in a given scene
  107375. */
  107376. register(): void;
  107377. /**
  107378. * Return the list of active meshes
  107379. * @returns the list of active meshes
  107380. */
  107381. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107382. /**
  107383. * Return the list of active sub meshes
  107384. * @param mesh The mesh to get the candidates sub meshes from
  107385. * @returns the list of active sub meshes
  107386. */
  107387. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107388. private _tempRay;
  107389. /**
  107390. * Return the list of sub meshes intersecting with a given local ray
  107391. * @param mesh defines the mesh to find the submesh for
  107392. * @param localRay defines the ray in local space
  107393. * @returns the list of intersecting sub meshes
  107394. */
  107395. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  107396. /**
  107397. * Return the list of sub meshes colliding with a collider
  107398. * @param mesh defines the mesh to find the submesh for
  107399. * @param collider defines the collider to evaluate the collision against
  107400. * @returns the list of colliding sub meshes
  107401. */
  107402. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  107403. /**
  107404. * Rebuilds the elements related to this component in case of
  107405. * context lost for instance.
  107406. */
  107407. rebuild(): void;
  107408. /**
  107409. * Disposes the component and the associated ressources.
  107410. */
  107411. dispose(): void;
  107412. }
  107413. }
  107414. declare module BABYLON {
  107415. /**
  107416. * Renders a layer on top of an existing scene
  107417. */
  107418. export class UtilityLayerRenderer implements IDisposable {
  107419. /** the original scene that will be rendered on top of */
  107420. originalScene: Scene;
  107421. private _pointerCaptures;
  107422. private _lastPointerEvents;
  107423. private static _DefaultUtilityLayer;
  107424. private static _DefaultKeepDepthUtilityLayer;
  107425. private _sharedGizmoLight;
  107426. private _renderCamera;
  107427. /**
  107428. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  107429. * @returns the camera that is used when rendering the utility layer
  107430. */
  107431. getRenderCamera(): Nullable<Camera>;
  107432. /**
  107433. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  107434. * @param cam the camera that should be used when rendering the utility layer
  107435. */
  107436. setRenderCamera(cam: Nullable<Camera>): void;
  107437. /**
  107438. * @hidden
  107439. * Light which used by gizmos to get light shading
  107440. */
  107441. _getSharedGizmoLight(): HemisphericLight;
  107442. /**
  107443. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  107444. */
  107445. pickUtilitySceneFirst: boolean;
  107446. /**
  107447. * 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)
  107448. */
  107449. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  107450. /**
  107451. * 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)
  107452. */
  107453. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  107454. /**
  107455. * The scene that is rendered on top of the original scene
  107456. */
  107457. utilityLayerScene: Scene;
  107458. /**
  107459. * If the utility layer should automatically be rendered on top of existing scene
  107460. */
  107461. shouldRender: boolean;
  107462. /**
  107463. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  107464. */
  107465. onlyCheckPointerDownEvents: boolean;
  107466. /**
  107467. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  107468. */
  107469. processAllEvents: boolean;
  107470. /**
  107471. * Observable raised when the pointer move from the utility layer scene to the main scene
  107472. */
  107473. onPointerOutObservable: Observable<number>;
  107474. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  107475. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  107476. private _afterRenderObserver;
  107477. private _sceneDisposeObserver;
  107478. private _originalPointerObserver;
  107479. /**
  107480. * Instantiates a UtilityLayerRenderer
  107481. * @param originalScene the original scene that will be rendered on top of
  107482. * @param handleEvents boolean indicating if the utility layer should handle events
  107483. */
  107484. constructor(
  107485. /** the original scene that will be rendered on top of */
  107486. originalScene: Scene, handleEvents?: boolean);
  107487. private _notifyObservers;
  107488. /**
  107489. * Renders the utility layers scene on top of the original scene
  107490. */
  107491. render(): void;
  107492. /**
  107493. * Disposes of the renderer
  107494. */
  107495. dispose(): void;
  107496. private _updateCamera;
  107497. }
  107498. }
  107499. declare module BABYLON {
  107500. /**
  107501. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  107502. */
  107503. export class Gizmo implements IDisposable {
  107504. /** The utility layer the gizmo will be added to */
  107505. gizmoLayer: UtilityLayerRenderer;
  107506. /**
  107507. * The root mesh of the gizmo
  107508. */
  107509. _rootMesh: Mesh;
  107510. private _attachedMesh;
  107511. /**
  107512. * Ratio for the scale of the gizmo (Default: 1)
  107513. */
  107514. scaleRatio: number;
  107515. /**
  107516. * If a custom mesh has been set (Default: false)
  107517. */
  107518. protected _customMeshSet: boolean;
  107519. /**
  107520. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  107521. * * When set, interactions will be enabled
  107522. */
  107523. attachedMesh: Nullable<AbstractMesh>;
  107524. /**
  107525. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107526. * @param mesh The mesh to replace the default mesh of the gizmo
  107527. */
  107528. setCustomMesh(mesh: Mesh): void;
  107529. /**
  107530. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  107531. */
  107532. updateGizmoRotationToMatchAttachedMesh: boolean;
  107533. /**
  107534. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  107535. */
  107536. updateGizmoPositionToMatchAttachedMesh: boolean;
  107537. /**
  107538. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  107539. */
  107540. updateScale: boolean;
  107541. protected _interactionsEnabled: boolean;
  107542. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107543. private _beforeRenderObserver;
  107544. private _tempVector;
  107545. /**
  107546. * Creates a gizmo
  107547. * @param gizmoLayer The utility layer the gizmo will be added to
  107548. */
  107549. constructor(
  107550. /** The utility layer the gizmo will be added to */
  107551. gizmoLayer?: UtilityLayerRenderer);
  107552. /**
  107553. * Updates the gizmo to match the attached mesh's position/rotation
  107554. */
  107555. protected _update(): void;
  107556. /**
  107557. * Disposes of the gizmo
  107558. */
  107559. dispose(): void;
  107560. }
  107561. }
  107562. declare module BABYLON {
  107563. /**
  107564. * Single plane drag gizmo
  107565. */
  107566. export class PlaneDragGizmo extends Gizmo {
  107567. /**
  107568. * Drag behavior responsible for the gizmos dragging interactions
  107569. */
  107570. dragBehavior: PointerDragBehavior;
  107571. private _pointerObserver;
  107572. /**
  107573. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107574. */
  107575. snapDistance: number;
  107576. /**
  107577. * Event that fires each time the gizmo snaps to a new location.
  107578. * * snapDistance is the the change in distance
  107579. */
  107580. onSnapObservable: Observable<{
  107581. snapDistance: number;
  107582. }>;
  107583. private _plane;
  107584. private _coloredMaterial;
  107585. private _hoverMaterial;
  107586. private _isEnabled;
  107587. private _parent;
  107588. /** @hidden */
  107589. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  107590. /** @hidden */
  107591. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107592. /**
  107593. * Creates a PlaneDragGizmo
  107594. * @param gizmoLayer The utility layer the gizmo will be added to
  107595. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  107596. * @param color The color of the gizmo
  107597. */
  107598. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107599. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107600. /**
  107601. * If the gizmo is enabled
  107602. */
  107603. isEnabled: boolean;
  107604. /**
  107605. * Disposes of the gizmo
  107606. */
  107607. dispose(): void;
  107608. }
  107609. }
  107610. declare module BABYLON {
  107611. /**
  107612. * Gizmo that enables dragging a mesh along 3 axis
  107613. */
  107614. export class PositionGizmo extends Gizmo {
  107615. /**
  107616. * Internal gizmo used for interactions on the x axis
  107617. */
  107618. xGizmo: AxisDragGizmo;
  107619. /**
  107620. * Internal gizmo used for interactions on the y axis
  107621. */
  107622. yGizmo: AxisDragGizmo;
  107623. /**
  107624. * Internal gizmo used for interactions on the z axis
  107625. */
  107626. zGizmo: AxisDragGizmo;
  107627. /**
  107628. * Internal gizmo used for interactions on the yz plane
  107629. */
  107630. xPlaneGizmo: PlaneDragGizmo;
  107631. /**
  107632. * Internal gizmo used for interactions on the xz plane
  107633. */
  107634. yPlaneGizmo: PlaneDragGizmo;
  107635. /**
  107636. * Internal gizmo used for interactions on the xy plane
  107637. */
  107638. zPlaneGizmo: PlaneDragGizmo;
  107639. /**
  107640. * private variables
  107641. */
  107642. private _meshAttached;
  107643. private _updateGizmoRotationToMatchAttachedMesh;
  107644. private _snapDistance;
  107645. private _scaleRatio;
  107646. /** Fires an event when any of it's sub gizmos are dragged */
  107647. onDragStartObservable: Observable<unknown>;
  107648. /** Fires an event when any of it's sub gizmos are released from dragging */
  107649. onDragEndObservable: Observable<unknown>;
  107650. /**
  107651. * If set to true, planar drag is enabled
  107652. */
  107653. private _planarGizmoEnabled;
  107654. attachedMesh: Nullable<AbstractMesh>;
  107655. /**
  107656. * Creates a PositionGizmo
  107657. * @param gizmoLayer The utility layer the gizmo will be added to
  107658. */
  107659. constructor(gizmoLayer?: UtilityLayerRenderer);
  107660. /**
  107661. * If the planar drag gizmo is enabled
  107662. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  107663. */
  107664. planarGizmoEnabled: boolean;
  107665. updateGizmoRotationToMatchAttachedMesh: boolean;
  107666. /**
  107667. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107668. */
  107669. snapDistance: number;
  107670. /**
  107671. * Ratio for the scale of the gizmo (Default: 1)
  107672. */
  107673. scaleRatio: number;
  107674. /**
  107675. * Disposes of the gizmo
  107676. */
  107677. dispose(): void;
  107678. /**
  107679. * CustomMeshes are not supported by this gizmo
  107680. * @param mesh The mesh to replace the default mesh of the gizmo
  107681. */
  107682. setCustomMesh(mesh: Mesh): void;
  107683. }
  107684. }
  107685. declare module BABYLON {
  107686. /**
  107687. * Single axis drag gizmo
  107688. */
  107689. export class AxisDragGizmo extends Gizmo {
  107690. /**
  107691. * Drag behavior responsible for the gizmos dragging interactions
  107692. */
  107693. dragBehavior: PointerDragBehavior;
  107694. private _pointerObserver;
  107695. /**
  107696. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107697. */
  107698. snapDistance: number;
  107699. /**
  107700. * Event that fires each time the gizmo snaps to a new location.
  107701. * * snapDistance is the the change in distance
  107702. */
  107703. onSnapObservable: Observable<{
  107704. snapDistance: number;
  107705. }>;
  107706. private _isEnabled;
  107707. private _parent;
  107708. private _arrow;
  107709. private _coloredMaterial;
  107710. private _hoverMaterial;
  107711. /** @hidden */
  107712. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  107713. /** @hidden */
  107714. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107715. /**
  107716. * Creates an AxisDragGizmo
  107717. * @param gizmoLayer The utility layer the gizmo will be added to
  107718. * @param dragAxis The axis which the gizmo will be able to drag on
  107719. * @param color The color of the gizmo
  107720. */
  107721. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107722. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107723. /**
  107724. * If the gizmo is enabled
  107725. */
  107726. isEnabled: boolean;
  107727. /**
  107728. * Disposes of the gizmo
  107729. */
  107730. dispose(): void;
  107731. }
  107732. }
  107733. declare module BABYLON.Debug {
  107734. /**
  107735. * The Axes viewer will show 3 axes in a specific point in space
  107736. */
  107737. export class AxesViewer {
  107738. private _xAxis;
  107739. private _yAxis;
  107740. private _zAxis;
  107741. private _scaleLinesFactor;
  107742. private _instanced;
  107743. /**
  107744. * Gets the hosting scene
  107745. */
  107746. scene: Scene;
  107747. /**
  107748. * Gets or sets a number used to scale line length
  107749. */
  107750. scaleLines: number;
  107751. /** Gets the node hierarchy used to render x-axis */
  107752. readonly xAxis: TransformNode;
  107753. /** Gets the node hierarchy used to render y-axis */
  107754. readonly yAxis: TransformNode;
  107755. /** Gets the node hierarchy used to render z-axis */
  107756. readonly zAxis: TransformNode;
  107757. /**
  107758. * Creates a new AxesViewer
  107759. * @param scene defines the hosting scene
  107760. * @param scaleLines defines a number used to scale line length (1 by default)
  107761. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  107762. * @param xAxis defines the node hierarchy used to render the x-axis
  107763. * @param yAxis defines the node hierarchy used to render the y-axis
  107764. * @param zAxis defines the node hierarchy used to render the z-axis
  107765. */
  107766. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  107767. /**
  107768. * Force the viewer to update
  107769. * @param position defines the position of the viewer
  107770. * @param xaxis defines the x axis of the viewer
  107771. * @param yaxis defines the y axis of the viewer
  107772. * @param zaxis defines the z axis of the viewer
  107773. */
  107774. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  107775. /**
  107776. * Creates an instance of this axes viewer.
  107777. * @returns a new axes viewer with instanced meshes
  107778. */
  107779. createInstance(): AxesViewer;
  107780. /** Releases resources */
  107781. dispose(): void;
  107782. private static _SetRenderingGroupId;
  107783. }
  107784. }
  107785. declare module BABYLON.Debug {
  107786. /**
  107787. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  107788. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  107789. */
  107790. export class BoneAxesViewer extends AxesViewer {
  107791. /**
  107792. * Gets or sets the target mesh where to display the axes viewer
  107793. */
  107794. mesh: Nullable<Mesh>;
  107795. /**
  107796. * Gets or sets the target bone where to display the axes viewer
  107797. */
  107798. bone: Nullable<Bone>;
  107799. /** Gets current position */
  107800. pos: Vector3;
  107801. /** Gets direction of X axis */
  107802. xaxis: Vector3;
  107803. /** Gets direction of Y axis */
  107804. yaxis: Vector3;
  107805. /** Gets direction of Z axis */
  107806. zaxis: Vector3;
  107807. /**
  107808. * Creates a new BoneAxesViewer
  107809. * @param scene defines the hosting scene
  107810. * @param bone defines the target bone
  107811. * @param mesh defines the target mesh
  107812. * @param scaleLines defines a scaling factor for line length (1 by default)
  107813. */
  107814. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  107815. /**
  107816. * Force the viewer to update
  107817. */
  107818. update(): void;
  107819. /** Releases resources */
  107820. dispose(): void;
  107821. }
  107822. }
  107823. declare module BABYLON {
  107824. /**
  107825. * Interface used to define scene explorer extensibility option
  107826. */
  107827. export interface IExplorerExtensibilityOption {
  107828. /**
  107829. * Define the option label
  107830. */
  107831. label: string;
  107832. /**
  107833. * Defines the action to execute on click
  107834. */
  107835. action: (entity: any) => void;
  107836. }
  107837. /**
  107838. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107839. */
  107840. export interface IExplorerExtensibilityGroup {
  107841. /**
  107842. * Defines a predicate to test if a given type mut be extended
  107843. */
  107844. predicate: (entity: any) => boolean;
  107845. /**
  107846. * Gets the list of options added to a type
  107847. */
  107848. entries: IExplorerExtensibilityOption[];
  107849. }
  107850. /**
  107851. * Interface used to define the options to use to create the Inspector
  107852. */
  107853. export interface IInspectorOptions {
  107854. /**
  107855. * Display in overlay mode (default: false)
  107856. */
  107857. overlay?: boolean;
  107858. /**
  107859. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  107860. */
  107861. globalRoot?: HTMLElement;
  107862. /**
  107863. * Display the Scene explorer
  107864. */
  107865. showExplorer?: boolean;
  107866. /**
  107867. * Display the property inspector
  107868. */
  107869. showInspector?: boolean;
  107870. /**
  107871. * Display in embed mode (both panes on the right)
  107872. */
  107873. embedMode?: boolean;
  107874. /**
  107875. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  107876. */
  107877. handleResize?: boolean;
  107878. /**
  107879. * Allow the panes to popup (default: true)
  107880. */
  107881. enablePopup?: boolean;
  107882. /**
  107883. * Allow the panes to be closed by users (default: true)
  107884. */
  107885. enableClose?: boolean;
  107886. /**
  107887. * Optional list of extensibility entries
  107888. */
  107889. explorerExtensibility?: IExplorerExtensibilityGroup[];
  107890. /**
  107891. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  107892. */
  107893. inspectorURL?: string;
  107894. }
  107895. interface Scene {
  107896. /**
  107897. * @hidden
  107898. * Backing field
  107899. */
  107900. _debugLayer: DebugLayer;
  107901. /**
  107902. * Gets the debug layer (aka Inspector) associated with the scene
  107903. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107904. */
  107905. debugLayer: DebugLayer;
  107906. }
  107907. /**
  107908. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107909. * what is happening in your scene
  107910. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107911. */
  107912. export class DebugLayer {
  107913. /**
  107914. * Define the url to get the inspector script from.
  107915. * By default it uses the babylonjs CDN.
  107916. * @ignoreNaming
  107917. */
  107918. static InspectorURL: string;
  107919. private _scene;
  107920. private BJSINSPECTOR;
  107921. private _onPropertyChangedObservable?;
  107922. /**
  107923. * Observable triggered when a property is changed through the inspector.
  107924. */
  107925. readonly onPropertyChangedObservable: any;
  107926. /**
  107927. * Instantiates a new debug layer.
  107928. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107929. * what is happening in your scene
  107930. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107931. * @param scene Defines the scene to inspect
  107932. */
  107933. constructor(scene: Scene);
  107934. /** Creates the inspector window. */
  107935. private _createInspector;
  107936. /**
  107937. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  107938. * @param entity defines the entity to select
  107939. * @param lineContainerTitle defines the specific block to highlight
  107940. */
  107941. select(entity: any, lineContainerTitle?: string): void;
  107942. /** Get the inspector from bundle or global */
  107943. private _getGlobalInspector;
  107944. /**
  107945. * Get if the inspector is visible or not.
  107946. * @returns true if visible otherwise, false
  107947. */
  107948. isVisible(): boolean;
  107949. /**
  107950. * Hide the inspector and close its window.
  107951. */
  107952. hide(): void;
  107953. /**
  107954. * Launch the debugLayer.
  107955. * @param config Define the configuration of the inspector
  107956. * @return a promise fulfilled when the debug layer is visible
  107957. */
  107958. show(config?: IInspectorOptions): Promise<DebugLayer>;
  107959. }
  107960. }
  107961. declare module BABYLON {
  107962. /**
  107963. * Class containing static functions to help procedurally build meshes
  107964. */
  107965. export class BoxBuilder {
  107966. /**
  107967. * Creates a box mesh
  107968. * * The parameter `size` sets the size (float) of each box side (default 1)
  107969. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107970. * * 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)
  107971. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107975. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107976. * @param name defines the name of the mesh
  107977. * @param options defines the options used to create the mesh
  107978. * @param scene defines the hosting scene
  107979. * @returns the box mesh
  107980. */
  107981. static CreateBox(name: string, options: {
  107982. size?: number;
  107983. width?: number;
  107984. height?: number;
  107985. depth?: number;
  107986. faceUV?: Vector4[];
  107987. faceColors?: Color4[];
  107988. sideOrientation?: number;
  107989. frontUVs?: Vector4;
  107990. backUVs?: Vector4;
  107991. wrap?: boolean;
  107992. topBaseAt?: number;
  107993. bottomBaseAt?: number;
  107994. updatable?: boolean;
  107995. }, scene?: Nullable<Scene>): Mesh;
  107996. }
  107997. }
  107998. declare module BABYLON {
  107999. /**
  108000. * Class containing static functions to help procedurally build meshes
  108001. */
  108002. export class SphereBuilder {
  108003. /**
  108004. * Creates a sphere mesh
  108005. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108006. * * 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`)
  108007. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108008. * * 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
  108009. * * 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)
  108010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108013. * @param name defines the name of the mesh
  108014. * @param options defines the options used to create the mesh
  108015. * @param scene defines the hosting scene
  108016. * @returns the sphere mesh
  108017. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108018. */
  108019. static CreateSphere(name: string, options: {
  108020. segments?: number;
  108021. diameter?: number;
  108022. diameterX?: number;
  108023. diameterY?: number;
  108024. diameterZ?: number;
  108025. arc?: number;
  108026. slice?: number;
  108027. sideOrientation?: number;
  108028. frontUVs?: Vector4;
  108029. backUVs?: Vector4;
  108030. updatable?: boolean;
  108031. }, scene?: Nullable<Scene>): Mesh;
  108032. }
  108033. }
  108034. declare module BABYLON.Debug {
  108035. /**
  108036. * Used to show the physics impostor around the specific mesh
  108037. */
  108038. export class PhysicsViewer {
  108039. /** @hidden */
  108040. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108041. /** @hidden */
  108042. protected _meshes: Array<Nullable<AbstractMesh>>;
  108043. /** @hidden */
  108044. protected _scene: Nullable<Scene>;
  108045. /** @hidden */
  108046. protected _numMeshes: number;
  108047. /** @hidden */
  108048. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108049. private _renderFunction;
  108050. private _utilityLayer;
  108051. private _debugBoxMesh;
  108052. private _debugSphereMesh;
  108053. private _debugCylinderMesh;
  108054. private _debugMaterial;
  108055. private _debugMeshMeshes;
  108056. /**
  108057. * Creates a new PhysicsViewer
  108058. * @param scene defines the hosting scene
  108059. */
  108060. constructor(scene: Scene);
  108061. /** @hidden */
  108062. protected _updateDebugMeshes(): void;
  108063. /**
  108064. * Renders a specified physic impostor
  108065. * @param impostor defines the impostor to render
  108066. * @param targetMesh defines the mesh represented by the impostor
  108067. * @returns the new debug mesh used to render the impostor
  108068. */
  108069. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108070. /**
  108071. * Hides a specified physic impostor
  108072. * @param impostor defines the impostor to hide
  108073. */
  108074. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108075. private _getDebugMaterial;
  108076. private _getDebugBoxMesh;
  108077. private _getDebugSphereMesh;
  108078. private _getDebugCylinderMesh;
  108079. private _getDebugMeshMesh;
  108080. private _getDebugMesh;
  108081. /** Releases all resources */
  108082. dispose(): void;
  108083. }
  108084. }
  108085. declare module BABYLON {
  108086. /**
  108087. * Class containing static functions to help procedurally build meshes
  108088. */
  108089. export class LinesBuilder {
  108090. /**
  108091. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108092. * * 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
  108093. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108094. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108095. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108096. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108097. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108098. * * 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
  108099. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108102. * @param name defines the name of the new line system
  108103. * @param options defines the options used to create the line system
  108104. * @param scene defines the hosting scene
  108105. * @returns a new line system mesh
  108106. */
  108107. static CreateLineSystem(name: string, options: {
  108108. lines: Vector3[][];
  108109. updatable?: boolean;
  108110. instance?: Nullable<LinesMesh>;
  108111. colors?: Nullable<Color4[][]>;
  108112. useVertexAlpha?: boolean;
  108113. }, scene: Nullable<Scene>): LinesMesh;
  108114. /**
  108115. * Creates a line mesh
  108116. * 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
  108117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108118. * * The parameter `points` is an array successive Vector3
  108119. * * 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
  108120. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108121. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108122. * * When updating an instance, remember that only point positions can change, not the number of points
  108123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108125. * @param name defines the name of the new line system
  108126. * @param options defines the options used to create the line system
  108127. * @param scene defines the hosting scene
  108128. * @returns a new line mesh
  108129. */
  108130. static CreateLines(name: string, options: {
  108131. points: Vector3[];
  108132. updatable?: boolean;
  108133. instance?: Nullable<LinesMesh>;
  108134. colors?: Color4[];
  108135. useVertexAlpha?: boolean;
  108136. }, scene?: Nullable<Scene>): LinesMesh;
  108137. /**
  108138. * Creates a dashed line mesh
  108139. * * 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
  108140. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108141. * * The parameter `points` is an array successive Vector3
  108142. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108143. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108144. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108145. * * 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
  108146. * * When updating an instance, remember that only point positions can change, not the number of points
  108147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108148. * @param name defines the name of the mesh
  108149. * @param options defines the options used to create the mesh
  108150. * @param scene defines the hosting scene
  108151. * @returns the dashed line mesh
  108152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108153. */
  108154. static CreateDashedLines(name: string, options: {
  108155. points: Vector3[];
  108156. dashSize?: number;
  108157. gapSize?: number;
  108158. dashNb?: number;
  108159. updatable?: boolean;
  108160. instance?: LinesMesh;
  108161. }, scene?: Nullable<Scene>): LinesMesh;
  108162. }
  108163. }
  108164. declare module BABYLON {
  108165. /**
  108166. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108167. * in order to better appreciate the issue one might have.
  108168. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108169. */
  108170. export class RayHelper {
  108171. /**
  108172. * Defines the ray we are currently tryin to visualize.
  108173. */
  108174. ray: Nullable<Ray>;
  108175. private _renderPoints;
  108176. private _renderLine;
  108177. private _renderFunction;
  108178. private _scene;
  108179. private _updateToMeshFunction;
  108180. private _attachedToMesh;
  108181. private _meshSpaceDirection;
  108182. private _meshSpaceOrigin;
  108183. /**
  108184. * Helper function to create a colored helper in a scene in one line.
  108185. * @param ray Defines the ray we are currently tryin to visualize
  108186. * @param scene Defines the scene the ray is used in
  108187. * @param color Defines the color we want to see the ray in
  108188. * @returns The newly created ray helper.
  108189. */
  108190. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  108191. /**
  108192. * Instantiate a new ray helper.
  108193. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108194. * in order to better appreciate the issue one might have.
  108195. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108196. * @param ray Defines the ray we are currently tryin to visualize
  108197. */
  108198. constructor(ray: Ray);
  108199. /**
  108200. * Shows the ray we are willing to debug.
  108201. * @param scene Defines the scene the ray needs to be rendered in
  108202. * @param color Defines the color the ray needs to be rendered in
  108203. */
  108204. show(scene: Scene, color?: Color3): void;
  108205. /**
  108206. * Hides the ray we are debugging.
  108207. */
  108208. hide(): void;
  108209. private _render;
  108210. /**
  108211. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  108212. * @param mesh Defines the mesh we want the helper attached to
  108213. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  108214. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  108215. * @param length Defines the length of the ray
  108216. */
  108217. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  108218. /**
  108219. * Detach the ray helper from the mesh it has previously been attached to.
  108220. */
  108221. detachFromMesh(): void;
  108222. private _updateToMesh;
  108223. /**
  108224. * Dispose the helper and release its associated resources.
  108225. */
  108226. dispose(): void;
  108227. }
  108228. }
  108229. declare module BABYLON.Debug {
  108230. /**
  108231. * Class used to render a debug view of a given skeleton
  108232. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  108233. */
  108234. export class SkeletonViewer {
  108235. /** defines the skeleton to render */
  108236. skeleton: Skeleton;
  108237. /** defines the mesh attached to the skeleton */
  108238. mesh: AbstractMesh;
  108239. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108240. autoUpdateBonesMatrices: boolean;
  108241. /** defines the rendering group id to use with the viewer */
  108242. renderingGroupId: number;
  108243. /** Gets or sets the color used to render the skeleton */
  108244. color: Color3;
  108245. private _scene;
  108246. private _debugLines;
  108247. private _debugMesh;
  108248. private _isEnabled;
  108249. private _renderFunction;
  108250. private _utilityLayer;
  108251. /**
  108252. * Returns the mesh used to render the bones
  108253. */
  108254. readonly debugMesh: Nullable<LinesMesh>;
  108255. /**
  108256. * Creates a new SkeletonViewer
  108257. * @param skeleton defines the skeleton to render
  108258. * @param mesh defines the mesh attached to the skeleton
  108259. * @param scene defines the hosting scene
  108260. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  108261. * @param renderingGroupId defines the rendering group id to use with the viewer
  108262. */
  108263. constructor(
  108264. /** defines the skeleton to render */
  108265. skeleton: Skeleton,
  108266. /** defines the mesh attached to the skeleton */
  108267. mesh: AbstractMesh, scene: Scene,
  108268. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108269. autoUpdateBonesMatrices?: boolean,
  108270. /** defines the rendering group id to use with the viewer */
  108271. renderingGroupId?: number);
  108272. /** Gets or sets a boolean indicating if the viewer is enabled */
  108273. isEnabled: boolean;
  108274. private _getBonePosition;
  108275. private _getLinesForBonesWithLength;
  108276. private _getLinesForBonesNoLength;
  108277. /** Update the viewer to sync with current skeleton state */
  108278. update(): void;
  108279. /** Release associated resources */
  108280. dispose(): void;
  108281. }
  108282. }
  108283. declare module BABYLON {
  108284. /**
  108285. * Options to create the null engine
  108286. */
  108287. export class NullEngineOptions {
  108288. /**
  108289. * Render width (Default: 512)
  108290. */
  108291. renderWidth: number;
  108292. /**
  108293. * Render height (Default: 256)
  108294. */
  108295. renderHeight: number;
  108296. /**
  108297. * Texture size (Default: 512)
  108298. */
  108299. textureSize: number;
  108300. /**
  108301. * If delta time between frames should be constant
  108302. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108303. */
  108304. deterministicLockstep: boolean;
  108305. /**
  108306. * Maximum about of steps between frames (Default: 4)
  108307. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108308. */
  108309. lockstepMaxSteps: number;
  108310. }
  108311. /**
  108312. * The null engine class provides support for headless version of babylon.js.
  108313. * This can be used in server side scenario or for testing purposes
  108314. */
  108315. export class NullEngine extends Engine {
  108316. private _options;
  108317. /**
  108318. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108319. */
  108320. isDeterministicLockStep(): boolean;
  108321. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  108322. getLockstepMaxSteps(): number;
  108323. /**
  108324. * Sets hardware scaling, used to save performance if needed
  108325. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108326. */
  108327. getHardwareScalingLevel(): number;
  108328. constructor(options?: NullEngineOptions);
  108329. createVertexBuffer(vertices: FloatArray): DataBuffer;
  108330. createIndexBuffer(indices: IndicesArray): DataBuffer;
  108331. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  108332. getRenderWidth(useScreen?: boolean): number;
  108333. getRenderHeight(useScreen?: boolean): number;
  108334. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  108335. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  108336. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108337. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108338. bindSamplers(effect: Effect): void;
  108339. enableEffect(effect: Effect): void;
  108340. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108341. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  108342. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  108343. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  108344. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  108345. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  108346. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  108347. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  108348. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  108349. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  108350. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  108351. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  108352. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  108353. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  108354. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108355. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108356. setFloat(uniform: WebGLUniformLocation, value: number): void;
  108357. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  108358. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  108359. setBool(uniform: WebGLUniformLocation, bool: number): void;
  108360. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  108361. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  108362. bindBuffers(vertexBuffers: {
  108363. [key: string]: VertexBuffer;
  108364. }, indexBuffer: DataBuffer, effect: Effect): void;
  108365. wipeCaches(bruteForce?: boolean): void;
  108366. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108367. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108368. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108369. /** @hidden */
  108370. _createTexture(): WebGLTexture;
  108371. /** @hidden */
  108372. _releaseTexture(texture: InternalTexture): void;
  108373. 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;
  108374. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  108375. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  108376. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  108377. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  108378. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  108379. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  108380. areAllEffectsReady(): boolean;
  108381. /**
  108382. * @hidden
  108383. * Get the current error code of the webGL context
  108384. * @returns the error code
  108385. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108386. */
  108387. getError(): number;
  108388. /** @hidden */
  108389. _getUnpackAlignement(): number;
  108390. /** @hidden */
  108391. _unpackFlipY(value: boolean): void;
  108392. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  108393. /**
  108394. * Updates a dynamic vertex buffer.
  108395. * @param vertexBuffer the vertex buffer to update
  108396. * @param data the data used to update the vertex buffer
  108397. * @param byteOffset the byte offset of the data (optional)
  108398. * @param byteLength the byte length of the data (optional)
  108399. */
  108400. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  108401. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  108402. /** @hidden */
  108403. _bindTexture(channel: number, texture: InternalTexture): void;
  108404. /** @hidden */
  108405. _releaseBuffer(buffer: DataBuffer): boolean;
  108406. releaseEffects(): void;
  108407. displayLoadingUI(): void;
  108408. hideLoadingUI(): void;
  108409. /** @hidden */
  108410. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108411. /** @hidden */
  108412. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108413. /** @hidden */
  108414. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108415. /** @hidden */
  108416. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  108417. }
  108418. }
  108419. declare module BABYLON {
  108420. /** @hidden */
  108421. export class _OcclusionDataStorage {
  108422. /** @hidden */
  108423. occlusionInternalRetryCounter: number;
  108424. /** @hidden */
  108425. isOcclusionQueryInProgress: boolean;
  108426. /** @hidden */
  108427. isOccluded: boolean;
  108428. /** @hidden */
  108429. occlusionRetryCount: number;
  108430. /** @hidden */
  108431. occlusionType: number;
  108432. /** @hidden */
  108433. occlusionQueryAlgorithmType: number;
  108434. }
  108435. interface Engine {
  108436. /**
  108437. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  108438. * @return the new query
  108439. */
  108440. createQuery(): WebGLQuery;
  108441. /**
  108442. * Delete and release a webGL query
  108443. * @param query defines the query to delete
  108444. * @return the current engine
  108445. */
  108446. deleteQuery(query: WebGLQuery): Engine;
  108447. /**
  108448. * Check if a given query has resolved and got its value
  108449. * @param query defines the query to check
  108450. * @returns true if the query got its value
  108451. */
  108452. isQueryResultAvailable(query: WebGLQuery): boolean;
  108453. /**
  108454. * Gets the value of a given query
  108455. * @param query defines the query to check
  108456. * @returns the value of the query
  108457. */
  108458. getQueryResult(query: WebGLQuery): number;
  108459. /**
  108460. * Initiates an occlusion query
  108461. * @param algorithmType defines the algorithm to use
  108462. * @param query defines the query to use
  108463. * @returns the current engine
  108464. * @see http://doc.babylonjs.com/features/occlusionquery
  108465. */
  108466. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  108467. /**
  108468. * Ends an occlusion query
  108469. * @see http://doc.babylonjs.com/features/occlusionquery
  108470. * @param algorithmType defines the algorithm to use
  108471. * @returns the current engine
  108472. */
  108473. endOcclusionQuery(algorithmType: number): Engine;
  108474. /**
  108475. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  108476. * Please note that only one query can be issued at a time
  108477. * @returns a time token used to track the time span
  108478. */
  108479. startTimeQuery(): Nullable<_TimeToken>;
  108480. /**
  108481. * Ends a time query
  108482. * @param token defines the token used to measure the time span
  108483. * @returns the time spent (in ns)
  108484. */
  108485. endTimeQuery(token: _TimeToken): int;
  108486. /** @hidden */
  108487. _currentNonTimestampToken: Nullable<_TimeToken>;
  108488. /** @hidden */
  108489. _createTimeQuery(): WebGLQuery;
  108490. /** @hidden */
  108491. _deleteTimeQuery(query: WebGLQuery): void;
  108492. /** @hidden */
  108493. _getGlAlgorithmType(algorithmType: number): number;
  108494. /** @hidden */
  108495. _getTimeQueryResult(query: WebGLQuery): any;
  108496. /** @hidden */
  108497. _getTimeQueryAvailability(query: WebGLQuery): any;
  108498. }
  108499. interface AbstractMesh {
  108500. /**
  108501. * Backing filed
  108502. * @hidden
  108503. */
  108504. __occlusionDataStorage: _OcclusionDataStorage;
  108505. /**
  108506. * Access property
  108507. * @hidden
  108508. */
  108509. _occlusionDataStorage: _OcclusionDataStorage;
  108510. /**
  108511. * 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.
  108512. * The default value is -1 which means don't break the query and wait till the result
  108513. * @see http://doc.babylonjs.com/features/occlusionquery
  108514. */
  108515. occlusionRetryCount: number;
  108516. /**
  108517. * 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:
  108518. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  108519. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  108520. * * 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.
  108521. * @see http://doc.babylonjs.com/features/occlusionquery
  108522. */
  108523. occlusionType: number;
  108524. /**
  108525. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  108526. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  108527. * * 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.
  108528. * @see http://doc.babylonjs.com/features/occlusionquery
  108529. */
  108530. occlusionQueryAlgorithmType: number;
  108531. /**
  108532. * 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
  108533. * @see http://doc.babylonjs.com/features/occlusionquery
  108534. */
  108535. isOccluded: boolean;
  108536. /**
  108537. * Flag to check the progress status of the query
  108538. * @see http://doc.babylonjs.com/features/occlusionquery
  108539. */
  108540. isOcclusionQueryInProgress: boolean;
  108541. }
  108542. }
  108543. declare module BABYLON {
  108544. /** @hidden */
  108545. export var _forceTransformFeedbackToBundle: boolean;
  108546. interface Engine {
  108547. /**
  108548. * Creates a webGL transform feedback object
  108549. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  108550. * @returns the webGL transform feedback object
  108551. */
  108552. createTransformFeedback(): WebGLTransformFeedback;
  108553. /**
  108554. * Delete a webGL transform feedback object
  108555. * @param value defines the webGL transform feedback object to delete
  108556. */
  108557. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  108558. /**
  108559. * Bind a webGL transform feedback object to the webgl context
  108560. * @param value defines the webGL transform feedback object to bind
  108561. */
  108562. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  108563. /**
  108564. * Begins a transform feedback operation
  108565. * @param usePoints defines if points or triangles must be used
  108566. */
  108567. beginTransformFeedback(usePoints: boolean): void;
  108568. /**
  108569. * Ends a transform feedback operation
  108570. */
  108571. endTransformFeedback(): void;
  108572. /**
  108573. * Specify the varyings to use with transform feedback
  108574. * @param program defines the associated webGL program
  108575. * @param value defines the list of strings representing the varying names
  108576. */
  108577. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  108578. /**
  108579. * Bind a webGL buffer for a transform feedback operation
  108580. * @param value defines the webGL buffer to bind
  108581. */
  108582. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  108583. }
  108584. }
  108585. declare module BABYLON {
  108586. /**
  108587. * Creation options of the multi render target texture.
  108588. */
  108589. export interface IMultiRenderTargetOptions {
  108590. /**
  108591. * Define if the texture needs to create mip maps after render.
  108592. */
  108593. generateMipMaps?: boolean;
  108594. /**
  108595. * Define the types of all the draw buffers we want to create
  108596. */
  108597. types?: number[];
  108598. /**
  108599. * Define the sampling modes of all the draw buffers we want to create
  108600. */
  108601. samplingModes?: number[];
  108602. /**
  108603. * Define if a depth buffer is required
  108604. */
  108605. generateDepthBuffer?: boolean;
  108606. /**
  108607. * Define if a stencil buffer is required
  108608. */
  108609. generateStencilBuffer?: boolean;
  108610. /**
  108611. * Define if a depth texture is required instead of a depth buffer
  108612. */
  108613. generateDepthTexture?: boolean;
  108614. /**
  108615. * Define the number of desired draw buffers
  108616. */
  108617. textureCount?: number;
  108618. /**
  108619. * Define if aspect ratio should be adapted to the texture or stay the scene one
  108620. */
  108621. doNotChangeAspectRatio?: boolean;
  108622. /**
  108623. * Define the default type of the buffers we are creating
  108624. */
  108625. defaultType?: number;
  108626. }
  108627. /**
  108628. * A multi render target, like a render target provides the ability to render to a texture.
  108629. * Unlike the render target, it can render to several draw buffers in one draw.
  108630. * This is specially interesting in deferred rendering or for any effects requiring more than
  108631. * just one color from a single pass.
  108632. */
  108633. export class MultiRenderTarget extends RenderTargetTexture {
  108634. private _internalTextures;
  108635. private _textures;
  108636. private _multiRenderTargetOptions;
  108637. /**
  108638. * Get if draw buffers are currently supported by the used hardware and browser.
  108639. */
  108640. readonly isSupported: boolean;
  108641. /**
  108642. * Get the list of textures generated by the multi render target.
  108643. */
  108644. readonly textures: Texture[];
  108645. /**
  108646. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  108647. */
  108648. readonly depthTexture: Texture;
  108649. /**
  108650. * Set the wrapping mode on U of all the textures we are rendering to.
  108651. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108652. */
  108653. wrapU: number;
  108654. /**
  108655. * Set the wrapping mode on V of all the textures we are rendering to.
  108656. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108657. */
  108658. wrapV: number;
  108659. /**
  108660. * Instantiate a new multi render target texture.
  108661. * A multi render target, like a render target provides the ability to render to a texture.
  108662. * Unlike the render target, it can render to several draw buffers in one draw.
  108663. * This is specially interesting in deferred rendering or for any effects requiring more than
  108664. * just one color from a single pass.
  108665. * @param name Define the name of the texture
  108666. * @param size Define the size of the buffers to render to
  108667. * @param count Define the number of target we are rendering into
  108668. * @param scene Define the scene the texture belongs to
  108669. * @param options Define the options used to create the multi render target
  108670. */
  108671. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  108672. /** @hidden */
  108673. _rebuild(): void;
  108674. private _createInternalTextures;
  108675. private _createTextures;
  108676. /**
  108677. * Define the number of samples used if MSAA is enabled.
  108678. */
  108679. samples: number;
  108680. /**
  108681. * Resize all the textures in the multi render target.
  108682. * Be carrefull as it will recreate all the data in the new texture.
  108683. * @param size Define the new size
  108684. */
  108685. resize(size: any): void;
  108686. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  108687. /**
  108688. * Dispose the render targets and their associated resources
  108689. */
  108690. dispose(): void;
  108691. /**
  108692. * Release all the underlying texture used as draw buffers.
  108693. */
  108694. releaseInternalTextures(): void;
  108695. }
  108696. }
  108697. declare module BABYLON {
  108698. interface Engine {
  108699. /**
  108700. * Unbind a list of render target textures from the webGL context
  108701. * This is used only when drawBuffer extension or webGL2 are active
  108702. * @param textures defines the render target textures to unbind
  108703. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  108704. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  108705. */
  108706. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  108707. /**
  108708. * Create a multi render target texture
  108709. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  108710. * @param size defines the size of the texture
  108711. * @param options defines the creation options
  108712. * @returns the cube texture as an InternalTexture
  108713. */
  108714. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  108715. /**
  108716. * Update the sample count for a given multiple render target texture
  108717. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108718. * @param textures defines the textures to update
  108719. * @param samples defines the sample count to set
  108720. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108721. */
  108722. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  108723. }
  108724. }
  108725. declare module BABYLON {
  108726. /**
  108727. * Gather the list of clipboard event types as constants.
  108728. */
  108729. export class ClipboardEventTypes {
  108730. /**
  108731. * The clipboard event is fired when a copy command is active (pressed).
  108732. */
  108733. static readonly COPY: number;
  108734. /**
  108735. * The clipboard event is fired when a cut command is active (pressed).
  108736. */
  108737. static readonly CUT: number;
  108738. /**
  108739. * The clipboard event is fired when a paste command is active (pressed).
  108740. */
  108741. static readonly PASTE: number;
  108742. }
  108743. /**
  108744. * This class is used to store clipboard related info for the onClipboardObservable event.
  108745. */
  108746. export class ClipboardInfo {
  108747. /**
  108748. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108749. */
  108750. type: number;
  108751. /**
  108752. * Defines the related dom event
  108753. */
  108754. event: ClipboardEvent;
  108755. /**
  108756. *Creates an instance of ClipboardInfo.
  108757. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  108758. * @param event Defines the related dom event
  108759. */
  108760. constructor(
  108761. /**
  108762. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108763. */
  108764. type: number,
  108765. /**
  108766. * Defines the related dom event
  108767. */
  108768. event: ClipboardEvent);
  108769. /**
  108770. * Get the clipboard event's type from the keycode.
  108771. * @param keyCode Defines the keyCode for the current keyboard event.
  108772. * @return {number}
  108773. */
  108774. static GetTypeFromCharacter(keyCode: number): number;
  108775. }
  108776. }
  108777. declare module BABYLON {
  108778. /**
  108779. * Google Daydream controller
  108780. */
  108781. export class DaydreamController extends WebVRController {
  108782. /**
  108783. * Base Url for the controller model.
  108784. */
  108785. static MODEL_BASE_URL: string;
  108786. /**
  108787. * File name for the controller model.
  108788. */
  108789. static MODEL_FILENAME: string;
  108790. /**
  108791. * Gamepad Id prefix used to identify Daydream Controller.
  108792. */
  108793. static readonly GAMEPAD_ID_PREFIX: string;
  108794. /**
  108795. * Creates a new DaydreamController from a gamepad
  108796. * @param vrGamepad the gamepad that the controller should be created from
  108797. */
  108798. constructor(vrGamepad: any);
  108799. /**
  108800. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108801. * @param scene scene in which to add meshes
  108802. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108803. */
  108804. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108805. /**
  108806. * Called once for each button that changed state since the last frame
  108807. * @param buttonIdx Which button index changed
  108808. * @param state New state of the button
  108809. * @param changes Which properties on the state changed since last frame
  108810. */
  108811. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108812. }
  108813. }
  108814. declare module BABYLON {
  108815. /**
  108816. * Gear VR Controller
  108817. */
  108818. export class GearVRController extends WebVRController {
  108819. /**
  108820. * Base Url for the controller model.
  108821. */
  108822. static MODEL_BASE_URL: string;
  108823. /**
  108824. * File name for the controller model.
  108825. */
  108826. static MODEL_FILENAME: string;
  108827. /**
  108828. * Gamepad Id prefix used to identify this controller.
  108829. */
  108830. static readonly GAMEPAD_ID_PREFIX: string;
  108831. private readonly _buttonIndexToObservableNameMap;
  108832. /**
  108833. * Creates a new GearVRController from a gamepad
  108834. * @param vrGamepad the gamepad that the controller should be created from
  108835. */
  108836. constructor(vrGamepad: any);
  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): void;
  108843. /**
  108844. * Called once for each button that changed state since the last frame
  108845. * @param buttonIdx Which button index changed
  108846. * @param state New state of the button
  108847. * @param changes Which properties on the state changed since last frame
  108848. */
  108849. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108850. }
  108851. }
  108852. declare module BABYLON {
  108853. /**
  108854. * Class containing static functions to help procedurally build meshes
  108855. */
  108856. export class PolyhedronBuilder {
  108857. /**
  108858. * Creates a polyhedron mesh
  108859. * * 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
  108860. * * The parameter `size` (positive float, default 1) sets the polygon size
  108861. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108862. * * 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`
  108863. * * 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
  108864. * * 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)`)
  108865. * * 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
  108866. * * 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
  108867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108870. * @param name defines the name of the mesh
  108871. * @param options defines the options used to create the mesh
  108872. * @param scene defines the hosting scene
  108873. * @returns the polyhedron mesh
  108874. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108875. */
  108876. static CreatePolyhedron(name: string, options: {
  108877. type?: number;
  108878. size?: number;
  108879. sizeX?: number;
  108880. sizeY?: number;
  108881. sizeZ?: number;
  108882. custom?: any;
  108883. faceUV?: Vector4[];
  108884. faceColors?: Color4[];
  108885. flat?: boolean;
  108886. updatable?: boolean;
  108887. sideOrientation?: number;
  108888. frontUVs?: Vector4;
  108889. backUVs?: Vector4;
  108890. }, scene?: Nullable<Scene>): Mesh;
  108891. }
  108892. }
  108893. declare module BABYLON {
  108894. /**
  108895. * Gizmo that enables scaling a mesh along 3 axis
  108896. */
  108897. export class ScaleGizmo extends Gizmo {
  108898. /**
  108899. * Internal gizmo used for interactions on the x axis
  108900. */
  108901. xGizmo: AxisScaleGizmo;
  108902. /**
  108903. * Internal gizmo used for interactions on the y axis
  108904. */
  108905. yGizmo: AxisScaleGizmo;
  108906. /**
  108907. * Internal gizmo used for interactions on the z axis
  108908. */
  108909. zGizmo: AxisScaleGizmo;
  108910. /**
  108911. * Internal gizmo used to scale all axis equally
  108912. */
  108913. uniformScaleGizmo: AxisScaleGizmo;
  108914. private _meshAttached;
  108915. private _updateGizmoRotationToMatchAttachedMesh;
  108916. private _snapDistance;
  108917. private _scaleRatio;
  108918. private _uniformScalingMesh;
  108919. private _octahedron;
  108920. /** Fires an event when any of it's sub gizmos are dragged */
  108921. onDragStartObservable: Observable<unknown>;
  108922. /** Fires an event when any of it's sub gizmos are released from dragging */
  108923. onDragEndObservable: Observable<unknown>;
  108924. attachedMesh: Nullable<AbstractMesh>;
  108925. /**
  108926. * Creates a ScaleGizmo
  108927. * @param gizmoLayer The utility layer the gizmo will be added to
  108928. */
  108929. constructor(gizmoLayer?: UtilityLayerRenderer);
  108930. updateGizmoRotationToMatchAttachedMesh: boolean;
  108931. /**
  108932. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108933. */
  108934. snapDistance: number;
  108935. /**
  108936. * Ratio for the scale of the gizmo (Default: 1)
  108937. */
  108938. scaleRatio: number;
  108939. /**
  108940. * Disposes of the gizmo
  108941. */
  108942. dispose(): void;
  108943. }
  108944. }
  108945. declare module BABYLON {
  108946. /**
  108947. * Single axis scale gizmo
  108948. */
  108949. export class AxisScaleGizmo extends Gizmo {
  108950. /**
  108951. * Drag behavior responsible for the gizmos dragging interactions
  108952. */
  108953. dragBehavior: PointerDragBehavior;
  108954. private _pointerObserver;
  108955. /**
  108956. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108957. */
  108958. snapDistance: number;
  108959. /**
  108960. * Event that fires each time the gizmo snaps to a new location.
  108961. * * snapDistance is the the change in distance
  108962. */
  108963. onSnapObservable: Observable<{
  108964. snapDistance: number;
  108965. }>;
  108966. /**
  108967. * If the scaling operation should be done on all axis (default: false)
  108968. */
  108969. uniformScaling: boolean;
  108970. private _isEnabled;
  108971. private _parent;
  108972. private _arrow;
  108973. private _coloredMaterial;
  108974. private _hoverMaterial;
  108975. /**
  108976. * Creates an AxisScaleGizmo
  108977. * @param gizmoLayer The utility layer the gizmo will be added to
  108978. * @param dragAxis The axis which the gizmo will be able to scale on
  108979. * @param color The color of the gizmo
  108980. */
  108981. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  108982. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108983. /**
  108984. * If the gizmo is enabled
  108985. */
  108986. isEnabled: boolean;
  108987. /**
  108988. * Disposes of the gizmo
  108989. */
  108990. dispose(): void;
  108991. /**
  108992. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108993. * @param mesh The mesh to replace the default mesh of the gizmo
  108994. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  108995. */
  108996. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  108997. }
  108998. }
  108999. declare module BABYLON {
  109000. /**
  109001. * Bounding box gizmo
  109002. */
  109003. export class BoundingBoxGizmo extends Gizmo {
  109004. private _lineBoundingBox;
  109005. private _rotateSpheresParent;
  109006. private _scaleBoxesParent;
  109007. private _boundingDimensions;
  109008. private _renderObserver;
  109009. private _pointerObserver;
  109010. private _scaleDragSpeed;
  109011. private _tmpQuaternion;
  109012. private _tmpVector;
  109013. private _tmpRotationMatrix;
  109014. /**
  109015. * 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)
  109016. */
  109017. ignoreChildren: boolean;
  109018. /**
  109019. * 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)
  109020. */
  109021. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  109022. /**
  109023. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  109024. */
  109025. rotationSphereSize: number;
  109026. /**
  109027. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  109028. */
  109029. scaleBoxSize: number;
  109030. /**
  109031. * 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)
  109032. */
  109033. fixedDragMeshScreenSize: boolean;
  109034. /**
  109035. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  109036. */
  109037. fixedDragMeshScreenSizeDistanceFactor: number;
  109038. /**
  109039. * Fired when a rotation sphere or scale box is dragged
  109040. */
  109041. onDragStartObservable: Observable<{}>;
  109042. /**
  109043. * Fired when a scale box is dragged
  109044. */
  109045. onScaleBoxDragObservable: Observable<{}>;
  109046. /**
  109047. * Fired when a scale box drag is ended
  109048. */
  109049. onScaleBoxDragEndObservable: Observable<{}>;
  109050. /**
  109051. * Fired when a rotation sphere is dragged
  109052. */
  109053. onRotationSphereDragObservable: Observable<{}>;
  109054. /**
  109055. * Fired when a rotation sphere drag is ended
  109056. */
  109057. onRotationSphereDragEndObservable: Observable<{}>;
  109058. /**
  109059. * 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)
  109060. */
  109061. scalePivot: Nullable<Vector3>;
  109062. /**
  109063. * Mesh used as a pivot to rotate the attached mesh
  109064. */
  109065. private _anchorMesh;
  109066. private _existingMeshScale;
  109067. private _dragMesh;
  109068. private pointerDragBehavior;
  109069. private coloredMaterial;
  109070. private hoverColoredMaterial;
  109071. /**
  109072. * Sets the color of the bounding box gizmo
  109073. * @param color the color to set
  109074. */
  109075. setColor(color: Color3): void;
  109076. /**
  109077. * Creates an BoundingBoxGizmo
  109078. * @param gizmoLayer The utility layer the gizmo will be added to
  109079. * @param color The color of the gizmo
  109080. */
  109081. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  109082. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109083. private _selectNode;
  109084. /**
  109085. * Updates the bounding box information for the Gizmo
  109086. */
  109087. updateBoundingBox(): void;
  109088. private _updateRotationSpheres;
  109089. private _updateScaleBoxes;
  109090. /**
  109091. * Enables rotation on the specified axis and disables rotation on the others
  109092. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  109093. */
  109094. setEnabledRotationAxis(axis: string): void;
  109095. /**
  109096. * Enables/disables scaling
  109097. * @param enable if scaling should be enabled
  109098. */
  109099. setEnabledScaling(enable: boolean): void;
  109100. private _updateDummy;
  109101. /**
  109102. * Enables a pointer drag behavior on the bounding box of the gizmo
  109103. */
  109104. enableDragBehavior(): void;
  109105. /**
  109106. * Disposes of the gizmo
  109107. */
  109108. dispose(): void;
  109109. /**
  109110. * 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)
  109111. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  109112. * @returns the bounding box mesh with the passed in mesh as a child
  109113. */
  109114. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  109115. /**
  109116. * CustomMeshes are not supported by this gizmo
  109117. * @param mesh The mesh to replace the default mesh of the gizmo
  109118. */
  109119. setCustomMesh(mesh: Mesh): void;
  109120. }
  109121. }
  109122. declare module BABYLON {
  109123. /**
  109124. * Single plane rotation gizmo
  109125. */
  109126. export class PlaneRotationGizmo extends Gizmo {
  109127. /**
  109128. * Drag behavior responsible for the gizmos dragging interactions
  109129. */
  109130. dragBehavior: PointerDragBehavior;
  109131. private _pointerObserver;
  109132. /**
  109133. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  109134. */
  109135. snapDistance: number;
  109136. /**
  109137. * Event that fires each time the gizmo snaps to a new location.
  109138. * * snapDistance is the the change in distance
  109139. */
  109140. onSnapObservable: Observable<{
  109141. snapDistance: number;
  109142. }>;
  109143. private _isEnabled;
  109144. private _parent;
  109145. /**
  109146. * Creates a PlaneRotationGizmo
  109147. * @param gizmoLayer The utility layer the gizmo will be added to
  109148. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  109149. * @param color The color of the gizmo
  109150. * @param tessellation Amount of tessellation to be used when creating rotation circles
  109151. * @param useEulerRotation Use and update Euler angle instead of quaternion
  109152. */
  109153. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  109154. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109155. /**
  109156. * If the gizmo is enabled
  109157. */
  109158. isEnabled: boolean;
  109159. /**
  109160. * Disposes of the gizmo
  109161. */
  109162. dispose(): void;
  109163. }
  109164. }
  109165. declare module BABYLON {
  109166. /**
  109167. * Gizmo that enables rotating a mesh along 3 axis
  109168. */
  109169. export class RotationGizmo extends Gizmo {
  109170. /**
  109171. * Internal gizmo used for interactions on the x axis
  109172. */
  109173. xGizmo: PlaneRotationGizmo;
  109174. /**
  109175. * Internal gizmo used for interactions on the y axis
  109176. */
  109177. yGizmo: PlaneRotationGizmo;
  109178. /**
  109179. * Internal gizmo used for interactions on the z axis
  109180. */
  109181. zGizmo: PlaneRotationGizmo;
  109182. /** Fires an event when any of it's sub gizmos are dragged */
  109183. onDragStartObservable: Observable<unknown>;
  109184. /** Fires an event when any of it's sub gizmos are released from dragging */
  109185. onDragEndObservable: Observable<unknown>;
  109186. private _meshAttached;
  109187. attachedMesh: Nullable<AbstractMesh>;
  109188. /**
  109189. * Creates a RotationGizmo
  109190. * @param gizmoLayer The utility layer the gizmo will be added to
  109191. * @param tessellation Amount of tessellation to be used when creating rotation circles
  109192. * @param useEulerRotation Use and update Euler angle instead of quaternion
  109193. */
  109194. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  109195. updateGizmoRotationToMatchAttachedMesh: boolean;
  109196. /**
  109197. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109198. */
  109199. snapDistance: number;
  109200. /**
  109201. * Ratio for the scale of the gizmo (Default: 1)
  109202. */
  109203. scaleRatio: number;
  109204. /**
  109205. * Disposes of the gizmo
  109206. */
  109207. dispose(): void;
  109208. /**
  109209. * CustomMeshes are not supported by this gizmo
  109210. * @param mesh The mesh to replace the default mesh of the gizmo
  109211. */
  109212. setCustomMesh(mesh: Mesh): void;
  109213. }
  109214. }
  109215. declare module BABYLON {
  109216. /**
  109217. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  109218. */
  109219. export class GizmoManager implements IDisposable {
  109220. private scene;
  109221. /**
  109222. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  109223. */
  109224. gizmos: {
  109225. positionGizmo: Nullable<PositionGizmo>;
  109226. rotationGizmo: Nullable<RotationGizmo>;
  109227. scaleGizmo: Nullable<ScaleGizmo>;
  109228. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  109229. };
  109230. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  109231. clearGizmoOnEmptyPointerEvent: boolean;
  109232. /** Fires an event when the manager is attached to a mesh */
  109233. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  109234. private _gizmosEnabled;
  109235. private _pointerObserver;
  109236. private _attachedMesh;
  109237. private _boundingBoxColor;
  109238. private _defaultUtilityLayer;
  109239. private _defaultKeepDepthUtilityLayer;
  109240. /**
  109241. * When bounding box gizmo is enabled, this can be used to track drag/end events
  109242. */
  109243. boundingBoxDragBehavior: SixDofDragBehavior;
  109244. /**
  109245. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  109246. */
  109247. attachableMeshes: Nullable<Array<AbstractMesh>>;
  109248. /**
  109249. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  109250. */
  109251. usePointerToAttachGizmos: boolean;
  109252. /**
  109253. * Utility layer that the bounding box gizmo belongs to
  109254. */
  109255. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  109256. /**
  109257. * Utility layer that all gizmos besides bounding box belong to
  109258. */
  109259. readonly utilityLayer: UtilityLayerRenderer;
  109260. /**
  109261. * Instatiates a gizmo manager
  109262. * @param scene the scene to overlay the gizmos on top of
  109263. */
  109264. constructor(scene: Scene);
  109265. /**
  109266. * Attaches a set of gizmos to the specified mesh
  109267. * @param mesh The mesh the gizmo's should be attached to
  109268. */
  109269. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  109270. /**
  109271. * If the position gizmo is enabled
  109272. */
  109273. positionGizmoEnabled: boolean;
  109274. /**
  109275. * If the rotation gizmo is enabled
  109276. */
  109277. rotationGizmoEnabled: boolean;
  109278. /**
  109279. * If the scale gizmo is enabled
  109280. */
  109281. scaleGizmoEnabled: boolean;
  109282. /**
  109283. * If the boundingBox gizmo is enabled
  109284. */
  109285. boundingBoxGizmoEnabled: boolean;
  109286. /**
  109287. * Disposes of the gizmo manager
  109288. */
  109289. dispose(): void;
  109290. }
  109291. }
  109292. declare module BABYLON {
  109293. /**
  109294. * A directional light is defined by a direction (what a surprise!).
  109295. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  109296. * 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.
  109297. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109298. */
  109299. export class DirectionalLight extends ShadowLight {
  109300. private _shadowFrustumSize;
  109301. /**
  109302. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  109303. */
  109304. /**
  109305. * Specifies a fix frustum size for the shadow generation.
  109306. */
  109307. shadowFrustumSize: number;
  109308. private _shadowOrthoScale;
  109309. /**
  109310. * Gets the shadow projection scale against the optimal computed one.
  109311. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109312. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109313. */
  109314. /**
  109315. * Sets the shadow projection scale against the optimal computed one.
  109316. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109317. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109318. */
  109319. shadowOrthoScale: number;
  109320. /**
  109321. * Automatically compute the projection matrix to best fit (including all the casters)
  109322. * on each frame.
  109323. */
  109324. autoUpdateExtends: boolean;
  109325. private _orthoLeft;
  109326. private _orthoRight;
  109327. private _orthoTop;
  109328. private _orthoBottom;
  109329. /**
  109330. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  109331. * The directional light is emitted from everywhere in the given direction.
  109332. * It can cast shadows.
  109333. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109334. * @param name The friendly name of the light
  109335. * @param direction The direction of the light
  109336. * @param scene The scene the light belongs to
  109337. */
  109338. constructor(name: string, direction: Vector3, scene: Scene);
  109339. /**
  109340. * Returns the string "DirectionalLight".
  109341. * @return The class name
  109342. */
  109343. getClassName(): string;
  109344. /**
  109345. * Returns the integer 1.
  109346. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109347. */
  109348. getTypeID(): number;
  109349. /**
  109350. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  109351. * Returns the DirectionalLight Shadow projection matrix.
  109352. */
  109353. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109354. /**
  109355. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  109356. * Returns the DirectionalLight Shadow projection matrix.
  109357. */
  109358. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  109359. /**
  109360. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  109361. * Returns the DirectionalLight Shadow projection matrix.
  109362. */
  109363. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109364. protected _buildUniformLayout(): void;
  109365. /**
  109366. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  109367. * @param effect The effect to update
  109368. * @param lightIndex The index of the light in the effect to update
  109369. * @returns The directional light
  109370. */
  109371. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  109372. /**
  109373. * Gets the minZ used for shadow according to both the scene and the light.
  109374. *
  109375. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109376. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109377. * @param activeCamera The camera we are returning the min for
  109378. * @returns the depth min z
  109379. */
  109380. getDepthMinZ(activeCamera: Camera): number;
  109381. /**
  109382. * Gets the maxZ used for shadow according to both the scene and the light.
  109383. *
  109384. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109385. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109386. * @param activeCamera The camera we are returning the max for
  109387. * @returns the depth max z
  109388. */
  109389. getDepthMaxZ(activeCamera: Camera): number;
  109390. /**
  109391. * Prepares the list of defines specific to the light type.
  109392. * @param defines the list of defines
  109393. * @param lightIndex defines the index of the light for the effect
  109394. */
  109395. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109396. }
  109397. }
  109398. declare module BABYLON {
  109399. /**
  109400. * Class containing static functions to help procedurally build meshes
  109401. */
  109402. export class HemisphereBuilder {
  109403. /**
  109404. * Creates a hemisphere mesh
  109405. * @param name defines the name of the mesh
  109406. * @param options defines the options used to create the mesh
  109407. * @param scene defines the hosting scene
  109408. * @returns the hemisphere mesh
  109409. */
  109410. static CreateHemisphere(name: string, options: {
  109411. segments?: number;
  109412. diameter?: number;
  109413. sideOrientation?: number;
  109414. }, scene: any): Mesh;
  109415. }
  109416. }
  109417. declare module BABYLON {
  109418. /**
  109419. * A spot light is defined by a position, a direction, an angle, and an exponent.
  109420. * These values define a cone of light starting from the position, emitting toward the direction.
  109421. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  109422. * and the exponent defines the speed of the decay of the light with distance (reach).
  109423. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109424. */
  109425. export class SpotLight extends ShadowLight {
  109426. private _angle;
  109427. private _innerAngle;
  109428. private _cosHalfAngle;
  109429. private _lightAngleScale;
  109430. private _lightAngleOffset;
  109431. /**
  109432. * Gets the cone angle of the spot light in Radians.
  109433. */
  109434. /**
  109435. * Sets the cone angle of the spot light in Radians.
  109436. */
  109437. angle: number;
  109438. /**
  109439. * Only used in gltf falloff mode, this defines the angle where
  109440. * the directional falloff will start before cutting at angle which could be seen
  109441. * as outer angle.
  109442. */
  109443. /**
  109444. * Only used in gltf falloff mode, this defines the angle where
  109445. * the directional falloff will start before cutting at angle which could be seen
  109446. * as outer angle.
  109447. */
  109448. innerAngle: number;
  109449. private _shadowAngleScale;
  109450. /**
  109451. * Allows scaling the angle of the light for shadow generation only.
  109452. */
  109453. /**
  109454. * Allows scaling the angle of the light for shadow generation only.
  109455. */
  109456. shadowAngleScale: number;
  109457. /**
  109458. * The light decay speed with the distance from the emission spot.
  109459. */
  109460. exponent: number;
  109461. private _projectionTextureMatrix;
  109462. /**
  109463. * Allows reading the projecton texture
  109464. */
  109465. readonly projectionTextureMatrix: Matrix;
  109466. protected _projectionTextureLightNear: number;
  109467. /**
  109468. * Gets the near clip of the Spotlight for texture projection.
  109469. */
  109470. /**
  109471. * Sets the near clip of the Spotlight for texture projection.
  109472. */
  109473. projectionTextureLightNear: number;
  109474. protected _projectionTextureLightFar: number;
  109475. /**
  109476. * Gets the far clip of the Spotlight for texture projection.
  109477. */
  109478. /**
  109479. * Sets the far clip of the Spotlight for texture projection.
  109480. */
  109481. projectionTextureLightFar: number;
  109482. protected _projectionTextureUpDirection: Vector3;
  109483. /**
  109484. * Gets the Up vector of the Spotlight for texture projection.
  109485. */
  109486. /**
  109487. * Sets the Up vector of the Spotlight for texture projection.
  109488. */
  109489. projectionTextureUpDirection: Vector3;
  109490. private _projectionTexture;
  109491. /**
  109492. * Gets the projection texture of the light.
  109493. */
  109494. /**
  109495. * Sets the projection texture of the light.
  109496. */
  109497. projectionTexture: Nullable<BaseTexture>;
  109498. private _projectionTextureViewLightDirty;
  109499. private _projectionTextureProjectionLightDirty;
  109500. private _projectionTextureDirty;
  109501. private _projectionTextureViewTargetVector;
  109502. private _projectionTextureViewLightMatrix;
  109503. private _projectionTextureProjectionLightMatrix;
  109504. private _projectionTextureScalingMatrix;
  109505. /**
  109506. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  109507. * It can cast shadows.
  109508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109509. * @param name The light friendly name
  109510. * @param position The position of the spot light in the scene
  109511. * @param direction The direction of the light in the scene
  109512. * @param angle The cone angle of the light in Radians
  109513. * @param exponent The light decay speed with the distance from the emission spot
  109514. * @param scene The scene the lights belongs to
  109515. */
  109516. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  109517. /**
  109518. * Returns the string "SpotLight".
  109519. * @returns the class name
  109520. */
  109521. getClassName(): string;
  109522. /**
  109523. * Returns the integer 2.
  109524. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109525. */
  109526. getTypeID(): number;
  109527. /**
  109528. * Overrides the direction setter to recompute the projection texture view light Matrix.
  109529. */
  109530. protected _setDirection(value: Vector3): void;
  109531. /**
  109532. * Overrides the position setter to recompute the projection texture view light Matrix.
  109533. */
  109534. protected _setPosition(value: Vector3): void;
  109535. /**
  109536. * 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.
  109537. * Returns the SpotLight.
  109538. */
  109539. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109540. protected _computeProjectionTextureViewLightMatrix(): void;
  109541. protected _computeProjectionTextureProjectionLightMatrix(): void;
  109542. /**
  109543. * Main function for light texture projection matrix computing.
  109544. */
  109545. protected _computeProjectionTextureMatrix(): void;
  109546. protected _buildUniformLayout(): void;
  109547. private _computeAngleValues;
  109548. /**
  109549. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  109550. * @param effect The effect to update
  109551. * @param lightIndex The index of the light in the effect to update
  109552. * @returns The spot light
  109553. */
  109554. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  109555. /**
  109556. * Disposes the light and the associated resources.
  109557. */
  109558. dispose(): void;
  109559. /**
  109560. * Prepares the list of defines specific to the light type.
  109561. * @param defines the list of defines
  109562. * @param lightIndex defines the index of the light for the effect
  109563. */
  109564. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109565. }
  109566. }
  109567. declare module BABYLON {
  109568. /**
  109569. * Gizmo that enables viewing a light
  109570. */
  109571. export class LightGizmo extends Gizmo {
  109572. private _lightMesh;
  109573. private _material;
  109574. private cachedPosition;
  109575. private cachedForward;
  109576. /**
  109577. * Creates a LightGizmo
  109578. * @param gizmoLayer The utility layer the gizmo will be added to
  109579. */
  109580. constructor(gizmoLayer?: UtilityLayerRenderer);
  109581. private _light;
  109582. /**
  109583. * The light that the gizmo is attached to
  109584. */
  109585. light: Nullable<Light>;
  109586. /**
  109587. * Gets the material used to render the light gizmo
  109588. */
  109589. readonly material: StandardMaterial;
  109590. /**
  109591. * @hidden
  109592. * Updates the gizmo to match the attached mesh's position/rotation
  109593. */
  109594. protected _update(): void;
  109595. private static _Scale;
  109596. /**
  109597. * Creates the lines for a light mesh
  109598. */
  109599. private static _createLightLines;
  109600. /**
  109601. * Disposes of the light gizmo
  109602. */
  109603. dispose(): void;
  109604. private static _CreateHemisphericLightMesh;
  109605. private static _CreatePointLightMesh;
  109606. private static _CreateSpotLightMesh;
  109607. private static _CreateDirectionalLightMesh;
  109608. }
  109609. }
  109610. declare module BABYLON {
  109611. /** @hidden */
  109612. export var backgroundFragmentDeclaration: {
  109613. name: string;
  109614. shader: string;
  109615. };
  109616. }
  109617. declare module BABYLON {
  109618. /** @hidden */
  109619. export var backgroundUboDeclaration: {
  109620. name: string;
  109621. shader: string;
  109622. };
  109623. }
  109624. declare module BABYLON {
  109625. /** @hidden */
  109626. export var backgroundPixelShader: {
  109627. name: string;
  109628. shader: string;
  109629. };
  109630. }
  109631. declare module BABYLON {
  109632. /** @hidden */
  109633. export var backgroundVertexDeclaration: {
  109634. name: string;
  109635. shader: string;
  109636. };
  109637. }
  109638. declare module BABYLON {
  109639. /** @hidden */
  109640. export var backgroundVertexShader: {
  109641. name: string;
  109642. shader: string;
  109643. };
  109644. }
  109645. declare module BABYLON {
  109646. /**
  109647. * Background material used to create an efficient environement around your scene.
  109648. */
  109649. export class BackgroundMaterial extends PushMaterial {
  109650. /**
  109651. * Standard reflectance value at parallel view angle.
  109652. */
  109653. static StandardReflectance0: number;
  109654. /**
  109655. * Standard reflectance value at grazing angle.
  109656. */
  109657. static StandardReflectance90: number;
  109658. protected _primaryColor: Color3;
  109659. /**
  109660. * Key light Color (multiply against the environement texture)
  109661. */
  109662. primaryColor: Color3;
  109663. protected __perceptualColor: Nullable<Color3>;
  109664. /**
  109665. * Experimental Internal Use Only.
  109666. *
  109667. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  109668. * This acts as a helper to set the primary color to a more "human friendly" value.
  109669. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  109670. * output color as close as possible from the chosen value.
  109671. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  109672. * part of lighting setup.)
  109673. */
  109674. _perceptualColor: Nullable<Color3>;
  109675. protected _primaryColorShadowLevel: float;
  109676. /**
  109677. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  109678. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  109679. */
  109680. primaryColorShadowLevel: float;
  109681. protected _primaryColorHighlightLevel: float;
  109682. /**
  109683. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  109684. * The primary color is used at the level chosen to define what the white area would look.
  109685. */
  109686. primaryColorHighlightLevel: float;
  109687. protected _reflectionTexture: Nullable<BaseTexture>;
  109688. /**
  109689. * Reflection Texture used in the material.
  109690. * Should be author in a specific way for the best result (refer to the documentation).
  109691. */
  109692. reflectionTexture: Nullable<BaseTexture>;
  109693. protected _reflectionBlur: float;
  109694. /**
  109695. * Reflection Texture level of blur.
  109696. *
  109697. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  109698. * texture twice.
  109699. */
  109700. reflectionBlur: float;
  109701. protected _diffuseTexture: Nullable<BaseTexture>;
  109702. /**
  109703. * Diffuse Texture used in the material.
  109704. * Should be author in a specific way for the best result (refer to the documentation).
  109705. */
  109706. diffuseTexture: Nullable<BaseTexture>;
  109707. protected _shadowLights: Nullable<IShadowLight[]>;
  109708. /**
  109709. * Specify the list of lights casting shadow on the material.
  109710. * All scene shadow lights will be included if null.
  109711. */
  109712. shadowLights: Nullable<IShadowLight[]>;
  109713. protected _shadowLevel: float;
  109714. /**
  109715. * Helps adjusting the shadow to a softer level if required.
  109716. * 0 means black shadows and 1 means no shadows.
  109717. */
  109718. shadowLevel: float;
  109719. protected _sceneCenter: Vector3;
  109720. /**
  109721. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  109722. * It is usually zero but might be interesting to modify according to your setup.
  109723. */
  109724. sceneCenter: Vector3;
  109725. protected _opacityFresnel: boolean;
  109726. /**
  109727. * This helps specifying that the material is falling off to the sky box at grazing angle.
  109728. * This helps ensuring a nice transition when the camera goes under the ground.
  109729. */
  109730. opacityFresnel: boolean;
  109731. protected _reflectionFresnel: boolean;
  109732. /**
  109733. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  109734. * This helps adding a mirror texture on the ground.
  109735. */
  109736. reflectionFresnel: boolean;
  109737. protected _reflectionFalloffDistance: number;
  109738. /**
  109739. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  109740. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  109741. */
  109742. reflectionFalloffDistance: number;
  109743. protected _reflectionAmount: number;
  109744. /**
  109745. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  109746. */
  109747. reflectionAmount: number;
  109748. protected _reflectionReflectance0: number;
  109749. /**
  109750. * This specifies the weight of the reflection at grazing angle.
  109751. */
  109752. reflectionReflectance0: number;
  109753. protected _reflectionReflectance90: number;
  109754. /**
  109755. * This specifies the weight of the reflection at a perpendicular point of view.
  109756. */
  109757. reflectionReflectance90: number;
  109758. /**
  109759. * Sets the reflection reflectance fresnel values according to the default standard
  109760. * empirically know to work well :-)
  109761. */
  109762. reflectionStandardFresnelWeight: number;
  109763. protected _useRGBColor: boolean;
  109764. /**
  109765. * Helps to directly use the maps channels instead of their level.
  109766. */
  109767. useRGBColor: boolean;
  109768. protected _enableNoise: boolean;
  109769. /**
  109770. * This helps reducing the banding effect that could occur on the background.
  109771. */
  109772. enableNoise: boolean;
  109773. /**
  109774. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109775. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  109776. * Recommended to be keep at 1.0 except for special cases.
  109777. */
  109778. fovMultiplier: number;
  109779. private _fovMultiplier;
  109780. /**
  109781. * Enable the FOV adjustment feature controlled by fovMultiplier.
  109782. */
  109783. useEquirectangularFOV: boolean;
  109784. private _maxSimultaneousLights;
  109785. /**
  109786. * Number of Simultaneous lights allowed on the material.
  109787. */
  109788. maxSimultaneousLights: int;
  109789. /**
  109790. * Default configuration related to image processing available in the Background Material.
  109791. */
  109792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109793. /**
  109794. * Keep track of the image processing observer to allow dispose and replace.
  109795. */
  109796. private _imageProcessingObserver;
  109797. /**
  109798. * Attaches a new image processing configuration to the PBR Material.
  109799. * @param configuration (if null the scene configuration will be use)
  109800. */
  109801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109802. /**
  109803. * Gets the image processing configuration used either in this material.
  109804. */
  109805. /**
  109806. * Sets the Default image processing configuration used either in the this material.
  109807. *
  109808. * If sets to null, the scene one is in use.
  109809. */
  109810. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  109811. /**
  109812. * Gets wether the color curves effect is enabled.
  109813. */
  109814. /**
  109815. * Sets wether the color curves effect is enabled.
  109816. */
  109817. cameraColorCurvesEnabled: boolean;
  109818. /**
  109819. * Gets wether the color grading effect is enabled.
  109820. */
  109821. /**
  109822. * Gets wether the color grading effect is enabled.
  109823. */
  109824. cameraColorGradingEnabled: boolean;
  109825. /**
  109826. * Gets wether tonemapping is enabled or not.
  109827. */
  109828. /**
  109829. * Sets wether tonemapping is enabled or not
  109830. */
  109831. cameraToneMappingEnabled: boolean;
  109832. /**
  109833. * The camera exposure used on this material.
  109834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109835. * This corresponds to a photographic exposure.
  109836. */
  109837. /**
  109838. * The camera exposure used on this material.
  109839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109840. * This corresponds to a photographic exposure.
  109841. */
  109842. cameraExposure: float;
  109843. /**
  109844. * Gets The camera contrast used on this material.
  109845. */
  109846. /**
  109847. * Sets The camera contrast used on this material.
  109848. */
  109849. cameraContrast: float;
  109850. /**
  109851. * Gets the Color Grading 2D Lookup Texture.
  109852. */
  109853. /**
  109854. * Sets the Color Grading 2D Lookup Texture.
  109855. */
  109856. cameraColorGradingTexture: Nullable<BaseTexture>;
  109857. /**
  109858. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109859. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109860. * 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;
  109861. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109862. */
  109863. /**
  109864. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109865. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109866. * 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;
  109867. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109868. */
  109869. cameraColorCurves: Nullable<ColorCurves>;
  109870. /**
  109871. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  109872. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  109873. */
  109874. switchToBGR: boolean;
  109875. private _renderTargets;
  109876. private _reflectionControls;
  109877. private _white;
  109878. private _primaryShadowColor;
  109879. private _primaryHighlightColor;
  109880. /**
  109881. * Instantiates a Background Material in the given scene
  109882. * @param name The friendly name of the material
  109883. * @param scene The scene to add the material to
  109884. */
  109885. constructor(name: string, scene: Scene);
  109886. /**
  109887. * Gets a boolean indicating that current material needs to register RTT
  109888. */
  109889. readonly hasRenderTargetTextures: boolean;
  109890. /**
  109891. * The entire material has been created in order to prevent overdraw.
  109892. * @returns false
  109893. */
  109894. needAlphaTesting(): boolean;
  109895. /**
  109896. * The entire material has been created in order to prevent overdraw.
  109897. * @returns true if blending is enable
  109898. */
  109899. needAlphaBlending(): boolean;
  109900. /**
  109901. * Checks wether the material is ready to be rendered for a given mesh.
  109902. * @param mesh The mesh to render
  109903. * @param subMesh The submesh to check against
  109904. * @param useInstances Specify wether or not the material is used with instances
  109905. * @returns true if all the dependencies are ready (Textures, Effects...)
  109906. */
  109907. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109908. /**
  109909. * Compute the primary color according to the chosen perceptual color.
  109910. */
  109911. private _computePrimaryColorFromPerceptualColor;
  109912. /**
  109913. * Compute the highlights and shadow colors according to their chosen levels.
  109914. */
  109915. private _computePrimaryColors;
  109916. /**
  109917. * Build the uniform buffer used in the material.
  109918. */
  109919. buildUniformLayout(): void;
  109920. /**
  109921. * Unbind the material.
  109922. */
  109923. unbind(): void;
  109924. /**
  109925. * Bind only the world matrix to the material.
  109926. * @param world The world matrix to bind.
  109927. */
  109928. bindOnlyWorldMatrix(world: Matrix): void;
  109929. /**
  109930. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  109931. * @param world The world matrix to bind.
  109932. * @param subMesh The submesh to bind for.
  109933. */
  109934. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109935. /**
  109936. * Checks to see if a texture is used in the material.
  109937. * @param texture - Base texture to use.
  109938. * @returns - Boolean specifying if a texture is used in the material.
  109939. */
  109940. hasTexture(texture: BaseTexture): boolean;
  109941. /**
  109942. * Dispose the material.
  109943. * @param forceDisposeEffect Force disposal of the associated effect.
  109944. * @param forceDisposeTextures Force disposal of the associated textures.
  109945. */
  109946. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109947. /**
  109948. * Clones the material.
  109949. * @param name The cloned name.
  109950. * @returns The cloned material.
  109951. */
  109952. clone(name: string): BackgroundMaterial;
  109953. /**
  109954. * Serializes the current material to its JSON representation.
  109955. * @returns The JSON representation.
  109956. */
  109957. serialize(): any;
  109958. /**
  109959. * Gets the class name of the material
  109960. * @returns "BackgroundMaterial"
  109961. */
  109962. getClassName(): string;
  109963. /**
  109964. * Parse a JSON input to create back a background material.
  109965. * @param source The JSON data to parse
  109966. * @param scene The scene to create the parsed material in
  109967. * @param rootUrl The root url of the assets the material depends upon
  109968. * @returns the instantiated BackgroundMaterial.
  109969. */
  109970. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  109971. }
  109972. }
  109973. declare module BABYLON {
  109974. /**
  109975. * Represents the different options available during the creation of
  109976. * a Environment helper.
  109977. *
  109978. * This can control the default ground, skybox and image processing setup of your scene.
  109979. */
  109980. export interface IEnvironmentHelperOptions {
  109981. /**
  109982. * Specifies wether or not to create a ground.
  109983. * True by default.
  109984. */
  109985. createGround: boolean;
  109986. /**
  109987. * Specifies the ground size.
  109988. * 15 by default.
  109989. */
  109990. groundSize: number;
  109991. /**
  109992. * The texture used on the ground for the main color.
  109993. * Comes from the BabylonJS CDN by default.
  109994. *
  109995. * Remarks: Can be either a texture or a url.
  109996. */
  109997. groundTexture: string | BaseTexture;
  109998. /**
  109999. * The color mixed in the ground texture by default.
  110000. * BabylonJS clearColor by default.
  110001. */
  110002. groundColor: Color3;
  110003. /**
  110004. * Specifies the ground opacity.
  110005. * 1 by default.
  110006. */
  110007. groundOpacity: number;
  110008. /**
  110009. * Enables the ground to receive shadows.
  110010. * True by default.
  110011. */
  110012. enableGroundShadow: boolean;
  110013. /**
  110014. * Helps preventing the shadow to be fully black on the ground.
  110015. * 0.5 by default.
  110016. */
  110017. groundShadowLevel: number;
  110018. /**
  110019. * Creates a mirror texture attach to the ground.
  110020. * false by default.
  110021. */
  110022. enableGroundMirror: boolean;
  110023. /**
  110024. * Specifies the ground mirror size ratio.
  110025. * 0.3 by default as the default kernel is 64.
  110026. */
  110027. groundMirrorSizeRatio: number;
  110028. /**
  110029. * Specifies the ground mirror blur kernel size.
  110030. * 64 by default.
  110031. */
  110032. groundMirrorBlurKernel: number;
  110033. /**
  110034. * Specifies the ground mirror visibility amount.
  110035. * 1 by default
  110036. */
  110037. groundMirrorAmount: number;
  110038. /**
  110039. * Specifies the ground mirror reflectance weight.
  110040. * This uses the standard weight of the background material to setup the fresnel effect
  110041. * of the mirror.
  110042. * 1 by default.
  110043. */
  110044. groundMirrorFresnelWeight: number;
  110045. /**
  110046. * Specifies the ground mirror Falloff distance.
  110047. * This can helps reducing the size of the reflection.
  110048. * 0 by Default.
  110049. */
  110050. groundMirrorFallOffDistance: number;
  110051. /**
  110052. * Specifies the ground mirror texture type.
  110053. * Unsigned Int by Default.
  110054. */
  110055. groundMirrorTextureType: number;
  110056. /**
  110057. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  110058. * the shown objects.
  110059. */
  110060. groundYBias: number;
  110061. /**
  110062. * Specifies wether or not to create a skybox.
  110063. * True by default.
  110064. */
  110065. createSkybox: boolean;
  110066. /**
  110067. * Specifies the skybox size.
  110068. * 20 by default.
  110069. */
  110070. skyboxSize: number;
  110071. /**
  110072. * The texture used on the skybox for the main color.
  110073. * Comes from the BabylonJS CDN by default.
  110074. *
  110075. * Remarks: Can be either a texture or a url.
  110076. */
  110077. skyboxTexture: string | BaseTexture;
  110078. /**
  110079. * The color mixed in the skybox texture by default.
  110080. * BabylonJS clearColor by default.
  110081. */
  110082. skyboxColor: Color3;
  110083. /**
  110084. * The background rotation around the Y axis of the scene.
  110085. * This helps aligning the key lights of your scene with the background.
  110086. * 0 by default.
  110087. */
  110088. backgroundYRotation: number;
  110089. /**
  110090. * Compute automatically the size of the elements to best fit with the scene.
  110091. */
  110092. sizeAuto: boolean;
  110093. /**
  110094. * Default position of the rootMesh if autoSize is not true.
  110095. */
  110096. rootPosition: Vector3;
  110097. /**
  110098. * Sets up the image processing in the scene.
  110099. * true by default.
  110100. */
  110101. setupImageProcessing: boolean;
  110102. /**
  110103. * The texture used as your environment texture in the scene.
  110104. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  110105. *
  110106. * Remarks: Can be either a texture or a url.
  110107. */
  110108. environmentTexture: string | BaseTexture;
  110109. /**
  110110. * The value of the exposure to apply to the scene.
  110111. * 0.6 by default if setupImageProcessing is true.
  110112. */
  110113. cameraExposure: number;
  110114. /**
  110115. * The value of the contrast to apply to the scene.
  110116. * 1.6 by default if setupImageProcessing is true.
  110117. */
  110118. cameraContrast: number;
  110119. /**
  110120. * Specifies wether or not tonemapping should be enabled in the scene.
  110121. * true by default if setupImageProcessing is true.
  110122. */
  110123. toneMappingEnabled: boolean;
  110124. }
  110125. /**
  110126. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  110127. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  110128. * It also helps with the default setup of your imageProcessing configuration.
  110129. */
  110130. export class EnvironmentHelper {
  110131. /**
  110132. * Default ground texture URL.
  110133. */
  110134. private static _groundTextureCDNUrl;
  110135. /**
  110136. * Default skybox texture URL.
  110137. */
  110138. private static _skyboxTextureCDNUrl;
  110139. /**
  110140. * Default environment texture URL.
  110141. */
  110142. private static _environmentTextureCDNUrl;
  110143. /**
  110144. * Creates the default options for the helper.
  110145. */
  110146. private static _getDefaultOptions;
  110147. private _rootMesh;
  110148. /**
  110149. * Gets the root mesh created by the helper.
  110150. */
  110151. readonly rootMesh: Mesh;
  110152. private _skybox;
  110153. /**
  110154. * Gets the skybox created by the helper.
  110155. */
  110156. readonly skybox: Nullable<Mesh>;
  110157. private _skyboxTexture;
  110158. /**
  110159. * Gets the skybox texture created by the helper.
  110160. */
  110161. readonly skyboxTexture: Nullable<BaseTexture>;
  110162. private _skyboxMaterial;
  110163. /**
  110164. * Gets the skybox material created by the helper.
  110165. */
  110166. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  110167. private _ground;
  110168. /**
  110169. * Gets the ground mesh created by the helper.
  110170. */
  110171. readonly ground: Nullable<Mesh>;
  110172. private _groundTexture;
  110173. /**
  110174. * Gets the ground texture created by the helper.
  110175. */
  110176. readonly groundTexture: Nullable<BaseTexture>;
  110177. private _groundMirror;
  110178. /**
  110179. * Gets the ground mirror created by the helper.
  110180. */
  110181. readonly groundMirror: Nullable<MirrorTexture>;
  110182. /**
  110183. * Gets the ground mirror render list to helps pushing the meshes
  110184. * you wish in the ground reflection.
  110185. */
  110186. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  110187. private _groundMaterial;
  110188. /**
  110189. * Gets the ground material created by the helper.
  110190. */
  110191. readonly groundMaterial: Nullable<BackgroundMaterial>;
  110192. /**
  110193. * Stores the creation options.
  110194. */
  110195. private readonly _scene;
  110196. private _options;
  110197. /**
  110198. * This observable will be notified with any error during the creation of the environment,
  110199. * mainly texture creation errors.
  110200. */
  110201. onErrorObservable: Observable<{
  110202. message?: string;
  110203. exception?: any;
  110204. }>;
  110205. /**
  110206. * constructor
  110207. * @param options Defines the options we want to customize the helper
  110208. * @param scene The scene to add the material to
  110209. */
  110210. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  110211. /**
  110212. * Updates the background according to the new options
  110213. * @param options
  110214. */
  110215. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  110216. /**
  110217. * Sets the primary color of all the available elements.
  110218. * @param color the main color to affect to the ground and the background
  110219. */
  110220. setMainColor(color: Color3): void;
  110221. /**
  110222. * Setup the image processing according to the specified options.
  110223. */
  110224. private _setupImageProcessing;
  110225. /**
  110226. * Setup the environment texture according to the specified options.
  110227. */
  110228. private _setupEnvironmentTexture;
  110229. /**
  110230. * Setup the background according to the specified options.
  110231. */
  110232. private _setupBackground;
  110233. /**
  110234. * Get the scene sizes according to the setup.
  110235. */
  110236. private _getSceneSize;
  110237. /**
  110238. * Setup the ground according to the specified options.
  110239. */
  110240. private _setupGround;
  110241. /**
  110242. * Setup the ground material according to the specified options.
  110243. */
  110244. private _setupGroundMaterial;
  110245. /**
  110246. * Setup the ground diffuse texture according to the specified options.
  110247. */
  110248. private _setupGroundDiffuseTexture;
  110249. /**
  110250. * Setup the ground mirror texture according to the specified options.
  110251. */
  110252. private _setupGroundMirrorTexture;
  110253. /**
  110254. * Setup the ground to receive the mirror texture.
  110255. */
  110256. private _setupMirrorInGroundMaterial;
  110257. /**
  110258. * Setup the skybox according to the specified options.
  110259. */
  110260. private _setupSkybox;
  110261. /**
  110262. * Setup the skybox material according to the specified options.
  110263. */
  110264. private _setupSkyboxMaterial;
  110265. /**
  110266. * Setup the skybox reflection texture according to the specified options.
  110267. */
  110268. private _setupSkyboxReflectionTexture;
  110269. private _errorHandler;
  110270. /**
  110271. * Dispose all the elements created by the Helper.
  110272. */
  110273. dispose(): void;
  110274. }
  110275. }
  110276. declare module BABYLON {
  110277. /**
  110278. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  110279. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  110280. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  110281. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110282. */
  110283. export class PhotoDome extends TransformNode {
  110284. /**
  110285. * Define the image as a Monoscopic panoramic 360 image.
  110286. */
  110287. static readonly MODE_MONOSCOPIC: number;
  110288. /**
  110289. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  110290. */
  110291. static readonly MODE_TOPBOTTOM: number;
  110292. /**
  110293. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  110294. */
  110295. static readonly MODE_SIDEBYSIDE: number;
  110296. private _useDirectMapping;
  110297. /**
  110298. * The texture being displayed on the sphere
  110299. */
  110300. protected _photoTexture: Texture;
  110301. /**
  110302. * Gets or sets the texture being displayed on the sphere
  110303. */
  110304. photoTexture: Texture;
  110305. /**
  110306. * Observable raised when an error occured while loading the 360 image
  110307. */
  110308. onLoadErrorObservable: Observable<string>;
  110309. /**
  110310. * The skybox material
  110311. */
  110312. protected _material: BackgroundMaterial;
  110313. /**
  110314. * The surface used for the skybox
  110315. */
  110316. protected _mesh: Mesh;
  110317. /**
  110318. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110319. * Also see the options.resolution property.
  110320. */
  110321. fovMultiplier: number;
  110322. private _imageMode;
  110323. /**
  110324. * Gets or set the current video mode for the video. It can be:
  110325. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  110326. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  110327. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  110328. */
  110329. imageMode: number;
  110330. /**
  110331. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  110332. * @param name Element's name, child elements will append suffixes for their own names.
  110333. * @param urlsOfPhoto defines the url of the photo to display
  110334. * @param options defines an object containing optional or exposed sub element properties
  110335. * @param onError defines a callback called when an error occured while loading the texture
  110336. */
  110337. constructor(name: string, urlOfPhoto: string, options: {
  110338. resolution?: number;
  110339. size?: number;
  110340. useDirectMapping?: boolean;
  110341. faceForward?: boolean;
  110342. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  110343. private _onBeforeCameraRenderObserver;
  110344. private _changeImageMode;
  110345. /**
  110346. * Releases resources associated with this node.
  110347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110349. */
  110350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110351. }
  110352. }
  110353. declare module BABYLON {
  110354. /** @hidden */
  110355. export var rgbdDecodePixelShader: {
  110356. name: string;
  110357. shader: string;
  110358. };
  110359. }
  110360. declare module BABYLON {
  110361. /**
  110362. * Class used to host texture specific utilities
  110363. */
  110364. export class BRDFTextureTools {
  110365. /**
  110366. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  110367. * @param texture the texture to expand.
  110368. */
  110369. private static _ExpandDefaultBRDFTexture;
  110370. /**
  110371. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  110372. * @param scene defines the hosting scene
  110373. * @returns the environment BRDF texture
  110374. */
  110375. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  110376. private static _environmentBRDFBase64Texture;
  110377. }
  110378. }
  110379. declare module BABYLON {
  110380. /**
  110381. * @hidden
  110382. */
  110383. export interface IMaterialClearCoatDefines {
  110384. CLEARCOAT: boolean;
  110385. CLEARCOAT_DEFAULTIOR: boolean;
  110386. CLEARCOAT_TEXTURE: boolean;
  110387. CLEARCOAT_TEXTUREDIRECTUV: number;
  110388. CLEARCOAT_BUMP: boolean;
  110389. CLEARCOAT_BUMPDIRECTUV: number;
  110390. CLEARCOAT_TINT: boolean;
  110391. CLEARCOAT_TINT_TEXTURE: boolean;
  110392. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110393. /** @hidden */
  110394. _areTexturesDirty: boolean;
  110395. }
  110396. /**
  110397. * Define the code related to the clear coat parameters of the pbr material.
  110398. */
  110399. export class PBRClearCoatConfiguration {
  110400. /**
  110401. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110402. * The default fits with a polyurethane material.
  110403. */
  110404. private static readonly _DefaultIndexOfRefraction;
  110405. private _isEnabled;
  110406. /**
  110407. * Defines if the clear coat is enabled in the material.
  110408. */
  110409. isEnabled: boolean;
  110410. /**
  110411. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  110412. */
  110413. intensity: number;
  110414. /**
  110415. * Defines the clear coat layer roughness.
  110416. */
  110417. roughness: number;
  110418. private _indexOfRefraction;
  110419. /**
  110420. * Defines the index of refraction of the clear coat.
  110421. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110422. * The default fits with a polyurethane material.
  110423. * Changing the default value is more performance intensive.
  110424. */
  110425. indexOfRefraction: number;
  110426. private _texture;
  110427. /**
  110428. * Stores the clear coat values in a texture.
  110429. */
  110430. texture: Nullable<BaseTexture>;
  110431. private _bumpTexture;
  110432. /**
  110433. * Define the clear coat specific bump texture.
  110434. */
  110435. bumpTexture: Nullable<BaseTexture>;
  110436. private _isTintEnabled;
  110437. /**
  110438. * Defines if the clear coat tint is enabled in the material.
  110439. */
  110440. isTintEnabled: boolean;
  110441. /**
  110442. * Defines the clear coat tint of the material.
  110443. * This is only use if tint is enabled
  110444. */
  110445. tintColor: Color3;
  110446. /**
  110447. * Defines the distance at which the tint color should be found in the
  110448. * clear coat media.
  110449. * This is only use if tint is enabled
  110450. */
  110451. tintColorAtDistance: number;
  110452. /**
  110453. * Defines the clear coat layer thickness.
  110454. * This is only use if tint is enabled
  110455. */
  110456. tintThickness: number;
  110457. private _tintTexture;
  110458. /**
  110459. * Stores the clear tint values in a texture.
  110460. * rgb is tint
  110461. * a is a thickness factor
  110462. */
  110463. tintTexture: Nullable<BaseTexture>;
  110464. /** @hidden */
  110465. private _internalMarkAllSubMeshesAsTexturesDirty;
  110466. /** @hidden */
  110467. _markAllSubMeshesAsTexturesDirty(): void;
  110468. /**
  110469. * Instantiate a new istance of clear coat configuration.
  110470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110471. */
  110472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110473. /**
  110474. * Gets wehter the submesh is ready to be used or not.
  110475. * @param defines the list of "defines" to update.
  110476. * @param scene defines the scene the material belongs to.
  110477. * @param engine defines the engine the material belongs to.
  110478. * @param disableBumpMap defines wether the material disables bump or not.
  110479. * @returns - boolean indicating that the submesh is ready or not.
  110480. */
  110481. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  110482. /**
  110483. * Checks to see if a texture is used in the material.
  110484. * @param defines the list of "defines" to update.
  110485. * @param scene defines the scene to the material belongs to.
  110486. */
  110487. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  110488. /**
  110489. * Binds the material data.
  110490. * @param uniformBuffer defines the Uniform buffer to fill in.
  110491. * @param scene defines the scene the material belongs to.
  110492. * @param engine defines the engine the material belongs to.
  110493. * @param disableBumpMap defines wether the material disables bump or not.
  110494. * @param isFrozen defines wether the material is frozen or not.
  110495. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110496. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110497. */
  110498. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  110499. /**
  110500. * Checks to see if a texture is used in the material.
  110501. * @param texture - Base texture to use.
  110502. * @returns - Boolean specifying if a texture is used in the material.
  110503. */
  110504. hasTexture(texture: BaseTexture): boolean;
  110505. /**
  110506. * Returns an array of the actively used textures.
  110507. * @param activeTextures Array of BaseTextures
  110508. */
  110509. getActiveTextures(activeTextures: BaseTexture[]): void;
  110510. /**
  110511. * Returns the animatable textures.
  110512. * @param animatables Array of animatable textures.
  110513. */
  110514. getAnimatables(animatables: IAnimatable[]): void;
  110515. /**
  110516. * Disposes the resources of the material.
  110517. * @param forceDisposeTextures - Forces the disposal of all textures.
  110518. */
  110519. dispose(forceDisposeTextures?: boolean): void;
  110520. /**
  110521. * Get the current class name of the texture useful for serialization or dynamic coding.
  110522. * @returns "PBRClearCoatConfiguration"
  110523. */
  110524. getClassName(): string;
  110525. /**
  110526. * Add fallbacks to the effect fallbacks list.
  110527. * @param defines defines the Base texture to use.
  110528. * @param fallbacks defines the current fallback list.
  110529. * @param currentRank defines the current fallback rank.
  110530. * @returns the new fallback rank.
  110531. */
  110532. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110533. /**
  110534. * Add the required uniforms to the current list.
  110535. * @param uniforms defines the current uniform list.
  110536. */
  110537. static AddUniforms(uniforms: string[]): void;
  110538. /**
  110539. * Add the required samplers to the current list.
  110540. * @param samplers defines the current sampler list.
  110541. */
  110542. static AddSamplers(samplers: string[]): void;
  110543. /**
  110544. * Add the required uniforms to the current buffer.
  110545. * @param uniformBuffer defines the current uniform buffer.
  110546. */
  110547. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110548. /**
  110549. * Makes a duplicate of the current configuration into another one.
  110550. * @param clearCoatConfiguration define the config where to copy the info
  110551. */
  110552. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  110553. /**
  110554. * Serializes this clear coat configuration.
  110555. * @returns - An object with the serialized config.
  110556. */
  110557. serialize(): any;
  110558. /**
  110559. * Parses a anisotropy Configuration from a serialized object.
  110560. * @param source - Serialized object.
  110561. * @param scene Defines the scene we are parsing for
  110562. * @param rootUrl Defines the rootUrl to load from
  110563. */
  110564. parse(source: any, scene: Scene, rootUrl: string): void;
  110565. }
  110566. }
  110567. declare module BABYLON {
  110568. /**
  110569. * @hidden
  110570. */
  110571. export interface IMaterialAnisotropicDefines {
  110572. ANISOTROPIC: boolean;
  110573. ANISOTROPIC_TEXTURE: boolean;
  110574. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110575. MAINUV1: boolean;
  110576. _areTexturesDirty: boolean;
  110577. _needUVs: boolean;
  110578. }
  110579. /**
  110580. * Define the code related to the anisotropic parameters of the pbr material.
  110581. */
  110582. export class PBRAnisotropicConfiguration {
  110583. private _isEnabled;
  110584. /**
  110585. * Defines if the anisotropy is enabled in the material.
  110586. */
  110587. isEnabled: boolean;
  110588. /**
  110589. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  110590. */
  110591. intensity: number;
  110592. /**
  110593. * Defines if the effect is along the tangents, bitangents or in between.
  110594. * By default, the effect is "strectching" the highlights along the tangents.
  110595. */
  110596. direction: Vector2;
  110597. private _texture;
  110598. /**
  110599. * Stores the anisotropy values in a texture.
  110600. * rg is direction (like normal from -1 to 1)
  110601. * b is a intensity
  110602. */
  110603. texture: Nullable<BaseTexture>;
  110604. /** @hidden */
  110605. private _internalMarkAllSubMeshesAsTexturesDirty;
  110606. /** @hidden */
  110607. _markAllSubMeshesAsTexturesDirty(): void;
  110608. /**
  110609. * Instantiate a new istance of anisotropy configuration.
  110610. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110611. */
  110612. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110613. /**
  110614. * Specifies that the submesh is ready to be used.
  110615. * @param defines the list of "defines" to update.
  110616. * @param scene defines the scene the material belongs to.
  110617. * @returns - boolean indicating that the submesh is ready or not.
  110618. */
  110619. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  110620. /**
  110621. * Checks to see if a texture is used in the material.
  110622. * @param defines the list of "defines" to update.
  110623. * @param mesh the mesh we are preparing the defines for.
  110624. * @param scene defines the scene the material belongs to.
  110625. */
  110626. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  110627. /**
  110628. * Binds the material data.
  110629. * @param uniformBuffer defines the Uniform buffer to fill in.
  110630. * @param scene defines the scene the material belongs to.
  110631. * @param isFrozen defines wether the material is frozen or not.
  110632. */
  110633. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110634. /**
  110635. * Checks to see if a texture is used in the material.
  110636. * @param texture - Base texture to use.
  110637. * @returns - Boolean specifying if a texture is used in the material.
  110638. */
  110639. hasTexture(texture: BaseTexture): boolean;
  110640. /**
  110641. * Returns an array of the actively used textures.
  110642. * @param activeTextures Array of BaseTextures
  110643. */
  110644. getActiveTextures(activeTextures: BaseTexture[]): void;
  110645. /**
  110646. * Returns the animatable textures.
  110647. * @param animatables Array of animatable textures.
  110648. */
  110649. getAnimatables(animatables: IAnimatable[]): void;
  110650. /**
  110651. * Disposes the resources of the material.
  110652. * @param forceDisposeTextures - Forces the disposal of all textures.
  110653. */
  110654. dispose(forceDisposeTextures?: boolean): void;
  110655. /**
  110656. * Get the current class name of the texture useful for serialization or dynamic coding.
  110657. * @returns "PBRAnisotropicConfiguration"
  110658. */
  110659. getClassName(): string;
  110660. /**
  110661. * Add fallbacks to the effect fallbacks list.
  110662. * @param defines defines the Base texture to use.
  110663. * @param fallbacks defines the current fallback list.
  110664. * @param currentRank defines the current fallback rank.
  110665. * @returns the new fallback rank.
  110666. */
  110667. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110668. /**
  110669. * Add the required uniforms to the current list.
  110670. * @param uniforms defines the current uniform list.
  110671. */
  110672. static AddUniforms(uniforms: string[]): void;
  110673. /**
  110674. * Add the required uniforms to the current buffer.
  110675. * @param uniformBuffer defines the current uniform buffer.
  110676. */
  110677. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110678. /**
  110679. * Add the required samplers to the current list.
  110680. * @param samplers defines the current sampler list.
  110681. */
  110682. static AddSamplers(samplers: string[]): void;
  110683. /**
  110684. * Makes a duplicate of the current configuration into another one.
  110685. * @param anisotropicConfiguration define the config where to copy the info
  110686. */
  110687. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  110688. /**
  110689. * Serializes this anisotropy configuration.
  110690. * @returns - An object with the serialized config.
  110691. */
  110692. serialize(): any;
  110693. /**
  110694. * Parses a anisotropy Configuration from a serialized object.
  110695. * @param source - Serialized object.
  110696. * @param scene Defines the scene we are parsing for
  110697. * @param rootUrl Defines the rootUrl to load from
  110698. */
  110699. parse(source: any, scene: Scene, rootUrl: string): void;
  110700. }
  110701. }
  110702. declare module BABYLON {
  110703. /**
  110704. * @hidden
  110705. */
  110706. export interface IMaterialBRDFDefines {
  110707. BRDF_V_HEIGHT_CORRELATED: boolean;
  110708. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110709. SPHERICAL_HARMONICS: boolean;
  110710. /** @hidden */
  110711. _areMiscDirty: boolean;
  110712. }
  110713. /**
  110714. * Define the code related to the BRDF parameters of the pbr material.
  110715. */
  110716. export class PBRBRDFConfiguration {
  110717. /**
  110718. * Default value used for the energy conservation.
  110719. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110720. */
  110721. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  110722. /**
  110723. * Default value used for the Smith Visibility Height Correlated mode.
  110724. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110725. */
  110726. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  110727. /**
  110728. * Default value used for the IBL diffuse part.
  110729. * This can help switching back to the polynomials mode globally which is a tiny bit
  110730. * less GPU intensive at the drawback of a lower quality.
  110731. */
  110732. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  110733. private _useEnergyConservation;
  110734. /**
  110735. * Defines if the material uses energy conservation.
  110736. */
  110737. useEnergyConservation: boolean;
  110738. private _useSmithVisibilityHeightCorrelated;
  110739. /**
  110740. * LEGACY Mode set to false
  110741. * Defines if the material uses height smith correlated visibility term.
  110742. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  110743. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  110744. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  110745. * Not relying on height correlated will also disable energy conservation.
  110746. */
  110747. useSmithVisibilityHeightCorrelated: boolean;
  110748. private _useSphericalHarmonics;
  110749. /**
  110750. * LEGACY Mode set to false
  110751. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  110752. * diffuse part of the IBL.
  110753. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  110754. * to the ground truth.
  110755. */
  110756. useSphericalHarmonics: boolean;
  110757. /** @hidden */
  110758. private _internalMarkAllSubMeshesAsMiscDirty;
  110759. /** @hidden */
  110760. _markAllSubMeshesAsMiscDirty(): void;
  110761. /**
  110762. * Instantiate a new istance of clear coat configuration.
  110763. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  110764. */
  110765. constructor(markAllSubMeshesAsMiscDirty: () => void);
  110766. /**
  110767. * Checks to see if a texture is used in the material.
  110768. * @param defines the list of "defines" to update.
  110769. */
  110770. prepareDefines(defines: IMaterialBRDFDefines): void;
  110771. /**
  110772. * Get the current class name of the texture useful for serialization or dynamic coding.
  110773. * @returns "PBRClearCoatConfiguration"
  110774. */
  110775. getClassName(): string;
  110776. /**
  110777. * Makes a duplicate of the current configuration into another one.
  110778. * @param brdfConfiguration define the config where to copy the info
  110779. */
  110780. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  110781. /**
  110782. * Serializes this BRDF configuration.
  110783. * @returns - An object with the serialized config.
  110784. */
  110785. serialize(): any;
  110786. /**
  110787. * Parses a anisotropy Configuration from a serialized object.
  110788. * @param source - Serialized object.
  110789. * @param scene Defines the scene we are parsing for
  110790. * @param rootUrl Defines the rootUrl to load from
  110791. */
  110792. parse(source: any, scene: Scene, rootUrl: string): void;
  110793. }
  110794. }
  110795. declare module BABYLON {
  110796. /**
  110797. * @hidden
  110798. */
  110799. export interface IMaterialSheenDefines {
  110800. SHEEN: boolean;
  110801. SHEEN_TEXTURE: boolean;
  110802. SHEEN_TEXTUREDIRECTUV: number;
  110803. SHEEN_LINKWITHALBEDO: boolean;
  110804. /** @hidden */
  110805. _areTexturesDirty: boolean;
  110806. }
  110807. /**
  110808. * Define the code related to the Sheen parameters of the pbr material.
  110809. */
  110810. export class PBRSheenConfiguration {
  110811. private _isEnabled;
  110812. /**
  110813. * Defines if the material uses sheen.
  110814. */
  110815. isEnabled: boolean;
  110816. private _linkSheenWithAlbedo;
  110817. /**
  110818. * Defines if the sheen is linked to the sheen color.
  110819. */
  110820. linkSheenWithAlbedo: boolean;
  110821. /**
  110822. * Defines the sheen intensity.
  110823. */
  110824. intensity: number;
  110825. /**
  110826. * Defines the sheen color.
  110827. */
  110828. color: Color3;
  110829. private _texture;
  110830. /**
  110831. * Stores the sheen tint values in a texture.
  110832. * rgb is tint
  110833. * a is a intensity
  110834. */
  110835. texture: Nullable<BaseTexture>;
  110836. /** @hidden */
  110837. private _internalMarkAllSubMeshesAsTexturesDirty;
  110838. /** @hidden */
  110839. _markAllSubMeshesAsTexturesDirty(): void;
  110840. /**
  110841. * Instantiate a new istance of clear coat configuration.
  110842. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110843. */
  110844. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110845. /**
  110846. * Specifies that the submesh is ready to be used.
  110847. * @param defines the list of "defines" to update.
  110848. * @param scene defines the scene the material belongs to.
  110849. * @returns - boolean indicating that the submesh is ready or not.
  110850. */
  110851. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  110852. /**
  110853. * Checks to see if a texture is used in the material.
  110854. * @param defines the list of "defines" to update.
  110855. * @param scene defines the scene the material belongs to.
  110856. */
  110857. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  110858. /**
  110859. * Binds the material data.
  110860. * @param uniformBuffer defines the Uniform buffer to fill in.
  110861. * @param scene defines the scene the material belongs to.
  110862. * @param isFrozen defines wether the material is frozen or not.
  110863. */
  110864. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110865. /**
  110866. * Checks to see if a texture is used in the material.
  110867. * @param texture - Base texture to use.
  110868. * @returns - Boolean specifying if a texture is used in the material.
  110869. */
  110870. hasTexture(texture: BaseTexture): boolean;
  110871. /**
  110872. * Returns an array of the actively used textures.
  110873. * @param activeTextures Array of BaseTextures
  110874. */
  110875. getActiveTextures(activeTextures: BaseTexture[]): void;
  110876. /**
  110877. * Returns the animatable textures.
  110878. * @param animatables Array of animatable textures.
  110879. */
  110880. getAnimatables(animatables: IAnimatable[]): void;
  110881. /**
  110882. * Disposes the resources of the material.
  110883. * @param forceDisposeTextures - Forces the disposal of all textures.
  110884. */
  110885. dispose(forceDisposeTextures?: boolean): void;
  110886. /**
  110887. * Get the current class name of the texture useful for serialization or dynamic coding.
  110888. * @returns "PBRSheenConfiguration"
  110889. */
  110890. getClassName(): string;
  110891. /**
  110892. * Add fallbacks to the effect fallbacks list.
  110893. * @param defines defines the Base texture to use.
  110894. * @param fallbacks defines the current fallback list.
  110895. * @param currentRank defines the current fallback rank.
  110896. * @returns the new fallback rank.
  110897. */
  110898. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110899. /**
  110900. * Add the required uniforms to the current list.
  110901. * @param uniforms defines the current uniform list.
  110902. */
  110903. static AddUniforms(uniforms: string[]): void;
  110904. /**
  110905. * Add the required uniforms to the current buffer.
  110906. * @param uniformBuffer defines the current uniform buffer.
  110907. */
  110908. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110909. /**
  110910. * Add the required samplers to the current list.
  110911. * @param samplers defines the current sampler list.
  110912. */
  110913. static AddSamplers(samplers: string[]): void;
  110914. /**
  110915. * Makes a duplicate of the current configuration into another one.
  110916. * @param sheenConfiguration define the config where to copy the info
  110917. */
  110918. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  110919. /**
  110920. * Serializes this BRDF configuration.
  110921. * @returns - An object with the serialized config.
  110922. */
  110923. serialize(): any;
  110924. /**
  110925. * Parses a anisotropy Configuration from a serialized object.
  110926. * @param source - Serialized object.
  110927. * @param scene Defines the scene we are parsing for
  110928. * @param rootUrl Defines the rootUrl to load from
  110929. */
  110930. parse(source: any, scene: Scene, rootUrl: string): void;
  110931. }
  110932. }
  110933. declare module BABYLON {
  110934. /**
  110935. * @hidden
  110936. */
  110937. export interface IMaterialSubSurfaceDefines {
  110938. SUBSURFACE: boolean;
  110939. SS_REFRACTION: boolean;
  110940. SS_TRANSLUCENCY: boolean;
  110941. SS_SCATERRING: boolean;
  110942. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110943. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110944. SS_REFRACTIONMAP_3D: boolean;
  110945. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110946. SS_LODINREFRACTIONALPHA: boolean;
  110947. SS_GAMMAREFRACTION: boolean;
  110948. SS_RGBDREFRACTION: boolean;
  110949. SS_LINEARSPECULARREFRACTION: boolean;
  110950. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110951. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110952. /** @hidden */
  110953. _areTexturesDirty: boolean;
  110954. }
  110955. /**
  110956. * Define the code related to the sub surface parameters of the pbr material.
  110957. */
  110958. export class PBRSubSurfaceConfiguration {
  110959. private _isRefractionEnabled;
  110960. /**
  110961. * Defines if the refraction is enabled in the material.
  110962. */
  110963. isRefractionEnabled: boolean;
  110964. private _isTranslucencyEnabled;
  110965. /**
  110966. * Defines if the translucency is enabled in the material.
  110967. */
  110968. isTranslucencyEnabled: boolean;
  110969. private _isScatteringEnabled;
  110970. /**
  110971. * Defines the refraction intensity of the material.
  110972. * The refraction when enabled replaces the Diffuse part of the material.
  110973. * The intensity helps transitionning between diffuse and refraction.
  110974. */
  110975. refractionIntensity: number;
  110976. /**
  110977. * Defines the translucency intensity of the material.
  110978. * When translucency has been enabled, this defines how much of the "translucency"
  110979. * is addded to the diffuse part of the material.
  110980. */
  110981. translucencyIntensity: number;
  110982. /**
  110983. * Defines the scattering intensity of the material.
  110984. * When scattering has been enabled, this defines how much of the "scattered light"
  110985. * is addded to the diffuse part of the material.
  110986. */
  110987. scatteringIntensity: number;
  110988. private _thicknessTexture;
  110989. /**
  110990. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  110991. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  110992. * 0 would mean minimumThickness
  110993. * 1 would mean maximumThickness
  110994. * The other channels might be use as a mask to vary the different effects intensity.
  110995. */
  110996. thicknessTexture: Nullable<BaseTexture>;
  110997. private _refractionTexture;
  110998. /**
  110999. * Defines the texture to use for refraction.
  111000. */
  111001. refractionTexture: Nullable<BaseTexture>;
  111002. private _indexOfRefraction;
  111003. /**
  111004. * Defines the index of refraction used in the material.
  111005. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  111006. */
  111007. indexOfRefraction: number;
  111008. private _invertRefractionY;
  111009. /**
  111010. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  111011. */
  111012. invertRefractionY: boolean;
  111013. private _linkRefractionWithTransparency;
  111014. /**
  111015. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111016. * Materials half opaque for instance using refraction could benefit from this control.
  111017. */
  111018. linkRefractionWithTransparency: boolean;
  111019. /**
  111020. * Defines the minimum thickness stored in the thickness map.
  111021. * If no thickness map is defined, this value will be used to simulate thickness.
  111022. */
  111023. minimumThickness: number;
  111024. /**
  111025. * Defines the maximum thickness stored in the thickness map.
  111026. */
  111027. maximumThickness: number;
  111028. /**
  111029. * Defines the volume tint of the material.
  111030. * This is used for both translucency and scattering.
  111031. */
  111032. tintColor: Color3;
  111033. /**
  111034. * Defines the distance at which the tint color should be found in the media.
  111035. * This is used for refraction only.
  111036. */
  111037. tintColorAtDistance: number;
  111038. /**
  111039. * Defines how far each channel transmit through the media.
  111040. * It is defined as a color to simplify it selection.
  111041. */
  111042. diffusionDistance: Color3;
  111043. private _useMaskFromThicknessTexture;
  111044. /**
  111045. * Stores the intensity of the different subsurface effects in the thickness texture.
  111046. * * the green channel is the translucency intensity.
  111047. * * the blue channel is the scattering intensity.
  111048. * * the alpha channel is the refraction intensity.
  111049. */
  111050. useMaskFromThicknessTexture: boolean;
  111051. /** @hidden */
  111052. private _internalMarkAllSubMeshesAsTexturesDirty;
  111053. /** @hidden */
  111054. _markAllSubMeshesAsTexturesDirty(): void;
  111055. /**
  111056. * Instantiate a new istance of sub surface configuration.
  111057. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111058. */
  111059. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111060. /**
  111061. * Gets wehter the submesh is ready to be used or not.
  111062. * @param defines the list of "defines" to update.
  111063. * @param scene defines the scene the material belongs to.
  111064. * @returns - boolean indicating that the submesh is ready or not.
  111065. */
  111066. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  111067. /**
  111068. * Checks to see if a texture is used in the material.
  111069. * @param defines the list of "defines" to update.
  111070. * @param scene defines the scene to the material belongs to.
  111071. */
  111072. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  111073. /**
  111074. * Binds the material data.
  111075. * @param uniformBuffer defines the Uniform buffer to fill in.
  111076. * @param scene defines the scene the material belongs to.
  111077. * @param engine defines the engine the material belongs to.
  111078. * @param isFrozen defines wether the material is frozen or not.
  111079. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  111080. */
  111081. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  111082. /**
  111083. * Unbinds the material from the mesh.
  111084. * @param activeEffect defines the effect that should be unbound from.
  111085. * @returns true if unbound, otherwise false
  111086. */
  111087. unbind(activeEffect: Effect): boolean;
  111088. /**
  111089. * Returns the texture used for refraction or null if none is used.
  111090. * @param scene defines the scene the material belongs to.
  111091. * @returns - Refraction texture if present. If no refraction texture and refraction
  111092. * is linked with transparency, returns environment texture. Otherwise, returns null.
  111093. */
  111094. private _getRefractionTexture;
  111095. /**
  111096. * Returns true if alpha blending should be disabled.
  111097. */
  111098. readonly disableAlphaBlending: boolean;
  111099. /**
  111100. * Fills the list of render target textures.
  111101. * @param renderTargets the list of render targets to update
  111102. */
  111103. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  111104. /**
  111105. * Checks to see if a texture is used in the material.
  111106. * @param texture - Base texture to use.
  111107. * @returns - Boolean specifying if a texture is used in the material.
  111108. */
  111109. hasTexture(texture: BaseTexture): boolean;
  111110. /**
  111111. * Gets a boolean indicating that current material needs to register RTT
  111112. * @returns true if this uses a render target otherwise false.
  111113. */
  111114. hasRenderTargetTextures(): boolean;
  111115. /**
  111116. * Returns an array of the actively used textures.
  111117. * @param activeTextures Array of BaseTextures
  111118. */
  111119. getActiveTextures(activeTextures: BaseTexture[]): void;
  111120. /**
  111121. * Returns the animatable textures.
  111122. * @param animatables Array of animatable textures.
  111123. */
  111124. getAnimatables(animatables: IAnimatable[]): void;
  111125. /**
  111126. * Disposes the resources of the material.
  111127. * @param forceDisposeTextures - Forces the disposal of all textures.
  111128. */
  111129. dispose(forceDisposeTextures?: boolean): void;
  111130. /**
  111131. * Get the current class name of the texture useful for serialization or dynamic coding.
  111132. * @returns "PBRSubSurfaceConfiguration"
  111133. */
  111134. getClassName(): string;
  111135. /**
  111136. * Add fallbacks to the effect fallbacks list.
  111137. * @param defines defines the Base texture to use.
  111138. * @param fallbacks defines the current fallback list.
  111139. * @param currentRank defines the current fallback rank.
  111140. * @returns the new fallback rank.
  111141. */
  111142. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111143. /**
  111144. * Add the required uniforms to the current list.
  111145. * @param uniforms defines the current uniform list.
  111146. */
  111147. static AddUniforms(uniforms: string[]): void;
  111148. /**
  111149. * Add the required samplers to the current list.
  111150. * @param samplers defines the current sampler list.
  111151. */
  111152. static AddSamplers(samplers: string[]): void;
  111153. /**
  111154. * Add the required uniforms to the current buffer.
  111155. * @param uniformBuffer defines the current uniform buffer.
  111156. */
  111157. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111158. /**
  111159. * Makes a duplicate of the current configuration into another one.
  111160. * @param configuration define the config where to copy the info
  111161. */
  111162. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  111163. /**
  111164. * Serializes this Sub Surface configuration.
  111165. * @returns - An object with the serialized config.
  111166. */
  111167. serialize(): any;
  111168. /**
  111169. * Parses a anisotropy Configuration from a serialized object.
  111170. * @param source - Serialized object.
  111171. * @param scene Defines the scene we are parsing for
  111172. * @param rootUrl Defines the rootUrl to load from
  111173. */
  111174. parse(source: any, scene: Scene, rootUrl: string): void;
  111175. }
  111176. }
  111177. declare module BABYLON {
  111178. /** @hidden */
  111179. export var pbrFragmentDeclaration: {
  111180. name: string;
  111181. shader: string;
  111182. };
  111183. }
  111184. declare module BABYLON {
  111185. /** @hidden */
  111186. export var pbrUboDeclaration: {
  111187. name: string;
  111188. shader: string;
  111189. };
  111190. }
  111191. declare module BABYLON {
  111192. /** @hidden */
  111193. export var pbrFragmentExtraDeclaration: {
  111194. name: string;
  111195. shader: string;
  111196. };
  111197. }
  111198. declare module BABYLON {
  111199. /** @hidden */
  111200. export var pbrFragmentSamplersDeclaration: {
  111201. name: string;
  111202. shader: string;
  111203. };
  111204. }
  111205. declare module BABYLON {
  111206. /** @hidden */
  111207. export var pbrHelperFunctions: {
  111208. name: string;
  111209. shader: string;
  111210. };
  111211. }
  111212. declare module BABYLON {
  111213. /** @hidden */
  111214. export var harmonicsFunctions: {
  111215. name: string;
  111216. shader: string;
  111217. };
  111218. }
  111219. declare module BABYLON {
  111220. /** @hidden */
  111221. export var pbrDirectLightingSetupFunctions: {
  111222. name: string;
  111223. shader: string;
  111224. };
  111225. }
  111226. declare module BABYLON {
  111227. /** @hidden */
  111228. export var pbrDirectLightingFalloffFunctions: {
  111229. name: string;
  111230. shader: string;
  111231. };
  111232. }
  111233. declare module BABYLON {
  111234. /** @hidden */
  111235. export var pbrBRDFFunctions: {
  111236. name: string;
  111237. shader: string;
  111238. };
  111239. }
  111240. declare module BABYLON {
  111241. /** @hidden */
  111242. export var pbrDirectLightingFunctions: {
  111243. name: string;
  111244. shader: string;
  111245. };
  111246. }
  111247. declare module BABYLON {
  111248. /** @hidden */
  111249. export var pbrIBLFunctions: {
  111250. name: string;
  111251. shader: string;
  111252. };
  111253. }
  111254. declare module BABYLON {
  111255. /** @hidden */
  111256. export var pbrDebug: {
  111257. name: string;
  111258. shader: string;
  111259. };
  111260. }
  111261. declare module BABYLON {
  111262. /** @hidden */
  111263. export var pbrPixelShader: {
  111264. name: string;
  111265. shader: string;
  111266. };
  111267. }
  111268. declare module BABYLON {
  111269. /** @hidden */
  111270. export var pbrVertexDeclaration: {
  111271. name: string;
  111272. shader: string;
  111273. };
  111274. }
  111275. declare module BABYLON {
  111276. /** @hidden */
  111277. export var pbrVertexShader: {
  111278. name: string;
  111279. shader: string;
  111280. };
  111281. }
  111282. declare module BABYLON {
  111283. /**
  111284. * Manages the defines for the PBR Material.
  111285. * @hidden
  111286. */
  111287. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  111288. PBR: boolean;
  111289. MAINUV1: boolean;
  111290. MAINUV2: boolean;
  111291. UV1: boolean;
  111292. UV2: boolean;
  111293. ALBEDO: boolean;
  111294. ALBEDODIRECTUV: number;
  111295. VERTEXCOLOR: boolean;
  111296. AMBIENT: boolean;
  111297. AMBIENTDIRECTUV: number;
  111298. AMBIENTINGRAYSCALE: boolean;
  111299. OPACITY: boolean;
  111300. VERTEXALPHA: boolean;
  111301. OPACITYDIRECTUV: number;
  111302. OPACITYRGB: boolean;
  111303. ALPHATEST: boolean;
  111304. DEPTHPREPASS: boolean;
  111305. ALPHABLEND: boolean;
  111306. ALPHAFROMALBEDO: boolean;
  111307. ALPHATESTVALUE: string;
  111308. SPECULAROVERALPHA: boolean;
  111309. RADIANCEOVERALPHA: boolean;
  111310. ALPHAFRESNEL: boolean;
  111311. LINEARALPHAFRESNEL: boolean;
  111312. PREMULTIPLYALPHA: boolean;
  111313. EMISSIVE: boolean;
  111314. EMISSIVEDIRECTUV: number;
  111315. REFLECTIVITY: boolean;
  111316. REFLECTIVITYDIRECTUV: number;
  111317. SPECULARTERM: boolean;
  111318. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  111319. MICROSURFACEAUTOMATIC: boolean;
  111320. LODBASEDMICROSFURACE: boolean;
  111321. MICROSURFACEMAP: boolean;
  111322. MICROSURFACEMAPDIRECTUV: number;
  111323. METALLICWORKFLOW: boolean;
  111324. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  111325. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  111326. METALLNESSSTOREINMETALMAPBLUE: boolean;
  111327. AOSTOREINMETALMAPRED: boolean;
  111328. ENVIRONMENTBRDF: boolean;
  111329. ENVIRONMENTBRDF_RGBD: boolean;
  111330. NORMAL: boolean;
  111331. TANGENT: boolean;
  111332. BUMP: boolean;
  111333. BUMPDIRECTUV: number;
  111334. OBJECTSPACE_NORMALMAP: boolean;
  111335. PARALLAX: boolean;
  111336. PARALLAXOCCLUSION: boolean;
  111337. NORMALXYSCALE: boolean;
  111338. LIGHTMAP: boolean;
  111339. LIGHTMAPDIRECTUV: number;
  111340. USELIGHTMAPASSHADOWMAP: boolean;
  111341. GAMMALIGHTMAP: boolean;
  111342. REFLECTION: boolean;
  111343. REFLECTIONMAP_3D: boolean;
  111344. REFLECTIONMAP_SPHERICAL: boolean;
  111345. REFLECTIONMAP_PLANAR: boolean;
  111346. REFLECTIONMAP_CUBIC: boolean;
  111347. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  111348. REFLECTIONMAP_PROJECTION: boolean;
  111349. REFLECTIONMAP_SKYBOX: boolean;
  111350. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  111351. REFLECTIONMAP_EXPLICIT: boolean;
  111352. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  111353. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  111354. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  111355. INVERTCUBICMAP: boolean;
  111356. USESPHERICALFROMREFLECTIONMAP: boolean;
  111357. USEIRRADIANCEMAP: boolean;
  111358. SPHERICAL_HARMONICS: boolean;
  111359. USESPHERICALINVERTEX: boolean;
  111360. REFLECTIONMAP_OPPOSITEZ: boolean;
  111361. LODINREFLECTIONALPHA: boolean;
  111362. GAMMAREFLECTION: boolean;
  111363. RGBDREFLECTION: boolean;
  111364. LINEARSPECULARREFLECTION: boolean;
  111365. RADIANCEOCCLUSION: boolean;
  111366. HORIZONOCCLUSION: boolean;
  111367. INSTANCES: boolean;
  111368. NUM_BONE_INFLUENCERS: number;
  111369. BonesPerMesh: number;
  111370. BONETEXTURE: boolean;
  111371. NONUNIFORMSCALING: boolean;
  111372. MORPHTARGETS: boolean;
  111373. MORPHTARGETS_NORMAL: boolean;
  111374. MORPHTARGETS_TANGENT: boolean;
  111375. MORPHTARGETS_UV: boolean;
  111376. NUM_MORPH_INFLUENCERS: number;
  111377. IMAGEPROCESSING: boolean;
  111378. VIGNETTE: boolean;
  111379. VIGNETTEBLENDMODEMULTIPLY: boolean;
  111380. VIGNETTEBLENDMODEOPAQUE: boolean;
  111381. TONEMAPPING: boolean;
  111382. TONEMAPPING_ACES: boolean;
  111383. CONTRAST: boolean;
  111384. COLORCURVES: boolean;
  111385. COLORGRADING: boolean;
  111386. COLORGRADING3D: boolean;
  111387. SAMPLER3DGREENDEPTH: boolean;
  111388. SAMPLER3DBGRMAP: boolean;
  111389. IMAGEPROCESSINGPOSTPROCESS: boolean;
  111390. EXPOSURE: boolean;
  111391. MULTIVIEW: boolean;
  111392. USEPHYSICALLIGHTFALLOFF: boolean;
  111393. USEGLTFLIGHTFALLOFF: boolean;
  111394. TWOSIDEDLIGHTING: boolean;
  111395. SHADOWFLOAT: boolean;
  111396. CLIPPLANE: boolean;
  111397. CLIPPLANE2: boolean;
  111398. CLIPPLANE3: boolean;
  111399. CLIPPLANE4: boolean;
  111400. POINTSIZE: boolean;
  111401. FOG: boolean;
  111402. LOGARITHMICDEPTH: boolean;
  111403. FORCENORMALFORWARD: boolean;
  111404. SPECULARAA: boolean;
  111405. CLEARCOAT: boolean;
  111406. CLEARCOAT_DEFAULTIOR: boolean;
  111407. CLEARCOAT_TEXTURE: boolean;
  111408. CLEARCOAT_TEXTUREDIRECTUV: number;
  111409. CLEARCOAT_BUMP: boolean;
  111410. CLEARCOAT_BUMPDIRECTUV: number;
  111411. CLEARCOAT_TINT: boolean;
  111412. CLEARCOAT_TINT_TEXTURE: boolean;
  111413. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111414. ANISOTROPIC: boolean;
  111415. ANISOTROPIC_TEXTURE: boolean;
  111416. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111417. BRDF_V_HEIGHT_CORRELATED: boolean;
  111418. MS_BRDF_ENERGY_CONSERVATION: boolean;
  111419. SHEEN: boolean;
  111420. SHEEN_TEXTURE: boolean;
  111421. SHEEN_TEXTUREDIRECTUV: number;
  111422. SHEEN_LINKWITHALBEDO: boolean;
  111423. SUBSURFACE: boolean;
  111424. SS_REFRACTION: boolean;
  111425. SS_TRANSLUCENCY: boolean;
  111426. SS_SCATERRING: boolean;
  111427. SS_THICKNESSANDMASK_TEXTURE: boolean;
  111428. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  111429. SS_REFRACTIONMAP_3D: boolean;
  111430. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  111431. SS_LODINREFRACTIONALPHA: boolean;
  111432. SS_GAMMAREFRACTION: boolean;
  111433. SS_RGBDREFRACTION: boolean;
  111434. SS_LINEARSPECULARREFRACTION: boolean;
  111435. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  111436. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  111437. UNLIT: boolean;
  111438. DEBUGMODE: number;
  111439. /**
  111440. * Initializes the PBR Material defines.
  111441. */
  111442. constructor();
  111443. /**
  111444. * Resets the PBR Material defines.
  111445. */
  111446. reset(): void;
  111447. }
  111448. /**
  111449. * The Physically based material base class of BJS.
  111450. *
  111451. * This offers the main features of a standard PBR material.
  111452. * For more information, please refer to the documentation :
  111453. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111454. */
  111455. export abstract class PBRBaseMaterial extends PushMaterial {
  111456. /**
  111457. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111458. */
  111459. static readonly PBRMATERIAL_OPAQUE: number;
  111460. /**
  111461. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111462. */
  111463. static readonly PBRMATERIAL_ALPHATEST: number;
  111464. /**
  111465. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111466. */
  111467. static readonly PBRMATERIAL_ALPHABLEND: number;
  111468. /**
  111469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111470. * They are also discarded below the alpha cutoff threshold to improve performances.
  111471. */
  111472. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111473. /**
  111474. * Defines the default value of how much AO map is occluding the analytical lights
  111475. * (point spot...).
  111476. */
  111477. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111478. /**
  111479. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  111480. */
  111481. static readonly LIGHTFALLOFF_PHYSICAL: number;
  111482. /**
  111483. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  111484. * to enhance interoperability with other engines.
  111485. */
  111486. static readonly LIGHTFALLOFF_GLTF: number;
  111487. /**
  111488. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  111489. * to enhance interoperability with other materials.
  111490. */
  111491. static readonly LIGHTFALLOFF_STANDARD: number;
  111492. /**
  111493. * Intensity of the direct lights e.g. the four lights available in your scene.
  111494. * This impacts both the direct diffuse and specular highlights.
  111495. */
  111496. protected _directIntensity: number;
  111497. /**
  111498. * Intensity of the emissive part of the material.
  111499. * This helps controlling the emissive effect without modifying the emissive color.
  111500. */
  111501. protected _emissiveIntensity: number;
  111502. /**
  111503. * Intensity of the environment e.g. how much the environment will light the object
  111504. * either through harmonics for rough material or through the refelction for shiny ones.
  111505. */
  111506. protected _environmentIntensity: number;
  111507. /**
  111508. * This is a special control allowing the reduction of the specular highlights coming from the
  111509. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111510. */
  111511. protected _specularIntensity: number;
  111512. /**
  111513. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  111514. */
  111515. private _lightingInfos;
  111516. /**
  111517. * Debug Control allowing disabling the bump map on this material.
  111518. */
  111519. protected _disableBumpMap: boolean;
  111520. /**
  111521. * AKA Diffuse Texture in standard nomenclature.
  111522. */
  111523. protected _albedoTexture: Nullable<BaseTexture>;
  111524. /**
  111525. * AKA Occlusion Texture in other nomenclature.
  111526. */
  111527. protected _ambientTexture: Nullable<BaseTexture>;
  111528. /**
  111529. * AKA Occlusion Texture Intensity in other nomenclature.
  111530. */
  111531. protected _ambientTextureStrength: number;
  111532. /**
  111533. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111534. * 1 means it completely occludes it
  111535. * 0 mean it has no impact
  111536. */
  111537. protected _ambientTextureImpactOnAnalyticalLights: number;
  111538. /**
  111539. * Stores the alpha values in a texture.
  111540. */
  111541. protected _opacityTexture: Nullable<BaseTexture>;
  111542. /**
  111543. * Stores the reflection values in a texture.
  111544. */
  111545. protected _reflectionTexture: Nullable<BaseTexture>;
  111546. /**
  111547. * Stores the emissive values in a texture.
  111548. */
  111549. protected _emissiveTexture: Nullable<BaseTexture>;
  111550. /**
  111551. * AKA Specular texture in other nomenclature.
  111552. */
  111553. protected _reflectivityTexture: Nullable<BaseTexture>;
  111554. /**
  111555. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111556. */
  111557. protected _metallicTexture: Nullable<BaseTexture>;
  111558. /**
  111559. * Specifies the metallic scalar of the metallic/roughness workflow.
  111560. * Can also be used to scale the metalness values of the metallic texture.
  111561. */
  111562. protected _metallic: Nullable<number>;
  111563. /**
  111564. * Specifies the roughness scalar of the metallic/roughness workflow.
  111565. * Can also be used to scale the roughness values of the metallic texture.
  111566. */
  111567. protected _roughness: Nullable<number>;
  111568. /**
  111569. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111570. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111571. */
  111572. protected _microSurfaceTexture: Nullable<BaseTexture>;
  111573. /**
  111574. * Stores surface normal data used to displace a mesh in a texture.
  111575. */
  111576. protected _bumpTexture: Nullable<BaseTexture>;
  111577. /**
  111578. * Stores the pre-calculated light information of a mesh in a texture.
  111579. */
  111580. protected _lightmapTexture: Nullable<BaseTexture>;
  111581. /**
  111582. * The color of a material in ambient lighting.
  111583. */
  111584. protected _ambientColor: Color3;
  111585. /**
  111586. * AKA Diffuse Color in other nomenclature.
  111587. */
  111588. protected _albedoColor: Color3;
  111589. /**
  111590. * AKA Specular Color in other nomenclature.
  111591. */
  111592. protected _reflectivityColor: Color3;
  111593. /**
  111594. * The color applied when light is reflected from a material.
  111595. */
  111596. protected _reflectionColor: Color3;
  111597. /**
  111598. * The color applied when light is emitted from a material.
  111599. */
  111600. protected _emissiveColor: Color3;
  111601. /**
  111602. * AKA Glossiness in other nomenclature.
  111603. */
  111604. protected _microSurface: number;
  111605. /**
  111606. * Specifies that the material will use the light map as a show map.
  111607. */
  111608. protected _useLightmapAsShadowmap: boolean;
  111609. /**
  111610. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111611. * makes the reflect vector face the model (under horizon).
  111612. */
  111613. protected _useHorizonOcclusion: boolean;
  111614. /**
  111615. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111616. * too much the area relying on ambient texture to define their ambient occlusion.
  111617. */
  111618. protected _useRadianceOcclusion: boolean;
  111619. /**
  111620. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111621. */
  111622. protected _useAlphaFromAlbedoTexture: boolean;
  111623. /**
  111624. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  111625. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111626. */
  111627. protected _useSpecularOverAlpha: boolean;
  111628. /**
  111629. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111630. */
  111631. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111632. /**
  111633. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111634. */
  111635. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  111636. /**
  111637. * Specifies if the metallic texture contains the roughness information in its green channel.
  111638. */
  111639. protected _useRoughnessFromMetallicTextureGreen: boolean;
  111640. /**
  111641. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111642. */
  111643. protected _useMetallnessFromMetallicTextureBlue: boolean;
  111644. /**
  111645. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111646. */
  111647. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  111648. /**
  111649. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111650. */
  111651. protected _useAmbientInGrayScale: boolean;
  111652. /**
  111653. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111654. * The material will try to infer what glossiness each pixel should be.
  111655. */
  111656. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  111657. /**
  111658. * Defines the falloff type used in this material.
  111659. * It by default is Physical.
  111660. */
  111661. protected _lightFalloff: number;
  111662. /**
  111663. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111664. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111665. */
  111666. protected _useRadianceOverAlpha: boolean;
  111667. /**
  111668. * Allows using an object space normal map (instead of tangent space).
  111669. */
  111670. protected _useObjectSpaceNormalMap: boolean;
  111671. /**
  111672. * Allows using the bump map in parallax mode.
  111673. */
  111674. protected _useParallax: boolean;
  111675. /**
  111676. * Allows using the bump map in parallax occlusion mode.
  111677. */
  111678. protected _useParallaxOcclusion: boolean;
  111679. /**
  111680. * Controls the scale bias of the parallax mode.
  111681. */
  111682. protected _parallaxScaleBias: number;
  111683. /**
  111684. * If sets to true, disables all the lights affecting the material.
  111685. */
  111686. protected _disableLighting: boolean;
  111687. /**
  111688. * Number of Simultaneous lights allowed on the material.
  111689. */
  111690. protected _maxSimultaneousLights: number;
  111691. /**
  111692. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111693. */
  111694. protected _invertNormalMapX: boolean;
  111695. /**
  111696. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111697. */
  111698. protected _invertNormalMapY: boolean;
  111699. /**
  111700. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111701. */
  111702. protected _twoSidedLighting: boolean;
  111703. /**
  111704. * Defines the alpha limits in alpha test mode.
  111705. */
  111706. protected _alphaCutOff: number;
  111707. /**
  111708. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111709. */
  111710. protected _forceAlphaTest: boolean;
  111711. /**
  111712. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111713. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111714. */
  111715. protected _useAlphaFresnel: boolean;
  111716. /**
  111717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111718. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111719. */
  111720. protected _useLinearAlphaFresnel: boolean;
  111721. /**
  111722. * The transparency mode of the material.
  111723. */
  111724. protected _transparencyMode: Nullable<number>;
  111725. /**
  111726. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  111727. * from cos thetav and roughness:
  111728. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  111729. */
  111730. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  111731. /**
  111732. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111733. */
  111734. protected _forceIrradianceInFragment: boolean;
  111735. /**
  111736. * Force normal to face away from face.
  111737. */
  111738. protected _forceNormalForward: boolean;
  111739. /**
  111740. * Enables specular anti aliasing in the PBR shader.
  111741. * It will both interacts on the Geometry for analytical and IBL lighting.
  111742. * It also prefilter the roughness map based on the bump values.
  111743. */
  111744. protected _enableSpecularAntiAliasing: boolean;
  111745. /**
  111746. * Default configuration related to image processing available in the PBR Material.
  111747. */
  111748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111749. /**
  111750. * Keep track of the image processing observer to allow dispose and replace.
  111751. */
  111752. private _imageProcessingObserver;
  111753. /**
  111754. * Attaches a new image processing configuration to the PBR Material.
  111755. * @param configuration
  111756. */
  111757. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111758. /**
  111759. * Stores the available render targets.
  111760. */
  111761. private _renderTargets;
  111762. /**
  111763. * Sets the global ambient color for the material used in lighting calculations.
  111764. */
  111765. private _globalAmbientColor;
  111766. /**
  111767. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  111768. */
  111769. private _useLogarithmicDepth;
  111770. /**
  111771. * If set to true, no lighting calculations will be applied.
  111772. */
  111773. private _unlit;
  111774. private _debugMode;
  111775. /**
  111776. * @hidden
  111777. * This is reserved for the inspector.
  111778. * Defines the material debug mode.
  111779. * It helps seeing only some components of the material while troubleshooting.
  111780. */
  111781. debugMode: number;
  111782. /**
  111783. * @hidden
  111784. * This is reserved for the inspector.
  111785. * Specify from where on screen the debug mode should start.
  111786. * The value goes from -1 (full screen) to 1 (not visible)
  111787. * It helps with side by side comparison against the final render
  111788. * This defaults to -1
  111789. */
  111790. private debugLimit;
  111791. /**
  111792. * @hidden
  111793. * This is reserved for the inspector.
  111794. * As the default viewing range might not be enough (if the ambient is really small for instance)
  111795. * You can use the factor to better multiply the final value.
  111796. */
  111797. private debugFactor;
  111798. /**
  111799. * Defines the clear coat layer parameters for the material.
  111800. */
  111801. readonly clearCoat: PBRClearCoatConfiguration;
  111802. /**
  111803. * Defines the anisotropic parameters for the material.
  111804. */
  111805. readonly anisotropy: PBRAnisotropicConfiguration;
  111806. /**
  111807. * Defines the BRDF parameters for the material.
  111808. */
  111809. readonly brdf: PBRBRDFConfiguration;
  111810. /**
  111811. * Defines the Sheen parameters for the material.
  111812. */
  111813. readonly sheen: PBRSheenConfiguration;
  111814. /**
  111815. * Defines the SubSurface parameters for the material.
  111816. */
  111817. readonly subSurface: PBRSubSurfaceConfiguration;
  111818. /**
  111819. * Custom callback helping to override the default shader used in the material.
  111820. */
  111821. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  111822. protected _rebuildInParallel: boolean;
  111823. /**
  111824. * Instantiates a new PBRMaterial instance.
  111825. *
  111826. * @param name The material name
  111827. * @param scene The scene the material will be use in.
  111828. */
  111829. constructor(name: string, scene: Scene);
  111830. /**
  111831. * Gets a boolean indicating that current material needs to register RTT
  111832. */
  111833. readonly hasRenderTargetTextures: boolean;
  111834. /**
  111835. * Gets the name of the material class.
  111836. */
  111837. getClassName(): string;
  111838. /**
  111839. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111840. */
  111841. /**
  111842. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111843. */
  111844. useLogarithmicDepth: boolean;
  111845. /**
  111846. * Gets the current transparency mode.
  111847. */
  111848. /**
  111849. * Sets the transparency mode of the material.
  111850. *
  111851. * | Value | Type | Description |
  111852. * | ----- | ----------------------------------- | ----------- |
  111853. * | 0 | OPAQUE | |
  111854. * | 1 | ALPHATEST | |
  111855. * | 2 | ALPHABLEND | |
  111856. * | 3 | ALPHATESTANDBLEND | |
  111857. *
  111858. */
  111859. transparencyMode: Nullable<number>;
  111860. /**
  111861. * Returns true if alpha blending should be disabled.
  111862. */
  111863. private readonly _disableAlphaBlending;
  111864. /**
  111865. * Specifies whether or not this material should be rendered in alpha blend mode.
  111866. */
  111867. needAlphaBlending(): boolean;
  111868. /**
  111869. * Specifies if the mesh will require alpha blending.
  111870. * @param mesh - BJS mesh.
  111871. */
  111872. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111873. /**
  111874. * Specifies whether or not this material should be rendered in alpha test mode.
  111875. */
  111876. needAlphaTesting(): boolean;
  111877. /**
  111878. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  111879. */
  111880. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  111881. /**
  111882. * Gets the texture used for the alpha test.
  111883. */
  111884. getAlphaTestTexture(): Nullable<BaseTexture>;
  111885. /**
  111886. * Specifies that the submesh is ready to be used.
  111887. * @param mesh - BJS mesh.
  111888. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  111889. * @param useInstances - Specifies that instances should be used.
  111890. * @returns - boolean indicating that the submesh is ready or not.
  111891. */
  111892. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111893. /**
  111894. * Specifies if the material uses metallic roughness workflow.
  111895. * @returns boolean specifiying if the material uses metallic roughness workflow.
  111896. */
  111897. isMetallicWorkflow(): boolean;
  111898. private _prepareEffect;
  111899. private _prepareDefines;
  111900. /**
  111901. * Force shader compilation
  111902. */
  111903. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  111904. clipPlane: boolean;
  111905. }>): void;
  111906. /**
  111907. * Initializes the uniform buffer layout for the shader.
  111908. */
  111909. buildUniformLayout(): void;
  111910. /**
  111911. * Unbinds the material from the mesh
  111912. */
  111913. unbind(): void;
  111914. /**
  111915. * Binds the submesh data.
  111916. * @param world - The world matrix.
  111917. * @param mesh - The BJS mesh.
  111918. * @param subMesh - A submesh of the BJS mesh.
  111919. */
  111920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111921. /**
  111922. * Returns the animatable textures.
  111923. * @returns - Array of animatable textures.
  111924. */
  111925. getAnimatables(): IAnimatable[];
  111926. /**
  111927. * Returns the texture used for reflections.
  111928. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  111929. */
  111930. private _getReflectionTexture;
  111931. /**
  111932. * Returns an array of the actively used textures.
  111933. * @returns - Array of BaseTextures
  111934. */
  111935. getActiveTextures(): BaseTexture[];
  111936. /**
  111937. * Checks to see if a texture is used in the material.
  111938. * @param texture - Base texture to use.
  111939. * @returns - Boolean specifying if a texture is used in the material.
  111940. */
  111941. hasTexture(texture: BaseTexture): boolean;
  111942. /**
  111943. * Disposes the resources of the material.
  111944. * @param forceDisposeEffect - Forces the disposal of effects.
  111945. * @param forceDisposeTextures - Forces the disposal of all textures.
  111946. */
  111947. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111948. }
  111949. }
  111950. declare module BABYLON {
  111951. /**
  111952. * The Physically based material of BJS.
  111953. *
  111954. * This offers the main features of a standard PBR material.
  111955. * For more information, please refer to the documentation :
  111956. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111957. */
  111958. export class PBRMaterial extends PBRBaseMaterial {
  111959. /**
  111960. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111961. */
  111962. static readonly PBRMATERIAL_OPAQUE: number;
  111963. /**
  111964. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111965. */
  111966. static readonly PBRMATERIAL_ALPHATEST: number;
  111967. /**
  111968. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111969. */
  111970. static readonly PBRMATERIAL_ALPHABLEND: number;
  111971. /**
  111972. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111973. * They are also discarded below the alpha cutoff threshold to improve performances.
  111974. */
  111975. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111976. /**
  111977. * Defines the default value of how much AO map is occluding the analytical lights
  111978. * (point spot...).
  111979. */
  111980. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111981. /**
  111982. * Intensity of the direct lights e.g. the four lights available in your scene.
  111983. * This impacts both the direct diffuse and specular highlights.
  111984. */
  111985. directIntensity: number;
  111986. /**
  111987. * Intensity of the emissive part of the material.
  111988. * This helps controlling the emissive effect without modifying the emissive color.
  111989. */
  111990. emissiveIntensity: number;
  111991. /**
  111992. * Intensity of the environment e.g. how much the environment will light the object
  111993. * either through harmonics for rough material or through the refelction for shiny ones.
  111994. */
  111995. environmentIntensity: number;
  111996. /**
  111997. * This is a special control allowing the reduction of the specular highlights coming from the
  111998. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111999. */
  112000. specularIntensity: number;
  112001. /**
  112002. * Debug Control allowing disabling the bump map on this material.
  112003. */
  112004. disableBumpMap: boolean;
  112005. /**
  112006. * AKA Diffuse Texture in standard nomenclature.
  112007. */
  112008. albedoTexture: BaseTexture;
  112009. /**
  112010. * AKA Occlusion Texture in other nomenclature.
  112011. */
  112012. ambientTexture: BaseTexture;
  112013. /**
  112014. * AKA Occlusion Texture Intensity in other nomenclature.
  112015. */
  112016. ambientTextureStrength: number;
  112017. /**
  112018. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112019. * 1 means it completely occludes it
  112020. * 0 mean it has no impact
  112021. */
  112022. ambientTextureImpactOnAnalyticalLights: number;
  112023. /**
  112024. * Stores the alpha values in a texture.
  112025. */
  112026. opacityTexture: BaseTexture;
  112027. /**
  112028. * Stores the reflection values in a texture.
  112029. */
  112030. reflectionTexture: Nullable<BaseTexture>;
  112031. /**
  112032. * Stores the emissive values in a texture.
  112033. */
  112034. emissiveTexture: BaseTexture;
  112035. /**
  112036. * AKA Specular texture in other nomenclature.
  112037. */
  112038. reflectivityTexture: BaseTexture;
  112039. /**
  112040. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112041. */
  112042. metallicTexture: BaseTexture;
  112043. /**
  112044. * Specifies the metallic scalar of the metallic/roughness workflow.
  112045. * Can also be used to scale the metalness values of the metallic texture.
  112046. */
  112047. metallic: Nullable<number>;
  112048. /**
  112049. * Specifies the roughness scalar of the metallic/roughness workflow.
  112050. * Can also be used to scale the roughness values of the metallic texture.
  112051. */
  112052. roughness: Nullable<number>;
  112053. /**
  112054. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112055. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112056. */
  112057. microSurfaceTexture: BaseTexture;
  112058. /**
  112059. * Stores surface normal data used to displace a mesh in a texture.
  112060. */
  112061. bumpTexture: BaseTexture;
  112062. /**
  112063. * Stores the pre-calculated light information of a mesh in a texture.
  112064. */
  112065. lightmapTexture: BaseTexture;
  112066. /**
  112067. * Stores the refracted light information in a texture.
  112068. */
  112069. refractionTexture: Nullable<BaseTexture>;
  112070. /**
  112071. * The color of a material in ambient lighting.
  112072. */
  112073. ambientColor: Color3;
  112074. /**
  112075. * AKA Diffuse Color in other nomenclature.
  112076. */
  112077. albedoColor: Color3;
  112078. /**
  112079. * AKA Specular Color in other nomenclature.
  112080. */
  112081. reflectivityColor: Color3;
  112082. /**
  112083. * The color reflected from the material.
  112084. */
  112085. reflectionColor: Color3;
  112086. /**
  112087. * The color emitted from the material.
  112088. */
  112089. emissiveColor: Color3;
  112090. /**
  112091. * AKA Glossiness in other nomenclature.
  112092. */
  112093. microSurface: number;
  112094. /**
  112095. * source material index of refraction (IOR)' / 'destination material IOR.
  112096. */
  112097. indexOfRefraction: number;
  112098. /**
  112099. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112100. */
  112101. invertRefractionY: boolean;
  112102. /**
  112103. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112104. * Materials half opaque for instance using refraction could benefit from this control.
  112105. */
  112106. linkRefractionWithTransparency: boolean;
  112107. /**
  112108. * If true, the light map contains occlusion information instead of lighting info.
  112109. */
  112110. useLightmapAsShadowmap: boolean;
  112111. /**
  112112. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112113. */
  112114. useAlphaFromAlbedoTexture: boolean;
  112115. /**
  112116. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  112117. */
  112118. forceAlphaTest: boolean;
  112119. /**
  112120. * Defines the alpha limits in alpha test mode.
  112121. */
  112122. alphaCutOff: number;
  112123. /**
  112124. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  112125. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112126. */
  112127. useSpecularOverAlpha: boolean;
  112128. /**
  112129. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112130. */
  112131. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112132. /**
  112133. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112134. */
  112135. useRoughnessFromMetallicTextureAlpha: boolean;
  112136. /**
  112137. * Specifies if the metallic texture contains the roughness information in its green channel.
  112138. */
  112139. useRoughnessFromMetallicTextureGreen: boolean;
  112140. /**
  112141. * Specifies if the metallic texture contains the metallness information in its blue channel.
  112142. */
  112143. useMetallnessFromMetallicTextureBlue: boolean;
  112144. /**
  112145. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  112146. */
  112147. useAmbientOcclusionFromMetallicTextureRed: boolean;
  112148. /**
  112149. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  112150. */
  112151. useAmbientInGrayScale: boolean;
  112152. /**
  112153. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  112154. * The material will try to infer what glossiness each pixel should be.
  112155. */
  112156. useAutoMicroSurfaceFromReflectivityMap: boolean;
  112157. /**
  112158. * BJS is using an harcoded light falloff based on a manually sets up range.
  112159. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  112160. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  112161. */
  112162. /**
  112163. * BJS is using an harcoded light falloff based on a manually sets up range.
  112164. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  112165. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  112166. */
  112167. usePhysicalLightFalloff: boolean;
  112168. /**
  112169. * In order to support the falloff compatibility with gltf, a special mode has been added
  112170. * to reproduce the gltf light falloff.
  112171. */
  112172. /**
  112173. * In order to support the falloff compatibility with gltf, a special mode has been added
  112174. * to reproduce the gltf light falloff.
  112175. */
  112176. useGLTFLightFalloff: boolean;
  112177. /**
  112178. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  112179. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  112180. */
  112181. useRadianceOverAlpha: boolean;
  112182. /**
  112183. * Allows using an object space normal map (instead of tangent space).
  112184. */
  112185. useObjectSpaceNormalMap: boolean;
  112186. /**
  112187. * Allows using the bump map in parallax mode.
  112188. */
  112189. useParallax: boolean;
  112190. /**
  112191. * Allows using the bump map in parallax occlusion mode.
  112192. */
  112193. useParallaxOcclusion: boolean;
  112194. /**
  112195. * Controls the scale bias of the parallax mode.
  112196. */
  112197. parallaxScaleBias: number;
  112198. /**
  112199. * If sets to true, disables all the lights affecting the material.
  112200. */
  112201. disableLighting: boolean;
  112202. /**
  112203. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  112204. */
  112205. forceIrradianceInFragment: boolean;
  112206. /**
  112207. * Number of Simultaneous lights allowed on the material.
  112208. */
  112209. maxSimultaneousLights: number;
  112210. /**
  112211. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112212. */
  112213. invertNormalMapX: boolean;
  112214. /**
  112215. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112216. */
  112217. invertNormalMapY: boolean;
  112218. /**
  112219. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112220. */
  112221. twoSidedLighting: boolean;
  112222. /**
  112223. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112224. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  112225. */
  112226. useAlphaFresnel: boolean;
  112227. /**
  112228. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112229. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  112230. */
  112231. useLinearAlphaFresnel: boolean;
  112232. /**
  112233. * Let user defines the brdf lookup texture used for IBL.
  112234. * A default 8bit version is embedded but you could point at :
  112235. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  112236. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  112237. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  112238. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  112239. */
  112240. environmentBRDFTexture: Nullable<BaseTexture>;
  112241. /**
  112242. * Force normal to face away from face.
  112243. */
  112244. forceNormalForward: boolean;
  112245. /**
  112246. * Enables specular anti aliasing in the PBR shader.
  112247. * It will both interacts on the Geometry for analytical and IBL lighting.
  112248. * It also prefilter the roughness map based on the bump values.
  112249. */
  112250. enableSpecularAntiAliasing: boolean;
  112251. /**
  112252. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112253. * makes the reflect vector face the model (under horizon).
  112254. */
  112255. useHorizonOcclusion: boolean;
  112256. /**
  112257. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112258. * too much the area relying on ambient texture to define their ambient occlusion.
  112259. */
  112260. useRadianceOcclusion: boolean;
  112261. /**
  112262. * If set to true, no lighting calculations will be applied.
  112263. */
  112264. unlit: boolean;
  112265. /**
  112266. * Gets the image processing configuration used either in this material.
  112267. */
  112268. /**
  112269. * Sets the Default image processing configuration used either in the this material.
  112270. *
  112271. * If sets to null, the scene one is in use.
  112272. */
  112273. imageProcessingConfiguration: ImageProcessingConfiguration;
  112274. /**
  112275. * Gets wether the color curves effect is enabled.
  112276. */
  112277. /**
  112278. * Sets wether the color curves effect is enabled.
  112279. */
  112280. cameraColorCurvesEnabled: boolean;
  112281. /**
  112282. * Gets wether the color grading effect is enabled.
  112283. */
  112284. /**
  112285. * Gets wether the color grading effect is enabled.
  112286. */
  112287. cameraColorGradingEnabled: boolean;
  112288. /**
  112289. * Gets wether tonemapping is enabled or not.
  112290. */
  112291. /**
  112292. * Sets wether tonemapping is enabled or not
  112293. */
  112294. cameraToneMappingEnabled: boolean;
  112295. /**
  112296. * The camera exposure used on this material.
  112297. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112298. * This corresponds to a photographic exposure.
  112299. */
  112300. /**
  112301. * The camera exposure used on this material.
  112302. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112303. * This corresponds to a photographic exposure.
  112304. */
  112305. cameraExposure: number;
  112306. /**
  112307. * Gets The camera contrast used on this material.
  112308. */
  112309. /**
  112310. * Sets The camera contrast used on this material.
  112311. */
  112312. cameraContrast: number;
  112313. /**
  112314. * Gets the Color Grading 2D Lookup Texture.
  112315. */
  112316. /**
  112317. * Sets the Color Grading 2D Lookup Texture.
  112318. */
  112319. cameraColorGradingTexture: Nullable<BaseTexture>;
  112320. /**
  112321. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112322. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112323. * 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;
  112324. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112325. */
  112326. /**
  112327. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112328. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112329. * 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;
  112330. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112331. */
  112332. cameraColorCurves: Nullable<ColorCurves>;
  112333. /**
  112334. * Instantiates a new PBRMaterial instance.
  112335. *
  112336. * @param name The material name
  112337. * @param scene The scene the material will be use in.
  112338. */
  112339. constructor(name: string, scene: Scene);
  112340. /**
  112341. * Returns the name of this material class.
  112342. */
  112343. getClassName(): string;
  112344. /**
  112345. * Makes a duplicate of the current material.
  112346. * @param name - name to use for the new material.
  112347. */
  112348. clone(name: string): PBRMaterial;
  112349. /**
  112350. * Serializes this PBR Material.
  112351. * @returns - An object with the serialized material.
  112352. */
  112353. serialize(): any;
  112354. /**
  112355. * Parses a PBR Material from a serialized object.
  112356. * @param source - Serialized object.
  112357. * @param scene - BJS scene instance.
  112358. * @param rootUrl - url for the scene object
  112359. * @returns - PBRMaterial
  112360. */
  112361. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  112362. }
  112363. }
  112364. declare module BABYLON {
  112365. /**
  112366. * Direct draw surface info
  112367. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  112368. */
  112369. export interface DDSInfo {
  112370. /**
  112371. * Width of the texture
  112372. */
  112373. width: number;
  112374. /**
  112375. * Width of the texture
  112376. */
  112377. height: number;
  112378. /**
  112379. * Number of Mipmaps for the texture
  112380. * @see https://en.wikipedia.org/wiki/Mipmap
  112381. */
  112382. mipmapCount: number;
  112383. /**
  112384. * If the textures format is a known fourCC format
  112385. * @see https://www.fourcc.org/
  112386. */
  112387. isFourCC: boolean;
  112388. /**
  112389. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  112390. */
  112391. isRGB: boolean;
  112392. /**
  112393. * If the texture is a lumincance format
  112394. */
  112395. isLuminance: boolean;
  112396. /**
  112397. * If this is a cube texture
  112398. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  112399. */
  112400. isCube: boolean;
  112401. /**
  112402. * If the texture is a compressed format eg. FOURCC_DXT1
  112403. */
  112404. isCompressed: boolean;
  112405. /**
  112406. * The dxgiFormat of the texture
  112407. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  112408. */
  112409. dxgiFormat: number;
  112410. /**
  112411. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  112412. */
  112413. textureType: number;
  112414. /**
  112415. * Sphericle polynomial created for the dds texture
  112416. */
  112417. sphericalPolynomial?: SphericalPolynomial;
  112418. }
  112419. /**
  112420. * Class used to provide DDS decompression tools
  112421. */
  112422. export class DDSTools {
  112423. /**
  112424. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  112425. */
  112426. static StoreLODInAlphaChannel: boolean;
  112427. /**
  112428. * Gets DDS information from an array buffer
  112429. * @param arrayBuffer defines the array buffer to read data from
  112430. * @returns the DDS information
  112431. */
  112432. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  112433. private static _FloatView;
  112434. private static _Int32View;
  112435. private static _ToHalfFloat;
  112436. private static _FromHalfFloat;
  112437. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  112438. private static _GetHalfFloatRGBAArrayBuffer;
  112439. private static _GetFloatRGBAArrayBuffer;
  112440. private static _GetFloatAsUIntRGBAArrayBuffer;
  112441. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  112442. private static _GetRGBAArrayBuffer;
  112443. private static _ExtractLongWordOrder;
  112444. private static _GetRGBArrayBuffer;
  112445. private static _GetLuminanceArrayBuffer;
  112446. /**
  112447. * Uploads DDS Levels to a Babylon Texture
  112448. * @hidden
  112449. */
  112450. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  112451. }
  112452. interface Engine {
  112453. /**
  112454. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  112455. * @param rootUrl defines the url where the file to load is located
  112456. * @param scene defines the current scene
  112457. * @param lodScale defines scale to apply to the mip map selection
  112458. * @param lodOffset defines offset to apply to the mip map selection
  112459. * @param onLoad defines an optional callback raised when the texture is loaded
  112460. * @param onError defines an optional callback raised if there is an issue to load the texture
  112461. * @param format defines the format of the data
  112462. * @param forcedExtension defines the extension to use to pick the right loader
  112463. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  112464. * @returns the cube texture as an InternalTexture
  112465. */
  112466. 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;
  112467. }
  112468. }
  112469. declare module BABYLON {
  112470. /**
  112471. * Implementation of the DDS Texture Loader.
  112472. * @hidden
  112473. */
  112474. export class _DDSTextureLoader implements IInternalTextureLoader {
  112475. /**
  112476. * Defines wether the loader supports cascade loading the different faces.
  112477. */
  112478. readonly supportCascades: boolean;
  112479. /**
  112480. * This returns if the loader support the current file information.
  112481. * @param extension defines the file extension of the file being loaded
  112482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112483. * @param fallback defines the fallback internal texture if any
  112484. * @param isBase64 defines whether the texture is encoded as a base64
  112485. * @param isBuffer defines whether the texture data are stored as a buffer
  112486. * @returns true if the loader can load the specified file
  112487. */
  112488. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112489. /**
  112490. * Transform the url before loading if required.
  112491. * @param rootUrl the url of the texture
  112492. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112493. * @returns the transformed texture
  112494. */
  112495. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112496. /**
  112497. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112498. * @param rootUrl the url of the texture
  112499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112500. * @returns the fallback texture
  112501. */
  112502. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112503. /**
  112504. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112505. * @param data contains the texture data
  112506. * @param texture defines the BabylonJS internal texture
  112507. * @param createPolynomials will be true if polynomials have been requested
  112508. * @param onLoad defines the callback to trigger once the texture is ready
  112509. * @param onError defines the callback to trigger in case of error
  112510. */
  112511. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112512. /**
  112513. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112514. * @param data contains the texture data
  112515. * @param texture defines the BabylonJS internal texture
  112516. * @param callback defines the method to call once ready to upload
  112517. */
  112518. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112519. }
  112520. }
  112521. declare module BABYLON {
  112522. /** @hidden */
  112523. export var rgbdEncodePixelShader: {
  112524. name: string;
  112525. shader: string;
  112526. };
  112527. }
  112528. declare module BABYLON {
  112529. /**
  112530. * Raw texture data and descriptor sufficient for WebGL texture upload
  112531. */
  112532. export interface EnvironmentTextureInfo {
  112533. /**
  112534. * Version of the environment map
  112535. */
  112536. version: number;
  112537. /**
  112538. * Width of image
  112539. */
  112540. width: number;
  112541. /**
  112542. * Irradiance information stored in the file.
  112543. */
  112544. irradiance: any;
  112545. /**
  112546. * Specular information stored in the file.
  112547. */
  112548. specular: any;
  112549. }
  112550. /**
  112551. * Sets of helpers addressing the serialization and deserialization of environment texture
  112552. * stored in a BabylonJS env file.
  112553. * Those files are usually stored as .env files.
  112554. */
  112555. export class EnvironmentTextureTools {
  112556. /**
  112557. * Magic number identifying the env file.
  112558. */
  112559. private static _MagicBytes;
  112560. /**
  112561. * Gets the environment info from an env file.
  112562. * @param data The array buffer containing the .env bytes.
  112563. * @returns the environment file info (the json header) if successfully parsed.
  112564. */
  112565. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112566. /**
  112567. * Creates an environment texture from a loaded cube texture.
  112568. * @param texture defines the cube texture to convert in env file
  112569. * @return a promise containing the environment data if succesfull.
  112570. */
  112571. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112572. /**
  112573. * Creates a JSON representation of the spherical data.
  112574. * @param texture defines the texture containing the polynomials
  112575. * @return the JSON representation of the spherical info
  112576. */
  112577. private static _CreateEnvTextureIrradiance;
  112578. /**
  112579. * Uploads the texture info contained in the env file to the GPU.
  112580. * @param texture defines the internal texture to upload to
  112581. * @param arrayBuffer defines the buffer cotaining the data to load
  112582. * @param info defines the texture info retrieved through the GetEnvInfo method
  112583. * @returns a promise
  112584. */
  112585. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112586. /**
  112587. * Uploads the levels of image data to the GPU.
  112588. * @param texture defines the internal texture to upload to
  112589. * @param imageData defines the array buffer views of image data [mipmap][face]
  112590. * @returns a promise
  112591. */
  112592. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112593. /**
  112594. * Uploads spherical polynomials information to the texture.
  112595. * @param texture defines the texture we are trying to upload the information to
  112596. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112597. */
  112598. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112599. /** @hidden */
  112600. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112601. }
  112602. }
  112603. declare module BABYLON {
  112604. /**
  112605. * Implementation of the ENV Texture Loader.
  112606. * @hidden
  112607. */
  112608. export class _ENVTextureLoader implements IInternalTextureLoader {
  112609. /**
  112610. * Defines wether the loader supports cascade loading the different faces.
  112611. */
  112612. readonly supportCascades: boolean;
  112613. /**
  112614. * This returns if the loader support the current file information.
  112615. * @param extension defines the file extension of the file being loaded
  112616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112617. * @param fallback defines the fallback internal texture if any
  112618. * @param isBase64 defines whether the texture is encoded as a base64
  112619. * @param isBuffer defines whether the texture data are stored as a buffer
  112620. * @returns true if the loader can load the specified file
  112621. */
  112622. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112623. /**
  112624. * Transform the url before loading if required.
  112625. * @param rootUrl the url of the texture
  112626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112627. * @returns the transformed texture
  112628. */
  112629. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112630. /**
  112631. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112632. * @param rootUrl the url of the texture
  112633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112634. * @returns the fallback texture
  112635. */
  112636. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112637. /**
  112638. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112639. * @param data contains the texture data
  112640. * @param texture defines the BabylonJS internal texture
  112641. * @param createPolynomials will be true if polynomials have been requested
  112642. * @param onLoad defines the callback to trigger once the texture is ready
  112643. * @param onError defines the callback to trigger in case of error
  112644. */
  112645. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112646. /**
  112647. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112648. * @param data contains the texture data
  112649. * @param texture defines the BabylonJS internal texture
  112650. * @param callback defines the method to call once ready to upload
  112651. */
  112652. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112653. }
  112654. }
  112655. declare module BABYLON {
  112656. /**
  112657. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  112658. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  112659. */
  112660. export class KhronosTextureContainer {
  112661. /** contents of the KTX container file */
  112662. arrayBuffer: any;
  112663. private static HEADER_LEN;
  112664. private static COMPRESSED_2D;
  112665. private static COMPRESSED_3D;
  112666. private static TEX_2D;
  112667. private static TEX_3D;
  112668. /**
  112669. * Gets the openGL type
  112670. */
  112671. glType: number;
  112672. /**
  112673. * Gets the openGL type size
  112674. */
  112675. glTypeSize: number;
  112676. /**
  112677. * Gets the openGL format
  112678. */
  112679. glFormat: number;
  112680. /**
  112681. * Gets the openGL internal format
  112682. */
  112683. glInternalFormat: number;
  112684. /**
  112685. * Gets the base internal format
  112686. */
  112687. glBaseInternalFormat: number;
  112688. /**
  112689. * Gets image width in pixel
  112690. */
  112691. pixelWidth: number;
  112692. /**
  112693. * Gets image height in pixel
  112694. */
  112695. pixelHeight: number;
  112696. /**
  112697. * Gets image depth in pixels
  112698. */
  112699. pixelDepth: number;
  112700. /**
  112701. * Gets the number of array elements
  112702. */
  112703. numberOfArrayElements: number;
  112704. /**
  112705. * Gets the number of faces
  112706. */
  112707. numberOfFaces: number;
  112708. /**
  112709. * Gets the number of mipmap levels
  112710. */
  112711. numberOfMipmapLevels: number;
  112712. /**
  112713. * Gets the bytes of key value data
  112714. */
  112715. bytesOfKeyValueData: number;
  112716. /**
  112717. * Gets the load type
  112718. */
  112719. loadType: number;
  112720. /**
  112721. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  112722. */
  112723. isInvalid: boolean;
  112724. /**
  112725. * Creates a new KhronosTextureContainer
  112726. * @param arrayBuffer contents of the KTX container file
  112727. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  112728. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  112729. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  112730. */
  112731. constructor(
  112732. /** contents of the KTX container file */
  112733. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  112734. /**
  112735. * Uploads KTX content to a Babylon Texture.
  112736. * It is assumed that the texture has already been created & is currently bound
  112737. * @hidden
  112738. */
  112739. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  112740. private _upload2DCompressedLevels;
  112741. }
  112742. }
  112743. declare module BABYLON {
  112744. /**
  112745. * Implementation of the KTX Texture Loader.
  112746. * @hidden
  112747. */
  112748. export class _KTXTextureLoader implements IInternalTextureLoader {
  112749. /**
  112750. * Defines wether the loader supports cascade loading the different faces.
  112751. */
  112752. readonly supportCascades: boolean;
  112753. /**
  112754. * This returns if the loader support the current file information.
  112755. * @param extension defines the file extension of the file being loaded
  112756. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112757. * @param fallback defines the fallback internal texture if any
  112758. * @param isBase64 defines whether the texture is encoded as a base64
  112759. * @param isBuffer defines whether the texture data are stored as a buffer
  112760. * @returns true if the loader can load the specified file
  112761. */
  112762. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112763. /**
  112764. * Transform the url before loading if required.
  112765. * @param rootUrl the url of the texture
  112766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112767. * @returns the transformed texture
  112768. */
  112769. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112770. /**
  112771. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112772. * @param rootUrl the url of the texture
  112773. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112774. * @returns the fallback texture
  112775. */
  112776. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112777. /**
  112778. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112779. * @param data contains the texture data
  112780. * @param texture defines the BabylonJS internal texture
  112781. * @param createPolynomials will be true if polynomials have been requested
  112782. * @param onLoad defines the callback to trigger once the texture is ready
  112783. * @param onError defines the callback to trigger in case of error
  112784. */
  112785. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112786. /**
  112787. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112788. * @param data contains the texture data
  112789. * @param texture defines the BabylonJS internal texture
  112790. * @param callback defines the method to call once ready to upload
  112791. */
  112792. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  112793. }
  112794. }
  112795. declare module BABYLON {
  112796. /**
  112797. * Options for the default xr helper
  112798. */
  112799. export class WebXRDefaultExperienceOptions {
  112800. /**
  112801. * Floor meshes that should be used for teleporting
  112802. */
  112803. floorMeshes: Array<AbstractMesh>;
  112804. }
  112805. /**
  112806. * Default experience which provides a similar setup to the previous webVRExperience
  112807. */
  112808. export class WebXRDefaultExperience {
  112809. /**
  112810. * Base experience
  112811. */
  112812. baseExperience: WebXRExperienceHelper;
  112813. /**
  112814. * Input experience extension
  112815. */
  112816. input: WebXRInput;
  112817. /**
  112818. * Loads the controller models
  112819. */
  112820. controllerModelLoader: WebXRControllerModelLoader;
  112821. /**
  112822. * Enables laser pointer and selection
  112823. */
  112824. pointerSelection: WebXRControllerPointerSelection;
  112825. /**
  112826. * Enables teleportation
  112827. */
  112828. teleportation: WebXRControllerTeleportation;
  112829. /**
  112830. * Enables ui for enetering/exiting xr
  112831. */
  112832. enterExitUI: WebXREnterExitUI;
  112833. /**
  112834. * Default output canvas xr should render to
  112835. */
  112836. outputCanvas: WebXRManagedOutputCanvas;
  112837. /**
  112838. * Creates the default xr experience
  112839. * @param scene scene
  112840. * @param options options for basic configuration
  112841. * @returns resulting WebXRDefaultExperience
  112842. */
  112843. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112844. private constructor();
  112845. /**
  112846. * DIsposes of the experience helper
  112847. */
  112848. dispose(): void;
  112849. }
  112850. }
  112851. declare module BABYLON {
  112852. /** @hidden */
  112853. export var _forceSceneHelpersToBundle: boolean;
  112854. interface Scene {
  112855. /**
  112856. * Creates a default light for the scene.
  112857. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  112858. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  112859. */
  112860. createDefaultLight(replace?: boolean): void;
  112861. /**
  112862. * Creates a default camera for the scene.
  112863. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  112864. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112865. * @param replace has default false, when true replaces the active camera in the scene
  112866. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  112867. */
  112868. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112869. /**
  112870. * Creates a default camera and a default light.
  112871. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  112872. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112873. * @param replace has the default false, when true replaces the active camera/light in the scene
  112874. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  112875. */
  112876. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112877. /**
  112878. * Creates a new sky box
  112879. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  112880. * @param environmentTexture defines the texture to use as environment texture
  112881. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  112882. * @param scale defines the overall scale of the skybox
  112883. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  112884. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  112885. * @returns a new mesh holding the sky box
  112886. */
  112887. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  112888. /**
  112889. * Creates a new environment
  112890. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  112891. * @param options defines the options you can use to configure the environment
  112892. * @returns the new EnvironmentHelper
  112893. */
  112894. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  112895. /**
  112896. * Creates a new VREXperienceHelper
  112897. * @see http://doc.babylonjs.com/how_to/webvr_helper
  112898. * @param webVROptions defines the options used to create the new VREXperienceHelper
  112899. * @returns a new VREXperienceHelper
  112900. */
  112901. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  112902. /**
  112903. * Creates a new WebXRDefaultExperience
  112904. * @see http://doc.babylonjs.com/how_to/webxr
  112905. * @param options experience options
  112906. * @returns a promise for a new WebXRDefaultExperience
  112907. */
  112908. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112909. }
  112910. }
  112911. declare module BABYLON {
  112912. /**
  112913. * Contains position and normal vectors for a vertex
  112914. */
  112915. export class PositionNormalVertex {
  112916. /** the position of the vertex (defaut: 0,0,0) */
  112917. position: Vector3;
  112918. /** the normal of the vertex (defaut: 0,1,0) */
  112919. normal: Vector3;
  112920. /**
  112921. * Creates a PositionNormalVertex
  112922. * @param position the position of the vertex (defaut: 0,0,0)
  112923. * @param normal the normal of the vertex (defaut: 0,1,0)
  112924. */
  112925. constructor(
  112926. /** the position of the vertex (defaut: 0,0,0) */
  112927. position?: Vector3,
  112928. /** the normal of the vertex (defaut: 0,1,0) */
  112929. normal?: Vector3);
  112930. /**
  112931. * Clones the PositionNormalVertex
  112932. * @returns the cloned PositionNormalVertex
  112933. */
  112934. clone(): PositionNormalVertex;
  112935. }
  112936. /**
  112937. * Contains position, normal and uv vectors for a vertex
  112938. */
  112939. export class PositionNormalTextureVertex {
  112940. /** the position of the vertex (defaut: 0,0,0) */
  112941. position: Vector3;
  112942. /** the normal of the vertex (defaut: 0,1,0) */
  112943. normal: Vector3;
  112944. /** the uv of the vertex (default: 0,0) */
  112945. uv: Vector2;
  112946. /**
  112947. * Creates a PositionNormalTextureVertex
  112948. * @param position the position of the vertex (defaut: 0,0,0)
  112949. * @param normal the normal of the vertex (defaut: 0,1,0)
  112950. * @param uv the uv of the vertex (default: 0,0)
  112951. */
  112952. constructor(
  112953. /** the position of the vertex (defaut: 0,0,0) */
  112954. position?: Vector3,
  112955. /** the normal of the vertex (defaut: 0,1,0) */
  112956. normal?: Vector3,
  112957. /** the uv of the vertex (default: 0,0) */
  112958. uv?: Vector2);
  112959. /**
  112960. * Clones the PositionNormalTextureVertex
  112961. * @returns the cloned PositionNormalTextureVertex
  112962. */
  112963. clone(): PositionNormalTextureVertex;
  112964. }
  112965. }
  112966. declare module BABYLON {
  112967. /**
  112968. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  112969. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  112970. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  112971. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112972. */
  112973. export class VideoDome extends TransformNode {
  112974. /**
  112975. * Define the video source as a Monoscopic panoramic 360 video.
  112976. */
  112977. static readonly MODE_MONOSCOPIC: number;
  112978. /**
  112979. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112980. */
  112981. static readonly MODE_TOPBOTTOM: number;
  112982. /**
  112983. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112984. */
  112985. static readonly MODE_SIDEBYSIDE: number;
  112986. private _halfDome;
  112987. private _useDirectMapping;
  112988. /**
  112989. * The video texture being displayed on the sphere
  112990. */
  112991. protected _videoTexture: VideoTexture;
  112992. /**
  112993. * Gets the video texture being displayed on the sphere
  112994. */
  112995. readonly videoTexture: VideoTexture;
  112996. /**
  112997. * The skybox material
  112998. */
  112999. protected _material: BackgroundMaterial;
  113000. /**
  113001. * The surface used for the skybox
  113002. */
  113003. protected _mesh: Mesh;
  113004. /**
  113005. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  113006. */
  113007. private _halfDomeMask;
  113008. /**
  113009. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113010. * Also see the options.resolution property.
  113011. */
  113012. fovMultiplier: number;
  113013. private _videoMode;
  113014. /**
  113015. * Gets or set the current video mode for the video. It can be:
  113016. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  113017. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113018. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113019. */
  113020. videoMode: number;
  113021. /**
  113022. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  113023. *
  113024. */
  113025. /**
  113026. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  113027. */
  113028. halfDome: boolean;
  113029. /**
  113030. * Oberserver used in Stereoscopic VR Mode.
  113031. */
  113032. private _onBeforeCameraRenderObserver;
  113033. /**
  113034. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  113035. * @param name Element's name, child elements will append suffixes for their own names.
  113036. * @param urlsOrVideo defines the url(s) or the video element to use
  113037. * @param options An object containing optional or exposed sub element properties
  113038. */
  113039. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  113040. resolution?: number;
  113041. clickToPlay?: boolean;
  113042. autoPlay?: boolean;
  113043. loop?: boolean;
  113044. size?: number;
  113045. poster?: string;
  113046. faceForward?: boolean;
  113047. useDirectMapping?: boolean;
  113048. halfDomeMode?: boolean;
  113049. }, scene: Scene);
  113050. private _changeVideoMode;
  113051. /**
  113052. * Releases resources associated with this node.
  113053. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113054. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113055. */
  113056. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113057. }
  113058. }
  113059. declare module BABYLON {
  113060. /**
  113061. * This class can be used to get instrumentation data from a Babylon engine
  113062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113063. */
  113064. export class EngineInstrumentation implements IDisposable {
  113065. /**
  113066. * Define the instrumented engine.
  113067. */
  113068. engine: Engine;
  113069. private _captureGPUFrameTime;
  113070. private _gpuFrameTimeToken;
  113071. private _gpuFrameTime;
  113072. private _captureShaderCompilationTime;
  113073. private _shaderCompilationTime;
  113074. private _onBeginFrameObserver;
  113075. private _onEndFrameObserver;
  113076. private _onBeforeShaderCompilationObserver;
  113077. private _onAfterShaderCompilationObserver;
  113078. /**
  113079. * Gets the perf counter used for GPU frame time
  113080. */
  113081. readonly gpuFrameTimeCounter: PerfCounter;
  113082. /**
  113083. * Gets the GPU frame time capture status
  113084. */
  113085. /**
  113086. * Enable or disable the GPU frame time capture
  113087. */
  113088. captureGPUFrameTime: boolean;
  113089. /**
  113090. * Gets the perf counter used for shader compilation time
  113091. */
  113092. readonly shaderCompilationTimeCounter: PerfCounter;
  113093. /**
  113094. * Gets the shader compilation time capture status
  113095. */
  113096. /**
  113097. * Enable or disable the shader compilation time capture
  113098. */
  113099. captureShaderCompilationTime: boolean;
  113100. /**
  113101. * Instantiates a new engine instrumentation.
  113102. * This class can be used to get instrumentation data from a Babylon engine
  113103. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113104. * @param engine Defines the engine to instrument
  113105. */
  113106. constructor(
  113107. /**
  113108. * Define the instrumented engine.
  113109. */
  113110. engine: Engine);
  113111. /**
  113112. * Dispose and release associated resources.
  113113. */
  113114. dispose(): void;
  113115. }
  113116. }
  113117. declare module BABYLON {
  113118. /**
  113119. * This class can be used to get instrumentation data from a Babylon engine
  113120. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113121. */
  113122. export class SceneInstrumentation implements IDisposable {
  113123. /**
  113124. * Defines the scene to instrument
  113125. */
  113126. scene: Scene;
  113127. private _captureActiveMeshesEvaluationTime;
  113128. private _activeMeshesEvaluationTime;
  113129. private _captureRenderTargetsRenderTime;
  113130. private _renderTargetsRenderTime;
  113131. private _captureFrameTime;
  113132. private _frameTime;
  113133. private _captureRenderTime;
  113134. private _renderTime;
  113135. private _captureInterFrameTime;
  113136. private _interFrameTime;
  113137. private _captureParticlesRenderTime;
  113138. private _particlesRenderTime;
  113139. private _captureSpritesRenderTime;
  113140. private _spritesRenderTime;
  113141. private _capturePhysicsTime;
  113142. private _physicsTime;
  113143. private _captureAnimationsTime;
  113144. private _animationsTime;
  113145. private _captureCameraRenderTime;
  113146. private _cameraRenderTime;
  113147. private _onBeforeActiveMeshesEvaluationObserver;
  113148. private _onAfterActiveMeshesEvaluationObserver;
  113149. private _onBeforeRenderTargetsRenderObserver;
  113150. private _onAfterRenderTargetsRenderObserver;
  113151. private _onAfterRenderObserver;
  113152. private _onBeforeDrawPhaseObserver;
  113153. private _onAfterDrawPhaseObserver;
  113154. private _onBeforeAnimationsObserver;
  113155. private _onBeforeParticlesRenderingObserver;
  113156. private _onAfterParticlesRenderingObserver;
  113157. private _onBeforeSpritesRenderingObserver;
  113158. private _onAfterSpritesRenderingObserver;
  113159. private _onBeforePhysicsObserver;
  113160. private _onAfterPhysicsObserver;
  113161. private _onAfterAnimationsObserver;
  113162. private _onBeforeCameraRenderObserver;
  113163. private _onAfterCameraRenderObserver;
  113164. /**
  113165. * Gets the perf counter used for active meshes evaluation time
  113166. */
  113167. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  113168. /**
  113169. * Gets the active meshes evaluation time capture status
  113170. */
  113171. /**
  113172. * Enable or disable the active meshes evaluation time capture
  113173. */
  113174. captureActiveMeshesEvaluationTime: boolean;
  113175. /**
  113176. * Gets the perf counter used for render targets render time
  113177. */
  113178. readonly renderTargetsRenderTimeCounter: PerfCounter;
  113179. /**
  113180. * Gets the render targets render time capture status
  113181. */
  113182. /**
  113183. * Enable or disable the render targets render time capture
  113184. */
  113185. captureRenderTargetsRenderTime: boolean;
  113186. /**
  113187. * Gets the perf counter used for particles render time
  113188. */
  113189. readonly particlesRenderTimeCounter: PerfCounter;
  113190. /**
  113191. * Gets the particles render time capture status
  113192. */
  113193. /**
  113194. * Enable or disable the particles render time capture
  113195. */
  113196. captureParticlesRenderTime: boolean;
  113197. /**
  113198. * Gets the perf counter used for sprites render time
  113199. */
  113200. readonly spritesRenderTimeCounter: PerfCounter;
  113201. /**
  113202. * Gets the sprites render time capture status
  113203. */
  113204. /**
  113205. * Enable or disable the sprites render time capture
  113206. */
  113207. captureSpritesRenderTime: boolean;
  113208. /**
  113209. * Gets the perf counter used for physics time
  113210. */
  113211. readonly physicsTimeCounter: PerfCounter;
  113212. /**
  113213. * Gets the physics time capture status
  113214. */
  113215. /**
  113216. * Enable or disable the physics time capture
  113217. */
  113218. capturePhysicsTime: boolean;
  113219. /**
  113220. * Gets the perf counter used for animations time
  113221. */
  113222. readonly animationsTimeCounter: PerfCounter;
  113223. /**
  113224. * Gets the animations time capture status
  113225. */
  113226. /**
  113227. * Enable or disable the animations time capture
  113228. */
  113229. captureAnimationsTime: boolean;
  113230. /**
  113231. * Gets the perf counter used for frame time capture
  113232. */
  113233. readonly frameTimeCounter: PerfCounter;
  113234. /**
  113235. * Gets the frame time capture status
  113236. */
  113237. /**
  113238. * Enable or disable the frame time capture
  113239. */
  113240. captureFrameTime: boolean;
  113241. /**
  113242. * Gets the perf counter used for inter-frames time capture
  113243. */
  113244. readonly interFrameTimeCounter: PerfCounter;
  113245. /**
  113246. * Gets the inter-frames time capture status
  113247. */
  113248. /**
  113249. * Enable or disable the inter-frames time capture
  113250. */
  113251. captureInterFrameTime: boolean;
  113252. /**
  113253. * Gets the perf counter used for render time capture
  113254. */
  113255. readonly renderTimeCounter: PerfCounter;
  113256. /**
  113257. * Gets the render time capture status
  113258. */
  113259. /**
  113260. * Enable or disable the render time capture
  113261. */
  113262. captureRenderTime: boolean;
  113263. /**
  113264. * Gets the perf counter used for camera render time capture
  113265. */
  113266. readonly cameraRenderTimeCounter: PerfCounter;
  113267. /**
  113268. * Gets the camera render time capture status
  113269. */
  113270. /**
  113271. * Enable or disable the camera render time capture
  113272. */
  113273. captureCameraRenderTime: boolean;
  113274. /**
  113275. * Gets the perf counter used for draw calls
  113276. */
  113277. readonly drawCallsCounter: PerfCounter;
  113278. /**
  113279. * Instantiates a new scene instrumentation.
  113280. * This class can be used to get instrumentation data from a Babylon engine
  113281. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113282. * @param scene Defines the scene to instrument
  113283. */
  113284. constructor(
  113285. /**
  113286. * Defines the scene to instrument
  113287. */
  113288. scene: Scene);
  113289. /**
  113290. * Dispose and release associated resources.
  113291. */
  113292. dispose(): void;
  113293. }
  113294. }
  113295. declare module BABYLON {
  113296. /** @hidden */
  113297. export var glowMapGenerationPixelShader: {
  113298. name: string;
  113299. shader: string;
  113300. };
  113301. }
  113302. declare module BABYLON {
  113303. /** @hidden */
  113304. export var glowMapGenerationVertexShader: {
  113305. name: string;
  113306. shader: string;
  113307. };
  113308. }
  113309. declare module BABYLON {
  113310. /**
  113311. * Effect layer options. This helps customizing the behaviour
  113312. * of the effect layer.
  113313. */
  113314. export interface IEffectLayerOptions {
  113315. /**
  113316. * Multiplication factor apply to the canvas size to compute the render target size
  113317. * used to generated the objects (the smaller the faster).
  113318. */
  113319. mainTextureRatio: number;
  113320. /**
  113321. * Enforces a fixed size texture to ensure effect stability across devices.
  113322. */
  113323. mainTextureFixedSize?: number;
  113324. /**
  113325. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  113326. */
  113327. alphaBlendingMode: number;
  113328. /**
  113329. * The camera attached to the layer.
  113330. */
  113331. camera: Nullable<Camera>;
  113332. /**
  113333. * The rendering group to draw the layer in.
  113334. */
  113335. renderingGroupId: number;
  113336. }
  113337. /**
  113338. * The effect layer Helps adding post process effect blended with the main pass.
  113339. *
  113340. * This can be for instance use to generate glow or higlight effects on the scene.
  113341. *
  113342. * The effect layer class can not be used directly and is intented to inherited from to be
  113343. * customized per effects.
  113344. */
  113345. export abstract class EffectLayer {
  113346. private _vertexBuffers;
  113347. private _indexBuffer;
  113348. private _cachedDefines;
  113349. private _effectLayerMapGenerationEffect;
  113350. private _effectLayerOptions;
  113351. private _mergeEffect;
  113352. protected _scene: Scene;
  113353. protected _engine: Engine;
  113354. protected _maxSize: number;
  113355. protected _mainTextureDesiredSize: ISize;
  113356. protected _mainTexture: RenderTargetTexture;
  113357. protected _shouldRender: boolean;
  113358. protected _postProcesses: PostProcess[];
  113359. protected _textures: BaseTexture[];
  113360. protected _emissiveTextureAndColor: {
  113361. texture: Nullable<BaseTexture>;
  113362. color: Color4;
  113363. };
  113364. /**
  113365. * The name of the layer
  113366. */
  113367. name: string;
  113368. /**
  113369. * The clear color of the texture used to generate the glow map.
  113370. */
  113371. neutralColor: Color4;
  113372. /**
  113373. * Specifies wether the highlight layer is enabled or not.
  113374. */
  113375. isEnabled: boolean;
  113376. /**
  113377. * Gets the camera attached to the layer.
  113378. */
  113379. readonly camera: Nullable<Camera>;
  113380. /**
  113381. * Gets the rendering group id the layer should render in.
  113382. */
  113383. renderingGroupId: number;
  113384. /**
  113385. * An event triggered when the effect layer has been disposed.
  113386. */
  113387. onDisposeObservable: Observable<EffectLayer>;
  113388. /**
  113389. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  113390. */
  113391. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  113392. /**
  113393. * An event triggered when the generated texture is being merged in the scene.
  113394. */
  113395. onBeforeComposeObservable: Observable<EffectLayer>;
  113396. /**
  113397. * An event triggered when the generated texture has been merged in the scene.
  113398. */
  113399. onAfterComposeObservable: Observable<EffectLayer>;
  113400. /**
  113401. * An event triggered when the efffect layer changes its size.
  113402. */
  113403. onSizeChangedObservable: Observable<EffectLayer>;
  113404. /** @hidden */
  113405. static _SceneComponentInitialization: (scene: Scene) => void;
  113406. /**
  113407. * Instantiates a new effect Layer and references it in the scene.
  113408. * @param name The name of the layer
  113409. * @param scene The scene to use the layer in
  113410. */
  113411. constructor(
  113412. /** The Friendly of the effect in the scene */
  113413. name: string, scene: Scene);
  113414. /**
  113415. * Get the effect name of the layer.
  113416. * @return The effect name
  113417. */
  113418. abstract getEffectName(): string;
  113419. /**
  113420. * Checks for the readiness of the element composing the layer.
  113421. * @param subMesh the mesh to check for
  113422. * @param useInstances specify wether or not to use instances to render the mesh
  113423. * @return true if ready otherwise, false
  113424. */
  113425. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113426. /**
  113427. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113428. * @returns true if the effect requires stencil during the main canvas render pass.
  113429. */
  113430. abstract needStencil(): boolean;
  113431. /**
  113432. * Create the merge effect. This is the shader use to blit the information back
  113433. * to the main canvas at the end of the scene rendering.
  113434. * @returns The effect containing the shader used to merge the effect on the main canvas
  113435. */
  113436. protected abstract _createMergeEffect(): Effect;
  113437. /**
  113438. * Creates the render target textures and post processes used in the effect layer.
  113439. */
  113440. protected abstract _createTextureAndPostProcesses(): void;
  113441. /**
  113442. * Implementation specific of rendering the generating effect on the main canvas.
  113443. * @param effect The effect used to render through
  113444. */
  113445. protected abstract _internalRender(effect: Effect): void;
  113446. /**
  113447. * Sets the required values for both the emissive texture and and the main color.
  113448. */
  113449. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113450. /**
  113451. * Free any resources and references associated to a mesh.
  113452. * Internal use
  113453. * @param mesh The mesh to free.
  113454. */
  113455. abstract _disposeMesh(mesh: Mesh): void;
  113456. /**
  113457. * Serializes this layer (Glow or Highlight for example)
  113458. * @returns a serialized layer object
  113459. */
  113460. abstract serialize?(): any;
  113461. /**
  113462. * Initializes the effect layer with the required options.
  113463. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  113464. */
  113465. protected _init(options: Partial<IEffectLayerOptions>): void;
  113466. /**
  113467. * Generates the index buffer of the full screen quad blending to the main canvas.
  113468. */
  113469. private _generateIndexBuffer;
  113470. /**
  113471. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  113472. */
  113473. private _generateVertexBuffer;
  113474. /**
  113475. * Sets the main texture desired size which is the closest power of two
  113476. * of the engine canvas size.
  113477. */
  113478. private _setMainTextureSize;
  113479. /**
  113480. * Creates the main texture for the effect layer.
  113481. */
  113482. protected _createMainTexture(): void;
  113483. /**
  113484. * Adds specific effects defines.
  113485. * @param defines The defines to add specifics to.
  113486. */
  113487. protected _addCustomEffectDefines(defines: string[]): void;
  113488. /**
  113489. * Checks for the readiness of the element composing the layer.
  113490. * @param subMesh the mesh to check for
  113491. * @param useInstances specify wether or not to use instances to render the mesh
  113492. * @param emissiveTexture the associated emissive texture used to generate the glow
  113493. * @return true if ready otherwise, false
  113494. */
  113495. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  113496. /**
  113497. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  113498. */
  113499. render(): void;
  113500. /**
  113501. * Determine if a given mesh will be used in the current effect.
  113502. * @param mesh mesh to test
  113503. * @returns true if the mesh will be used
  113504. */
  113505. hasMesh(mesh: AbstractMesh): boolean;
  113506. /**
  113507. * Returns true if the layer contains information to display, otherwise false.
  113508. * @returns true if the glow layer should be rendered
  113509. */
  113510. shouldRender(): boolean;
  113511. /**
  113512. * Returns true if the mesh should render, otherwise false.
  113513. * @param mesh The mesh to render
  113514. * @returns true if it should render otherwise false
  113515. */
  113516. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  113517. /**
  113518. * Returns true if the mesh can be rendered, otherwise false.
  113519. * @param mesh The mesh to render
  113520. * @param material The material used on the mesh
  113521. * @returns true if it can be rendered otherwise false
  113522. */
  113523. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113524. /**
  113525. * Returns true if the mesh should render, otherwise false.
  113526. * @param mesh The mesh to render
  113527. * @returns true if it should render otherwise false
  113528. */
  113529. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  113530. /**
  113531. * Renders the submesh passed in parameter to the generation map.
  113532. */
  113533. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  113534. /**
  113535. * Rebuild the required buffers.
  113536. * @hidden Internal use only.
  113537. */
  113538. _rebuild(): void;
  113539. /**
  113540. * Dispose only the render target textures and post process.
  113541. */
  113542. private _disposeTextureAndPostProcesses;
  113543. /**
  113544. * Dispose the highlight layer and free resources.
  113545. */
  113546. dispose(): void;
  113547. /**
  113548. * Gets the class name of the effect layer
  113549. * @returns the string with the class name of the effect layer
  113550. */
  113551. getClassName(): string;
  113552. /**
  113553. * Creates an effect layer from parsed effect layer data
  113554. * @param parsedEffectLayer defines effect layer data
  113555. * @param scene defines the current scene
  113556. * @param rootUrl defines the root URL containing the effect layer information
  113557. * @returns a parsed effect Layer
  113558. */
  113559. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  113560. }
  113561. }
  113562. declare module BABYLON {
  113563. interface AbstractScene {
  113564. /**
  113565. * The list of effect layers (highlights/glow) added to the scene
  113566. * @see http://doc.babylonjs.com/how_to/highlight_layer
  113567. * @see http://doc.babylonjs.com/how_to/glow_layer
  113568. */
  113569. effectLayers: Array<EffectLayer>;
  113570. /**
  113571. * Removes the given effect layer from this scene.
  113572. * @param toRemove defines the effect layer to remove
  113573. * @returns the index of the removed effect layer
  113574. */
  113575. removeEffectLayer(toRemove: EffectLayer): number;
  113576. /**
  113577. * Adds the given effect layer to this scene
  113578. * @param newEffectLayer defines the effect layer to add
  113579. */
  113580. addEffectLayer(newEffectLayer: EffectLayer): void;
  113581. }
  113582. /**
  113583. * Defines the layer scene component responsible to manage any effect layers
  113584. * in a given scene.
  113585. */
  113586. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  113587. /**
  113588. * The component name helpfull to identify the component in the list of scene components.
  113589. */
  113590. readonly name: string;
  113591. /**
  113592. * The scene the component belongs to.
  113593. */
  113594. scene: Scene;
  113595. private _engine;
  113596. private _renderEffects;
  113597. private _needStencil;
  113598. private _previousStencilState;
  113599. /**
  113600. * Creates a new instance of the component for the given scene
  113601. * @param scene Defines the scene to register the component in
  113602. */
  113603. constructor(scene: Scene);
  113604. /**
  113605. * Registers the component in a given scene
  113606. */
  113607. register(): void;
  113608. /**
  113609. * Rebuilds the elements related to this component in case of
  113610. * context lost for instance.
  113611. */
  113612. rebuild(): void;
  113613. /**
  113614. * Serializes the component data to the specified json object
  113615. * @param serializationObject The object to serialize to
  113616. */
  113617. serialize(serializationObject: any): void;
  113618. /**
  113619. * Adds all the elements from the container to the scene
  113620. * @param container the container holding the elements
  113621. */
  113622. addFromContainer(container: AbstractScene): void;
  113623. /**
  113624. * Removes all the elements in the container from the scene
  113625. * @param container contains the elements to remove
  113626. * @param dispose if the removed element should be disposed (default: false)
  113627. */
  113628. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113629. /**
  113630. * Disposes the component and the associated ressources.
  113631. */
  113632. dispose(): void;
  113633. private _isReadyForMesh;
  113634. private _renderMainTexture;
  113635. private _setStencil;
  113636. private _setStencilBack;
  113637. private _draw;
  113638. private _drawCamera;
  113639. private _drawRenderingGroup;
  113640. }
  113641. }
  113642. declare module BABYLON {
  113643. /** @hidden */
  113644. export var glowMapMergePixelShader: {
  113645. name: string;
  113646. shader: string;
  113647. };
  113648. }
  113649. declare module BABYLON {
  113650. /** @hidden */
  113651. export var glowMapMergeVertexShader: {
  113652. name: string;
  113653. shader: string;
  113654. };
  113655. }
  113656. declare module BABYLON {
  113657. interface AbstractScene {
  113658. /**
  113659. * Return a the first highlight layer of the scene with a given name.
  113660. * @param name The name of the highlight layer to look for.
  113661. * @return The highlight layer if found otherwise null.
  113662. */
  113663. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  113664. }
  113665. /**
  113666. * Glow layer options. This helps customizing the behaviour
  113667. * of the glow layer.
  113668. */
  113669. export interface IGlowLayerOptions {
  113670. /**
  113671. * Multiplication factor apply to the canvas size to compute the render target size
  113672. * used to generated the glowing objects (the smaller the faster).
  113673. */
  113674. mainTextureRatio: number;
  113675. /**
  113676. * Enforces a fixed size texture to ensure resize independant blur.
  113677. */
  113678. mainTextureFixedSize?: number;
  113679. /**
  113680. * How big is the kernel of the blur texture.
  113681. */
  113682. blurKernelSize: number;
  113683. /**
  113684. * The camera attached to the layer.
  113685. */
  113686. camera: Nullable<Camera>;
  113687. /**
  113688. * Enable MSAA by chosing the number of samples.
  113689. */
  113690. mainTextureSamples?: number;
  113691. /**
  113692. * The rendering group to draw the layer in.
  113693. */
  113694. renderingGroupId: number;
  113695. }
  113696. /**
  113697. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  113698. *
  113699. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113700. * glowy meshes to your scene.
  113701. *
  113702. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  113703. */
  113704. export class GlowLayer extends EffectLayer {
  113705. /**
  113706. * Effect Name of the layer.
  113707. */
  113708. static readonly EffectName: string;
  113709. /**
  113710. * The default blur kernel size used for the glow.
  113711. */
  113712. static DefaultBlurKernelSize: number;
  113713. /**
  113714. * The default texture size ratio used for the glow.
  113715. */
  113716. static DefaultTextureRatio: number;
  113717. /**
  113718. * Sets the kernel size of the blur.
  113719. */
  113720. /**
  113721. * Gets the kernel size of the blur.
  113722. */
  113723. blurKernelSize: number;
  113724. /**
  113725. * Sets the glow intensity.
  113726. */
  113727. /**
  113728. * Gets the glow intensity.
  113729. */
  113730. intensity: number;
  113731. private _options;
  113732. private _intensity;
  113733. private _horizontalBlurPostprocess1;
  113734. private _verticalBlurPostprocess1;
  113735. private _horizontalBlurPostprocess2;
  113736. private _verticalBlurPostprocess2;
  113737. private _blurTexture1;
  113738. private _blurTexture2;
  113739. private _postProcesses1;
  113740. private _postProcesses2;
  113741. private _includedOnlyMeshes;
  113742. private _excludedMeshes;
  113743. /**
  113744. * Callback used to let the user override the color selection on a per mesh basis
  113745. */
  113746. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  113747. /**
  113748. * Callback used to let the user override the texture selection on a per mesh basis
  113749. */
  113750. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  113751. /**
  113752. * Instantiates a new glow Layer and references it to the scene.
  113753. * @param name The name of the layer
  113754. * @param scene The scene to use the layer in
  113755. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  113756. */
  113757. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  113758. /**
  113759. * Get the effect name of the layer.
  113760. * @return The effect name
  113761. */
  113762. getEffectName(): string;
  113763. /**
  113764. * Create the merge effect. This is the shader use to blit the information back
  113765. * to the main canvas at the end of the scene rendering.
  113766. */
  113767. protected _createMergeEffect(): Effect;
  113768. /**
  113769. * Creates the render target textures and post processes used in the glow layer.
  113770. */
  113771. protected _createTextureAndPostProcesses(): void;
  113772. /**
  113773. * Checks for the readiness of the element composing the layer.
  113774. * @param subMesh the mesh to check for
  113775. * @param useInstances specify wether or not to use instances to render the mesh
  113776. * @param emissiveTexture the associated emissive texture used to generate the glow
  113777. * @return true if ready otherwise, false
  113778. */
  113779. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113780. /**
  113781. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113782. */
  113783. needStencil(): boolean;
  113784. /**
  113785. * Returns true if the mesh can be rendered, otherwise false.
  113786. * @param mesh The mesh to render
  113787. * @param material The material used on the mesh
  113788. * @returns true if it can be rendered otherwise false
  113789. */
  113790. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113791. /**
  113792. * Implementation specific of rendering the generating effect on the main canvas.
  113793. * @param effect The effect used to render through
  113794. */
  113795. protected _internalRender(effect: Effect): void;
  113796. /**
  113797. * Sets the required values for both the emissive texture and and the main color.
  113798. */
  113799. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113800. /**
  113801. * Returns true if the mesh should render, otherwise false.
  113802. * @param mesh The mesh to render
  113803. * @returns true if it should render otherwise false
  113804. */
  113805. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113806. /**
  113807. * Adds specific effects defines.
  113808. * @param defines The defines to add specifics to.
  113809. */
  113810. protected _addCustomEffectDefines(defines: string[]): void;
  113811. /**
  113812. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  113813. * @param mesh The mesh to exclude from the glow layer
  113814. */
  113815. addExcludedMesh(mesh: Mesh): void;
  113816. /**
  113817. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  113818. * @param mesh The mesh to remove
  113819. */
  113820. removeExcludedMesh(mesh: Mesh): void;
  113821. /**
  113822. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  113823. * @param mesh The mesh to include in the glow layer
  113824. */
  113825. addIncludedOnlyMesh(mesh: Mesh): void;
  113826. /**
  113827. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  113828. * @param mesh The mesh to remove
  113829. */
  113830. removeIncludedOnlyMesh(mesh: Mesh): void;
  113831. /**
  113832. * Determine if a given mesh will be used in the glow layer
  113833. * @param mesh The mesh to test
  113834. * @returns true if the mesh will be highlighted by the current glow layer
  113835. */
  113836. hasMesh(mesh: AbstractMesh): boolean;
  113837. /**
  113838. * Free any resources and references associated to a mesh.
  113839. * Internal use
  113840. * @param mesh The mesh to free.
  113841. * @hidden
  113842. */
  113843. _disposeMesh(mesh: Mesh): void;
  113844. /**
  113845. * Gets the class name of the effect layer
  113846. * @returns the string with the class name of the effect layer
  113847. */
  113848. getClassName(): string;
  113849. /**
  113850. * Serializes this glow layer
  113851. * @returns a serialized glow layer object
  113852. */
  113853. serialize(): any;
  113854. /**
  113855. * Creates a Glow Layer from parsed glow layer data
  113856. * @param parsedGlowLayer defines glow layer data
  113857. * @param scene defines the current scene
  113858. * @param rootUrl defines the root URL containing the glow layer information
  113859. * @returns a parsed Glow Layer
  113860. */
  113861. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  113862. }
  113863. }
  113864. declare module BABYLON {
  113865. /** @hidden */
  113866. export var glowBlurPostProcessPixelShader: {
  113867. name: string;
  113868. shader: string;
  113869. };
  113870. }
  113871. declare module BABYLON {
  113872. interface AbstractScene {
  113873. /**
  113874. * Return a the first highlight layer of the scene with a given name.
  113875. * @param name The name of the highlight layer to look for.
  113876. * @return The highlight layer if found otherwise null.
  113877. */
  113878. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  113879. }
  113880. /**
  113881. * Highlight layer options. This helps customizing the behaviour
  113882. * of the highlight layer.
  113883. */
  113884. export interface IHighlightLayerOptions {
  113885. /**
  113886. * Multiplication factor apply to the canvas size to compute the render target size
  113887. * used to generated the glowing objects (the smaller the faster).
  113888. */
  113889. mainTextureRatio: number;
  113890. /**
  113891. * Enforces a fixed size texture to ensure resize independant blur.
  113892. */
  113893. mainTextureFixedSize?: number;
  113894. /**
  113895. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  113896. * of the picture to blur (the smaller the faster).
  113897. */
  113898. blurTextureSizeRatio: number;
  113899. /**
  113900. * How big in texel of the blur texture is the vertical blur.
  113901. */
  113902. blurVerticalSize: number;
  113903. /**
  113904. * How big in texel of the blur texture is the horizontal blur.
  113905. */
  113906. blurHorizontalSize: number;
  113907. /**
  113908. * Alpha blending mode used to apply the blur. Default is combine.
  113909. */
  113910. alphaBlendingMode: number;
  113911. /**
  113912. * The camera attached to the layer.
  113913. */
  113914. camera: Nullable<Camera>;
  113915. /**
  113916. * Should we display highlight as a solid stroke?
  113917. */
  113918. isStroke?: boolean;
  113919. /**
  113920. * The rendering group to draw the layer in.
  113921. */
  113922. renderingGroupId: number;
  113923. }
  113924. /**
  113925. * The highlight layer Helps adding a glow effect around a mesh.
  113926. *
  113927. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113928. * glowy meshes to your scene.
  113929. *
  113930. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  113931. */
  113932. export class HighlightLayer extends EffectLayer {
  113933. name: string;
  113934. /**
  113935. * Effect Name of the highlight layer.
  113936. */
  113937. static readonly EffectName: string;
  113938. /**
  113939. * The neutral color used during the preparation of the glow effect.
  113940. * This is black by default as the blend operation is a blend operation.
  113941. */
  113942. static NeutralColor: Color4;
  113943. /**
  113944. * Stencil value used for glowing meshes.
  113945. */
  113946. static GlowingMeshStencilReference: number;
  113947. /**
  113948. * Stencil value used for the other meshes in the scene.
  113949. */
  113950. static NormalMeshStencilReference: number;
  113951. /**
  113952. * Specifies whether or not the inner glow is ACTIVE in the layer.
  113953. */
  113954. innerGlow: boolean;
  113955. /**
  113956. * Specifies whether or not the outer glow is ACTIVE in the layer.
  113957. */
  113958. outerGlow: boolean;
  113959. /**
  113960. * Specifies the horizontal size of the blur.
  113961. */
  113962. /**
  113963. * Gets the horizontal size of the blur.
  113964. */
  113965. blurHorizontalSize: number;
  113966. /**
  113967. * Specifies the vertical size of the blur.
  113968. */
  113969. /**
  113970. * Gets the vertical size of the blur.
  113971. */
  113972. blurVerticalSize: number;
  113973. /**
  113974. * An event triggered when the highlight layer is being blurred.
  113975. */
  113976. onBeforeBlurObservable: Observable<HighlightLayer>;
  113977. /**
  113978. * An event triggered when the highlight layer has been blurred.
  113979. */
  113980. onAfterBlurObservable: Observable<HighlightLayer>;
  113981. private _instanceGlowingMeshStencilReference;
  113982. private _options;
  113983. private _downSamplePostprocess;
  113984. private _horizontalBlurPostprocess;
  113985. private _verticalBlurPostprocess;
  113986. private _blurTexture;
  113987. private _meshes;
  113988. private _excludedMeshes;
  113989. /**
  113990. * Instantiates a new highlight Layer and references it to the scene..
  113991. * @param name The name of the layer
  113992. * @param scene The scene to use the layer in
  113993. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  113994. */
  113995. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  113996. /**
  113997. * Get the effect name of the layer.
  113998. * @return The effect name
  113999. */
  114000. getEffectName(): string;
  114001. /**
  114002. * Create the merge effect. This is the shader use to blit the information back
  114003. * to the main canvas at the end of the scene rendering.
  114004. */
  114005. protected _createMergeEffect(): Effect;
  114006. /**
  114007. * Creates the render target textures and post processes used in the highlight layer.
  114008. */
  114009. protected _createTextureAndPostProcesses(): void;
  114010. /**
  114011. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114012. */
  114013. needStencil(): boolean;
  114014. /**
  114015. * Checks for the readiness of the element composing the layer.
  114016. * @param subMesh the mesh to check for
  114017. * @param useInstances specify wether or not to use instances to render the mesh
  114018. * @param emissiveTexture the associated emissive texture used to generate the glow
  114019. * @return true if ready otherwise, false
  114020. */
  114021. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114022. /**
  114023. * Implementation specific of rendering the generating effect on the main canvas.
  114024. * @param effect The effect used to render through
  114025. */
  114026. protected _internalRender(effect: Effect): void;
  114027. /**
  114028. * Returns true if the layer contains information to display, otherwise false.
  114029. */
  114030. shouldRender(): boolean;
  114031. /**
  114032. * Returns true if the mesh should render, otherwise false.
  114033. * @param mesh The mesh to render
  114034. * @returns true if it should render otherwise false
  114035. */
  114036. protected _shouldRenderMesh(mesh: Mesh): boolean;
  114037. /**
  114038. * Sets the required values for both the emissive texture and and the main color.
  114039. */
  114040. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114041. /**
  114042. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  114043. * @param mesh The mesh to exclude from the highlight layer
  114044. */
  114045. addExcludedMesh(mesh: Mesh): void;
  114046. /**
  114047. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  114048. * @param mesh The mesh to highlight
  114049. */
  114050. removeExcludedMesh(mesh: Mesh): void;
  114051. /**
  114052. * Determine if a given mesh will be highlighted by the current HighlightLayer
  114053. * @param mesh mesh to test
  114054. * @returns true if the mesh will be highlighted by the current HighlightLayer
  114055. */
  114056. hasMesh(mesh: AbstractMesh): boolean;
  114057. /**
  114058. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  114059. * @param mesh The mesh to highlight
  114060. * @param color The color of the highlight
  114061. * @param glowEmissiveOnly Extract the glow from the emissive texture
  114062. */
  114063. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  114064. /**
  114065. * Remove a mesh from the highlight layer in order to make it stop glowing.
  114066. * @param mesh The mesh to highlight
  114067. */
  114068. removeMesh(mesh: Mesh): void;
  114069. /**
  114070. * Force the stencil to the normal expected value for none glowing parts
  114071. */
  114072. private _defaultStencilReference;
  114073. /**
  114074. * Free any resources and references associated to a mesh.
  114075. * Internal use
  114076. * @param mesh The mesh to free.
  114077. * @hidden
  114078. */
  114079. _disposeMesh(mesh: Mesh): void;
  114080. /**
  114081. * Dispose the highlight layer and free resources.
  114082. */
  114083. dispose(): void;
  114084. /**
  114085. * Gets the class name of the effect layer
  114086. * @returns the string with the class name of the effect layer
  114087. */
  114088. getClassName(): string;
  114089. /**
  114090. * Serializes this Highlight layer
  114091. * @returns a serialized Highlight layer object
  114092. */
  114093. serialize(): any;
  114094. /**
  114095. * Creates a Highlight layer from parsed Highlight layer data
  114096. * @param parsedHightlightLayer defines the Highlight layer data
  114097. * @param scene defines the current scene
  114098. * @param rootUrl defines the root URL containing the Highlight layer information
  114099. * @returns a parsed Highlight layer
  114100. */
  114101. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  114102. }
  114103. }
  114104. declare module BABYLON {
  114105. interface AbstractScene {
  114106. /**
  114107. * The list of layers (background and foreground) of the scene
  114108. */
  114109. layers: Array<Layer>;
  114110. }
  114111. /**
  114112. * Defines the layer scene component responsible to manage any layers
  114113. * in a given scene.
  114114. */
  114115. export class LayerSceneComponent implements ISceneComponent {
  114116. /**
  114117. * The component name helpfull to identify the component in the list of scene components.
  114118. */
  114119. readonly name: string;
  114120. /**
  114121. * The scene the component belongs to.
  114122. */
  114123. scene: Scene;
  114124. private _engine;
  114125. /**
  114126. * Creates a new instance of the component for the given scene
  114127. * @param scene Defines the scene to register the component in
  114128. */
  114129. constructor(scene: Scene);
  114130. /**
  114131. * Registers the component in a given scene
  114132. */
  114133. register(): void;
  114134. /**
  114135. * Rebuilds the elements related to this component in case of
  114136. * context lost for instance.
  114137. */
  114138. rebuild(): void;
  114139. /**
  114140. * Disposes the component and the associated ressources.
  114141. */
  114142. dispose(): void;
  114143. private _draw;
  114144. private _drawCameraPredicate;
  114145. private _drawCameraBackground;
  114146. private _drawCameraForeground;
  114147. private _drawRenderTargetPredicate;
  114148. private _drawRenderTargetBackground;
  114149. private _drawRenderTargetForeground;
  114150. /**
  114151. * Adds all the elements from the container to the scene
  114152. * @param container the container holding the elements
  114153. */
  114154. addFromContainer(container: AbstractScene): void;
  114155. /**
  114156. * Removes all the elements in the container from the scene
  114157. * @param container contains the elements to remove
  114158. * @param dispose if the removed element should be disposed (default: false)
  114159. */
  114160. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114161. }
  114162. }
  114163. declare module BABYLON {
  114164. /** @hidden */
  114165. export var layerPixelShader: {
  114166. name: string;
  114167. shader: string;
  114168. };
  114169. }
  114170. declare module BABYLON {
  114171. /** @hidden */
  114172. export var layerVertexShader: {
  114173. name: string;
  114174. shader: string;
  114175. };
  114176. }
  114177. declare module BABYLON {
  114178. /**
  114179. * This represents a full screen 2d layer.
  114180. * This can be useful to display a picture in the background of your scene for instance.
  114181. * @see https://www.babylonjs-playground.com/#08A2BS#1
  114182. */
  114183. export class Layer {
  114184. /**
  114185. * Define the name of the layer.
  114186. */
  114187. name: string;
  114188. /**
  114189. * Define the texture the layer should display.
  114190. */
  114191. texture: Nullable<Texture>;
  114192. /**
  114193. * Is the layer in background or foreground.
  114194. */
  114195. isBackground: boolean;
  114196. /**
  114197. * Define the color of the layer (instead of texture).
  114198. */
  114199. color: Color4;
  114200. /**
  114201. * Define the scale of the layer in order to zoom in out of the texture.
  114202. */
  114203. scale: Vector2;
  114204. /**
  114205. * Define an offset for the layer in order to shift the texture.
  114206. */
  114207. offset: Vector2;
  114208. /**
  114209. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  114210. */
  114211. alphaBlendingMode: number;
  114212. /**
  114213. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  114214. * Alpha test will not mix with the background color in case of transparency.
  114215. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  114216. */
  114217. alphaTest: boolean;
  114218. /**
  114219. * Define a mask to restrict the layer to only some of the scene cameras.
  114220. */
  114221. layerMask: number;
  114222. /**
  114223. * Define the list of render target the layer is visible into.
  114224. */
  114225. renderTargetTextures: RenderTargetTexture[];
  114226. /**
  114227. * Define if the layer is only used in renderTarget or if it also
  114228. * renders in the main frame buffer of the canvas.
  114229. */
  114230. renderOnlyInRenderTargetTextures: boolean;
  114231. private _scene;
  114232. private _vertexBuffers;
  114233. private _indexBuffer;
  114234. private _effect;
  114235. private _alphaTestEffect;
  114236. /**
  114237. * An event triggered when the layer is disposed.
  114238. */
  114239. onDisposeObservable: Observable<Layer>;
  114240. private _onDisposeObserver;
  114241. /**
  114242. * Back compatibility with callback before the onDisposeObservable existed.
  114243. * The set callback will be triggered when the layer has been disposed.
  114244. */
  114245. onDispose: () => void;
  114246. /**
  114247. * An event triggered before rendering the scene
  114248. */
  114249. onBeforeRenderObservable: Observable<Layer>;
  114250. private _onBeforeRenderObserver;
  114251. /**
  114252. * Back compatibility with callback before the onBeforeRenderObservable existed.
  114253. * The set callback will be triggered just before rendering the layer.
  114254. */
  114255. onBeforeRender: () => void;
  114256. /**
  114257. * An event triggered after rendering the scene
  114258. */
  114259. onAfterRenderObservable: Observable<Layer>;
  114260. private _onAfterRenderObserver;
  114261. /**
  114262. * Back compatibility with callback before the onAfterRenderObservable existed.
  114263. * The set callback will be triggered just after rendering the layer.
  114264. */
  114265. onAfterRender: () => void;
  114266. /**
  114267. * Instantiates a new layer.
  114268. * This represents a full screen 2d layer.
  114269. * This can be useful to display a picture in the background of your scene for instance.
  114270. * @see https://www.babylonjs-playground.com/#08A2BS#1
  114271. * @param name Define the name of the layer in the scene
  114272. * @param imgUrl Define the url of the texture to display in the layer
  114273. * @param scene Define the scene the layer belongs to
  114274. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  114275. * @param color Defines a color for the layer
  114276. */
  114277. constructor(
  114278. /**
  114279. * Define the name of the layer.
  114280. */
  114281. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  114282. private _createIndexBuffer;
  114283. /** @hidden */
  114284. _rebuild(): void;
  114285. /**
  114286. * Renders the layer in the scene.
  114287. */
  114288. render(): void;
  114289. /**
  114290. * Disposes and releases the associated ressources.
  114291. */
  114292. dispose(): void;
  114293. }
  114294. }
  114295. declare module BABYLON {
  114296. /** @hidden */
  114297. export var lensFlarePixelShader: {
  114298. name: string;
  114299. shader: string;
  114300. };
  114301. }
  114302. declare module BABYLON {
  114303. /** @hidden */
  114304. export var lensFlareVertexShader: {
  114305. name: string;
  114306. shader: string;
  114307. };
  114308. }
  114309. declare module BABYLON {
  114310. /**
  114311. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114312. * It is usually composed of several `lensFlare`.
  114313. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114314. */
  114315. export class LensFlareSystem {
  114316. /**
  114317. * Define the name of the lens flare system
  114318. */
  114319. name: string;
  114320. /**
  114321. * List of lens flares used in this system.
  114322. */
  114323. lensFlares: LensFlare[];
  114324. /**
  114325. * Define a limit from the border the lens flare can be visible.
  114326. */
  114327. borderLimit: number;
  114328. /**
  114329. * Define a viewport border we do not want to see the lens flare in.
  114330. */
  114331. viewportBorder: number;
  114332. /**
  114333. * Define a predicate which could limit the list of meshes able to occlude the effect.
  114334. */
  114335. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114336. /**
  114337. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  114338. */
  114339. layerMask: number;
  114340. /**
  114341. * Define the id of the lens flare system in the scene.
  114342. * (equal to name by default)
  114343. */
  114344. id: string;
  114345. private _scene;
  114346. private _emitter;
  114347. private _vertexBuffers;
  114348. private _indexBuffer;
  114349. private _effect;
  114350. private _positionX;
  114351. private _positionY;
  114352. private _isEnabled;
  114353. /** @hidden */
  114354. static _SceneComponentInitialization: (scene: Scene) => void;
  114355. /**
  114356. * Instantiates a lens flare system.
  114357. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114358. * It is usually composed of several `lensFlare`.
  114359. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114360. * @param name Define the name of the lens flare system in the scene
  114361. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  114362. * @param scene Define the scene the lens flare system belongs to
  114363. */
  114364. constructor(
  114365. /**
  114366. * Define the name of the lens flare system
  114367. */
  114368. name: string, emitter: any, scene: Scene);
  114369. /**
  114370. * Define if the lens flare system is enabled.
  114371. */
  114372. isEnabled: boolean;
  114373. /**
  114374. * Get the scene the effects belongs to.
  114375. * @returns the scene holding the lens flare system
  114376. */
  114377. getScene(): Scene;
  114378. /**
  114379. * Get the emitter of the lens flare system.
  114380. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114381. * @returns the emitter of the lens flare system
  114382. */
  114383. getEmitter(): any;
  114384. /**
  114385. * Set the emitter of the lens flare system.
  114386. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114387. * @param newEmitter Define the new emitter of the system
  114388. */
  114389. setEmitter(newEmitter: any): void;
  114390. /**
  114391. * Get the lens flare system emitter position.
  114392. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  114393. * @returns the position
  114394. */
  114395. getEmitterPosition(): Vector3;
  114396. /**
  114397. * @hidden
  114398. */
  114399. computeEffectivePosition(globalViewport: Viewport): boolean;
  114400. /** @hidden */
  114401. _isVisible(): boolean;
  114402. /**
  114403. * @hidden
  114404. */
  114405. render(): boolean;
  114406. /**
  114407. * Dispose and release the lens flare with its associated resources.
  114408. */
  114409. dispose(): void;
  114410. /**
  114411. * Parse a lens flare system from a JSON repressentation
  114412. * @param parsedLensFlareSystem Define the JSON to parse
  114413. * @param scene Define the scene the parsed system should be instantiated in
  114414. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  114415. * @returns the parsed system
  114416. */
  114417. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  114418. /**
  114419. * Serialize the current Lens Flare System into a JSON representation.
  114420. * @returns the serialized JSON
  114421. */
  114422. serialize(): any;
  114423. }
  114424. }
  114425. declare module BABYLON {
  114426. /**
  114427. * This represents one of the lens effect in a `lensFlareSystem`.
  114428. * It controls one of the indiviual texture used in the effect.
  114429. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114430. */
  114431. export class LensFlare {
  114432. /**
  114433. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114434. */
  114435. size: number;
  114436. /**
  114437. * 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.
  114438. */
  114439. position: number;
  114440. /**
  114441. * Define the lens color.
  114442. */
  114443. color: Color3;
  114444. /**
  114445. * Define the lens texture.
  114446. */
  114447. texture: Nullable<Texture>;
  114448. /**
  114449. * Define the alpha mode to render this particular lens.
  114450. */
  114451. alphaMode: number;
  114452. private _system;
  114453. /**
  114454. * Creates a new Lens Flare.
  114455. * This represents one of the lens effect in a `lensFlareSystem`.
  114456. * It controls one of the indiviual texture used in the effect.
  114457. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114458. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  114459. * @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.
  114460. * @param color Define the lens color
  114461. * @param imgUrl Define the lens texture url
  114462. * @param system Define the `lensFlareSystem` this flare is part of
  114463. * @returns The newly created Lens Flare
  114464. */
  114465. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  114466. /**
  114467. * Instantiates a new Lens Flare.
  114468. * This represents one of the lens effect in a `lensFlareSystem`.
  114469. * It controls one of the indiviual texture used in the effect.
  114470. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114471. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  114472. * @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.
  114473. * @param color Define the lens color
  114474. * @param imgUrl Define the lens texture url
  114475. * @param system Define the `lensFlareSystem` this flare is part of
  114476. */
  114477. constructor(
  114478. /**
  114479. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114480. */
  114481. size: number,
  114482. /**
  114483. * 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.
  114484. */
  114485. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  114486. /**
  114487. * Dispose and release the lens flare with its associated resources.
  114488. */
  114489. dispose(): void;
  114490. }
  114491. }
  114492. declare module BABYLON {
  114493. interface AbstractScene {
  114494. /**
  114495. * The list of lens flare system added to the scene
  114496. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114497. */
  114498. lensFlareSystems: Array<LensFlareSystem>;
  114499. /**
  114500. * Removes the given lens flare system from this scene.
  114501. * @param toRemove The lens flare system to remove
  114502. * @returns The index of the removed lens flare system
  114503. */
  114504. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  114505. /**
  114506. * Adds the given lens flare system to this scene
  114507. * @param newLensFlareSystem The lens flare system to add
  114508. */
  114509. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  114510. /**
  114511. * Gets a lens flare system using its name
  114512. * @param name defines the name to look for
  114513. * @returns the lens flare system or null if not found
  114514. */
  114515. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  114516. /**
  114517. * Gets a lens flare system using its id
  114518. * @param id defines the id to look for
  114519. * @returns the lens flare system or null if not found
  114520. */
  114521. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  114522. }
  114523. /**
  114524. * Defines the lens flare scene component responsible to manage any lens flares
  114525. * in a given scene.
  114526. */
  114527. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  114528. /**
  114529. * The component name helpfull to identify the component in the list of scene components.
  114530. */
  114531. readonly name: string;
  114532. /**
  114533. * The scene the component belongs to.
  114534. */
  114535. scene: Scene;
  114536. /**
  114537. * Creates a new instance of the component for the given scene
  114538. * @param scene Defines the scene to register the component in
  114539. */
  114540. constructor(scene: Scene);
  114541. /**
  114542. * Registers the component in a given scene
  114543. */
  114544. register(): void;
  114545. /**
  114546. * Rebuilds the elements related to this component in case of
  114547. * context lost for instance.
  114548. */
  114549. rebuild(): void;
  114550. /**
  114551. * Adds all the elements from the container to the scene
  114552. * @param container the container holding the elements
  114553. */
  114554. addFromContainer(container: AbstractScene): void;
  114555. /**
  114556. * Removes all the elements in the container from the scene
  114557. * @param container contains the elements to remove
  114558. * @param dispose if the removed element should be disposed (default: false)
  114559. */
  114560. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114561. /**
  114562. * Serializes the component data to the specified json object
  114563. * @param serializationObject The object to serialize to
  114564. */
  114565. serialize(serializationObject: any): void;
  114566. /**
  114567. * Disposes the component and the associated ressources.
  114568. */
  114569. dispose(): void;
  114570. private _draw;
  114571. }
  114572. }
  114573. declare module BABYLON {
  114574. /**
  114575. * Defines the shadow generator component responsible to manage any shadow generators
  114576. * in a given scene.
  114577. */
  114578. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  114579. /**
  114580. * The component name helpfull to identify the component in the list of scene components.
  114581. */
  114582. readonly name: string;
  114583. /**
  114584. * The scene the component belongs to.
  114585. */
  114586. scene: Scene;
  114587. /**
  114588. * Creates a new instance of the component for the given scene
  114589. * @param scene Defines the scene to register the component in
  114590. */
  114591. constructor(scene: Scene);
  114592. /**
  114593. * Registers the component in a given scene
  114594. */
  114595. register(): void;
  114596. /**
  114597. * Rebuilds the elements related to this component in case of
  114598. * context lost for instance.
  114599. */
  114600. rebuild(): void;
  114601. /**
  114602. * Serializes the component data to the specified json object
  114603. * @param serializationObject The object to serialize to
  114604. */
  114605. serialize(serializationObject: any): void;
  114606. /**
  114607. * Adds all the elements from the container to the scene
  114608. * @param container the container holding the elements
  114609. */
  114610. addFromContainer(container: AbstractScene): void;
  114611. /**
  114612. * Removes all the elements in the container from the scene
  114613. * @param container contains the elements to remove
  114614. * @param dispose if the removed element should be disposed (default: false)
  114615. */
  114616. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114617. /**
  114618. * Rebuilds the elements related to this component in case of
  114619. * context lost for instance.
  114620. */
  114621. dispose(): void;
  114622. private _gatherRenderTargets;
  114623. }
  114624. }
  114625. declare module BABYLON {
  114626. /**
  114627. * A point light is a light defined by an unique point in world space.
  114628. * The light is emitted in every direction from this point.
  114629. * A good example of a point light is a standard light bulb.
  114630. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114631. */
  114632. export class PointLight extends ShadowLight {
  114633. private _shadowAngle;
  114634. /**
  114635. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114636. * This specifies what angle the shadow will use to be created.
  114637. *
  114638. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114639. */
  114640. /**
  114641. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114642. * This specifies what angle the shadow will use to be created.
  114643. *
  114644. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114645. */
  114646. shadowAngle: number;
  114647. /**
  114648. * Gets the direction if it has been set.
  114649. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114650. */
  114651. /**
  114652. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114653. */
  114654. direction: Vector3;
  114655. /**
  114656. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  114657. * A PointLight emits the light in every direction.
  114658. * It can cast shadows.
  114659. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  114660. * ```javascript
  114661. * var pointLight = new PointLight("pl", camera.position, scene);
  114662. * ```
  114663. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114664. * @param name The light friendly name
  114665. * @param position The position of the point light in the scene
  114666. * @param scene The scene the lights belongs to
  114667. */
  114668. constructor(name: string, position: Vector3, scene: Scene);
  114669. /**
  114670. * Returns the string "PointLight"
  114671. * @returns the class name
  114672. */
  114673. getClassName(): string;
  114674. /**
  114675. * Returns the integer 0.
  114676. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114677. */
  114678. getTypeID(): number;
  114679. /**
  114680. * Specifies wether or not the shadowmap should be a cube texture.
  114681. * @returns true if the shadowmap needs to be a cube texture.
  114682. */
  114683. needCube(): boolean;
  114684. /**
  114685. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  114686. * @param faceIndex The index of the face we are computed the direction to generate shadow
  114687. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  114688. */
  114689. getShadowDirection(faceIndex?: number): Vector3;
  114690. /**
  114691. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  114692. * - fov = PI / 2
  114693. * - aspect ratio : 1.0
  114694. * - z-near and far equal to the active camera minZ and maxZ.
  114695. * Returns the PointLight.
  114696. */
  114697. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114698. protected _buildUniformLayout(): void;
  114699. /**
  114700. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  114701. * @param effect The effect to update
  114702. * @param lightIndex The index of the light in the effect to update
  114703. * @returns The point light
  114704. */
  114705. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  114706. /**
  114707. * Prepares the list of defines specific to the light type.
  114708. * @param defines the list of defines
  114709. * @param lightIndex defines the index of the light for the effect
  114710. */
  114711. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114712. }
  114713. }
  114714. declare module BABYLON {
  114715. /**
  114716. * Header information of HDR texture files.
  114717. */
  114718. export interface HDRInfo {
  114719. /**
  114720. * The height of the texture in pixels.
  114721. */
  114722. height: number;
  114723. /**
  114724. * The width of the texture in pixels.
  114725. */
  114726. width: number;
  114727. /**
  114728. * The index of the beginning of the data in the binary file.
  114729. */
  114730. dataPosition: number;
  114731. }
  114732. /**
  114733. * This groups tools to convert HDR texture to native colors array.
  114734. */
  114735. export class HDRTools {
  114736. private static Ldexp;
  114737. private static Rgbe2float;
  114738. private static readStringLine;
  114739. /**
  114740. * Reads header information from an RGBE texture stored in a native array.
  114741. * More information on this format are available here:
  114742. * https://en.wikipedia.org/wiki/RGBE_image_format
  114743. *
  114744. * @param uint8array The binary file stored in native array.
  114745. * @return The header information.
  114746. */
  114747. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  114748. /**
  114749. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  114750. * This RGBE texture needs to store the information as a panorama.
  114751. *
  114752. * More information on this format are available here:
  114753. * https://en.wikipedia.org/wiki/RGBE_image_format
  114754. *
  114755. * @param buffer The binary file stored in an array buffer.
  114756. * @param size The expected size of the extracted cubemap.
  114757. * @return The Cube Map information.
  114758. */
  114759. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  114760. /**
  114761. * Returns the pixels data extracted from an RGBE texture.
  114762. * This pixels will be stored left to right up to down in the R G B order in one array.
  114763. *
  114764. * More information on this format are available here:
  114765. * https://en.wikipedia.org/wiki/RGBE_image_format
  114766. *
  114767. * @param uint8array The binary file stored in an array buffer.
  114768. * @param hdrInfo The header information of the file.
  114769. * @return The pixels data in RGB right to left up to down order.
  114770. */
  114771. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  114772. private static RGBE_ReadPixels_RLE;
  114773. }
  114774. }
  114775. declare module BABYLON {
  114776. /**
  114777. * This represents a texture coming from an HDR input.
  114778. *
  114779. * The only supported format is currently panorama picture stored in RGBE format.
  114780. * Example of such files can be found on HDRLib: http://hdrlib.com/
  114781. */
  114782. export class HDRCubeTexture extends BaseTexture {
  114783. private static _facesMapping;
  114784. private _generateHarmonics;
  114785. private _noMipmap;
  114786. private _textureMatrix;
  114787. private _size;
  114788. private _onLoad;
  114789. private _onError;
  114790. /**
  114791. * The texture URL.
  114792. */
  114793. url: string;
  114794. /**
  114795. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  114796. */
  114797. coordinatesMode: number;
  114798. protected _isBlocking: boolean;
  114799. /**
  114800. * Sets wether or not the texture is blocking during loading.
  114801. */
  114802. /**
  114803. * Gets wether or not the texture is blocking during loading.
  114804. */
  114805. isBlocking: boolean;
  114806. protected _rotationY: number;
  114807. /**
  114808. * Sets texture matrix rotation angle around Y axis in radians.
  114809. */
  114810. /**
  114811. * Gets texture matrix rotation angle around Y axis radians.
  114812. */
  114813. rotationY: number;
  114814. /**
  114815. * Gets or sets the center of the bounding box associated with the cube texture
  114816. * It must define where the camera used to render the texture was set
  114817. */
  114818. boundingBoxPosition: Vector3;
  114819. private _boundingBoxSize;
  114820. /**
  114821. * Gets or sets the size of the bounding box associated with the cube texture
  114822. * When defined, the cubemap will switch to local mode
  114823. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  114824. * @example https://www.babylonjs-playground.com/#RNASML
  114825. */
  114826. boundingBoxSize: Vector3;
  114827. /**
  114828. * Instantiates an HDRTexture from the following parameters.
  114829. *
  114830. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  114831. * @param scene The scene the texture will be used in
  114832. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114833. * @param noMipmap Forces to not generate the mipmap if true
  114834. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  114835. * @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)
  114836. * @param reserved Reserved flag for internal use.
  114837. */
  114838. 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>);
  114839. /**
  114840. * Get the current class name of the texture useful for serialization or dynamic coding.
  114841. * @returns "HDRCubeTexture"
  114842. */
  114843. getClassName(): string;
  114844. /**
  114845. * Occurs when the file is raw .hdr file.
  114846. */
  114847. private loadTexture;
  114848. clone(): HDRCubeTexture;
  114849. delayLoad(): void;
  114850. /**
  114851. * Get the texture reflection matrix used to rotate/transform the reflection.
  114852. * @returns the reflection matrix
  114853. */
  114854. getReflectionTextureMatrix(): Matrix;
  114855. /**
  114856. * Set the texture reflection matrix used to rotate/transform the reflection.
  114857. * @param value Define the reflection matrix to set
  114858. */
  114859. setReflectionTextureMatrix(value: Matrix): void;
  114860. /**
  114861. * Parses a JSON representation of an HDR Texture in order to create the texture
  114862. * @param parsedTexture Define the JSON representation
  114863. * @param scene Define the scene the texture should be created in
  114864. * @param rootUrl Define the root url in case we need to load relative dependencies
  114865. * @returns the newly created texture after parsing
  114866. */
  114867. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  114868. serialize(): any;
  114869. }
  114870. }
  114871. declare module BABYLON {
  114872. /**
  114873. * Class used to control physics engine
  114874. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114875. */
  114876. export class PhysicsEngine implements IPhysicsEngine {
  114877. private _physicsPlugin;
  114878. /**
  114879. * Global value used to control the smallest number supported by the simulation
  114880. */
  114881. static Epsilon: number;
  114882. private _impostors;
  114883. private _joints;
  114884. /**
  114885. * Gets the gravity vector used by the simulation
  114886. */
  114887. gravity: Vector3;
  114888. /**
  114889. * Factory used to create the default physics plugin.
  114890. * @returns The default physics plugin
  114891. */
  114892. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  114893. /**
  114894. * Creates a new Physics Engine
  114895. * @param gravity defines the gravity vector used by the simulation
  114896. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114897. */
  114898. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  114899. /**
  114900. * Sets the gravity vector used by the simulation
  114901. * @param gravity defines the gravity vector to use
  114902. */
  114903. setGravity(gravity: Vector3): void;
  114904. /**
  114905. * Set the time step of the physics engine.
  114906. * Default is 1/60.
  114907. * To slow it down, enter 1/600 for example.
  114908. * To speed it up, 1/30
  114909. * @param newTimeStep defines the new timestep to apply to this world.
  114910. */
  114911. setTimeStep(newTimeStep?: number): void;
  114912. /**
  114913. * Get the time step of the physics engine.
  114914. * @returns the current time step
  114915. */
  114916. getTimeStep(): number;
  114917. /**
  114918. * Release all resources
  114919. */
  114920. dispose(): void;
  114921. /**
  114922. * Gets the name of the current physics plugin
  114923. * @returns the name of the plugin
  114924. */
  114925. getPhysicsPluginName(): string;
  114926. /**
  114927. * Adding a new impostor for the impostor tracking.
  114928. * This will be done by the impostor itself.
  114929. * @param impostor the impostor to add
  114930. */
  114931. addImpostor(impostor: PhysicsImpostor): void;
  114932. /**
  114933. * Remove an impostor from the engine.
  114934. * This impostor and its mesh will not longer be updated by the physics engine.
  114935. * @param impostor the impostor to remove
  114936. */
  114937. removeImpostor(impostor: PhysicsImpostor): void;
  114938. /**
  114939. * Add a joint to the physics engine
  114940. * @param mainImpostor defines the main impostor to which the joint is added.
  114941. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114942. * @param joint defines the joint that will connect both impostors.
  114943. */
  114944. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114945. /**
  114946. * Removes a joint from the simulation
  114947. * @param mainImpostor defines the impostor used with the joint
  114948. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114949. * @param joint defines the joint to remove
  114950. */
  114951. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114952. /**
  114953. * Called by the scene. No need to call it.
  114954. * @param delta defines the timespam between frames
  114955. */
  114956. _step(delta: number): void;
  114957. /**
  114958. * Gets the current plugin used to run the simulation
  114959. * @returns current plugin
  114960. */
  114961. getPhysicsPlugin(): IPhysicsEnginePlugin;
  114962. /**
  114963. * Gets the list of physic impostors
  114964. * @returns an array of PhysicsImpostor
  114965. */
  114966. getImpostors(): Array<PhysicsImpostor>;
  114967. /**
  114968. * Gets the impostor for a physics enabled object
  114969. * @param object defines the object impersonated by the impostor
  114970. * @returns the PhysicsImpostor or null if not found
  114971. */
  114972. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  114973. /**
  114974. * Gets the impostor for a physics body object
  114975. * @param body defines physics body used by the impostor
  114976. * @returns the PhysicsImpostor or null if not found
  114977. */
  114978. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  114979. /**
  114980. * Does a raycast in the physics world
  114981. * @param from when should the ray start?
  114982. * @param to when should the ray end?
  114983. * @returns PhysicsRaycastResult
  114984. */
  114985. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114986. }
  114987. }
  114988. declare module BABYLON {
  114989. /** @hidden */
  114990. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  114991. private _useDeltaForWorldStep;
  114992. world: any;
  114993. name: string;
  114994. private _physicsMaterials;
  114995. private _fixedTimeStep;
  114996. private _cannonRaycastResult;
  114997. private _raycastResult;
  114998. private _physicsBodysToRemoveAfterStep;
  114999. BJSCANNON: any;
  115000. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  115001. setGravity(gravity: Vector3): void;
  115002. setTimeStep(timeStep: number): void;
  115003. getTimeStep(): number;
  115004. executeStep(delta: number): void;
  115005. private _removeMarkedPhysicsBodiesFromWorld;
  115006. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115007. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115008. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115009. private _processChildMeshes;
  115010. removePhysicsBody(impostor: PhysicsImpostor): void;
  115011. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115012. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115013. private _addMaterial;
  115014. private _checkWithEpsilon;
  115015. private _createShape;
  115016. private _createHeightmap;
  115017. private _minus90X;
  115018. private _plus90X;
  115019. private _tmpPosition;
  115020. private _tmpDeltaPosition;
  115021. private _tmpUnityRotation;
  115022. private _updatePhysicsBodyTransformation;
  115023. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115024. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115025. isSupported(): boolean;
  115026. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115027. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115028. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115029. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115030. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115031. getBodyMass(impostor: PhysicsImpostor): number;
  115032. getBodyFriction(impostor: PhysicsImpostor): number;
  115033. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115034. getBodyRestitution(impostor: PhysicsImpostor): number;
  115035. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115036. sleepBody(impostor: PhysicsImpostor): void;
  115037. wakeUpBody(impostor: PhysicsImpostor): void;
  115038. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  115039. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115040. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115041. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115042. getRadius(impostor: PhysicsImpostor): number;
  115043. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115044. dispose(): void;
  115045. private _extendNamespace;
  115046. /**
  115047. * Does a raycast in the physics world
  115048. * @param from when should the ray start?
  115049. * @param to when should the ray end?
  115050. * @returns PhysicsRaycastResult
  115051. */
  115052. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115053. }
  115054. }
  115055. declare module BABYLON {
  115056. /** @hidden */
  115057. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  115058. world: any;
  115059. name: string;
  115060. BJSOIMO: any;
  115061. private _raycastResult;
  115062. constructor(iterations?: number, oimoInjection?: any);
  115063. setGravity(gravity: Vector3): void;
  115064. setTimeStep(timeStep: number): void;
  115065. getTimeStep(): number;
  115066. private _tmpImpostorsArray;
  115067. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115068. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115069. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115070. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115071. private _tmpPositionVector;
  115072. removePhysicsBody(impostor: PhysicsImpostor): void;
  115073. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115074. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115075. isSupported(): boolean;
  115076. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115077. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115078. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115079. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115080. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115081. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115082. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115083. getBodyMass(impostor: PhysicsImpostor): number;
  115084. getBodyFriction(impostor: PhysicsImpostor): number;
  115085. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115086. getBodyRestitution(impostor: PhysicsImpostor): number;
  115087. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115088. sleepBody(impostor: PhysicsImpostor): void;
  115089. wakeUpBody(impostor: PhysicsImpostor): void;
  115090. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115091. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  115092. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  115093. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115094. getRadius(impostor: PhysicsImpostor): number;
  115095. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115096. dispose(): void;
  115097. /**
  115098. * Does a raycast in the physics world
  115099. * @param from when should the ray start?
  115100. * @param to when should the ray end?
  115101. * @returns PhysicsRaycastResult
  115102. */
  115103. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115104. }
  115105. }
  115106. declare module BABYLON {
  115107. /**
  115108. * Class containing static functions to help procedurally build meshes
  115109. */
  115110. export class RibbonBuilder {
  115111. /**
  115112. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115113. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115114. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115115. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115116. * * 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
  115117. * * 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
  115118. * * 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
  115119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115121. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115122. * * 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
  115123. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115124. * * 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
  115125. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115127. * @param name defines the name of the mesh
  115128. * @param options defines the options used to create the mesh
  115129. * @param scene defines the hosting scene
  115130. * @returns the ribbon mesh
  115131. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115132. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115133. */
  115134. static CreateRibbon(name: string, options: {
  115135. pathArray: Vector3[][];
  115136. closeArray?: boolean;
  115137. closePath?: boolean;
  115138. offset?: number;
  115139. updatable?: boolean;
  115140. sideOrientation?: number;
  115141. frontUVs?: Vector4;
  115142. backUVs?: Vector4;
  115143. instance?: Mesh;
  115144. invertUV?: boolean;
  115145. uvs?: Vector2[];
  115146. colors?: Color4[];
  115147. }, scene?: Nullable<Scene>): Mesh;
  115148. }
  115149. }
  115150. declare module BABYLON {
  115151. /**
  115152. * Class containing static functions to help procedurally build meshes
  115153. */
  115154. export class ShapeBuilder {
  115155. /**
  115156. * 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.
  115157. * * 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.
  115158. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115159. * * 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.
  115160. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115161. * * 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
  115162. * * 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
  115163. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115168. * @param name defines the name of the mesh
  115169. * @param options defines the options used to create the mesh
  115170. * @param scene defines the hosting scene
  115171. * @returns the extruded shape mesh
  115172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115174. */
  115175. static ExtrudeShape(name: string, options: {
  115176. shape: Vector3[];
  115177. path: Vector3[];
  115178. scale?: number;
  115179. rotation?: number;
  115180. cap?: number;
  115181. updatable?: boolean;
  115182. sideOrientation?: number;
  115183. frontUVs?: Vector4;
  115184. backUVs?: Vector4;
  115185. instance?: Mesh;
  115186. invertUV?: boolean;
  115187. }, scene?: Nullable<Scene>): Mesh;
  115188. /**
  115189. * Creates an custom extruded shape mesh.
  115190. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115191. * * 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.
  115192. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115193. * * 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
  115194. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115195. * * 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
  115196. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115197. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115198. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115199. * * 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
  115200. * * 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
  115201. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115204. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115206. * @param name defines the name of the mesh
  115207. * @param options defines the options used to create the mesh
  115208. * @param scene defines the hosting scene
  115209. * @returns the custom extruded shape mesh
  115210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115211. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115213. */
  115214. static ExtrudeShapeCustom(name: string, options: {
  115215. shape: Vector3[];
  115216. path: Vector3[];
  115217. scaleFunction?: any;
  115218. rotationFunction?: any;
  115219. ribbonCloseArray?: boolean;
  115220. ribbonClosePath?: boolean;
  115221. cap?: number;
  115222. updatable?: boolean;
  115223. sideOrientation?: number;
  115224. frontUVs?: Vector4;
  115225. backUVs?: Vector4;
  115226. instance?: Mesh;
  115227. invertUV?: boolean;
  115228. }, scene?: Nullable<Scene>): Mesh;
  115229. private static _ExtrudeShapeGeneric;
  115230. }
  115231. }
  115232. declare module BABYLON {
  115233. /**
  115234. * AmmoJS Physics plugin
  115235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  115236. * @see https://github.com/kripken/ammo.js/
  115237. */
  115238. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  115239. private _useDeltaForWorldStep;
  115240. /**
  115241. * Reference to the Ammo library
  115242. */
  115243. bjsAMMO: any;
  115244. /**
  115245. * Created ammoJS world which physics bodies are added to
  115246. */
  115247. world: any;
  115248. /**
  115249. * Name of the plugin
  115250. */
  115251. name: string;
  115252. private _timeStep;
  115253. private _fixedTimeStep;
  115254. private _maxSteps;
  115255. private _tmpQuaternion;
  115256. private _tmpAmmoTransform;
  115257. private _tmpAmmoQuaternion;
  115258. private _tmpAmmoConcreteContactResultCallback;
  115259. private _collisionConfiguration;
  115260. private _dispatcher;
  115261. private _overlappingPairCache;
  115262. private _solver;
  115263. private _softBodySolver;
  115264. private _tmpAmmoVectorA;
  115265. private _tmpAmmoVectorB;
  115266. private _tmpAmmoVectorC;
  115267. private _tmpAmmoVectorD;
  115268. private _tmpContactCallbackResult;
  115269. private _tmpAmmoVectorRCA;
  115270. private _tmpAmmoVectorRCB;
  115271. private _raycastResult;
  115272. private static readonly DISABLE_COLLISION_FLAG;
  115273. private static readonly KINEMATIC_FLAG;
  115274. private static readonly DISABLE_DEACTIVATION_FLAG;
  115275. /**
  115276. * Initializes the ammoJS plugin
  115277. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  115278. * @param ammoInjection can be used to inject your own ammo reference
  115279. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  115280. */
  115281. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  115282. /**
  115283. * Sets the gravity of the physics world (m/(s^2))
  115284. * @param gravity Gravity to set
  115285. */
  115286. setGravity(gravity: Vector3): void;
  115287. /**
  115288. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  115289. * @param timeStep timestep to use in seconds
  115290. */
  115291. setTimeStep(timeStep: number): void;
  115292. /**
  115293. * 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)
  115294. * @param fixedTimeStep fixedTimeStep to use in seconds
  115295. */
  115296. setFixedTimeStep(fixedTimeStep: number): void;
  115297. /**
  115298. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  115299. * @param maxSteps the maximum number of steps by the physics engine per frame
  115300. */
  115301. setMaxSteps(maxSteps: number): void;
  115302. /**
  115303. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  115304. * @returns the current timestep in seconds
  115305. */
  115306. getTimeStep(): number;
  115307. private _isImpostorInContact;
  115308. private _isImpostorPairInContact;
  115309. private _stepSimulation;
  115310. /**
  115311. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  115312. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  115313. * After the step the babylon meshes are set to the position of the physics imposters
  115314. * @param delta amount of time to step forward
  115315. * @param impostors array of imposters to update before/after the step
  115316. */
  115317. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115318. /**
  115319. * Update babylon mesh to match physics world object
  115320. * @param impostor imposter to match
  115321. */
  115322. private _afterSoftStep;
  115323. /**
  115324. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115325. * @param impostor imposter to match
  115326. */
  115327. private _ropeStep;
  115328. /**
  115329. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115330. * @param impostor imposter to match
  115331. */
  115332. private _softbodyOrClothStep;
  115333. private _tmpVector;
  115334. private _tmpMatrix;
  115335. /**
  115336. * Applies an impulse on the imposter
  115337. * @param impostor imposter to apply impulse to
  115338. * @param force amount of force to be applied to the imposter
  115339. * @param contactPoint the location to apply the impulse on the imposter
  115340. */
  115341. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115342. /**
  115343. * Applies a force on the imposter
  115344. * @param impostor imposter to apply force
  115345. * @param force amount of force to be applied to the imposter
  115346. * @param contactPoint the location to apply the force on the imposter
  115347. */
  115348. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115349. /**
  115350. * Creates a physics body using the plugin
  115351. * @param impostor the imposter to create the physics body on
  115352. */
  115353. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115354. /**
  115355. * Removes the physics body from the imposter and disposes of the body's memory
  115356. * @param impostor imposter to remove the physics body from
  115357. */
  115358. removePhysicsBody(impostor: PhysicsImpostor): void;
  115359. /**
  115360. * Generates a joint
  115361. * @param impostorJoint the imposter joint to create the joint with
  115362. */
  115363. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115364. /**
  115365. * Removes a joint
  115366. * @param impostorJoint the imposter joint to remove the joint from
  115367. */
  115368. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115369. private _addMeshVerts;
  115370. /**
  115371. * Initialise the soft body vertices to match its object's (mesh) vertices
  115372. * Softbody vertices (nodes) are in world space and to match this
  115373. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  115374. * @param impostor to create the softbody for
  115375. */
  115376. private _softVertexData;
  115377. /**
  115378. * Create an impostor's soft body
  115379. * @param impostor to create the softbody for
  115380. */
  115381. private _createSoftbody;
  115382. /**
  115383. * Create cloth for an impostor
  115384. * @param impostor to create the softbody for
  115385. */
  115386. private _createCloth;
  115387. /**
  115388. * Create rope for an impostor
  115389. * @param impostor to create the softbody for
  115390. */
  115391. private _createRope;
  115392. private _addHullVerts;
  115393. private _createShape;
  115394. /**
  115395. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  115396. * @param impostor imposter containing the physics body and babylon object
  115397. */
  115398. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115399. /**
  115400. * Sets the babylon object's position/rotation from the physics body's position/rotation
  115401. * @param impostor imposter containing the physics body and babylon object
  115402. * @param newPosition new position
  115403. * @param newRotation new rotation
  115404. */
  115405. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115406. /**
  115407. * If this plugin is supported
  115408. * @returns true if its supported
  115409. */
  115410. isSupported(): boolean;
  115411. /**
  115412. * Sets the linear velocity of the physics body
  115413. * @param impostor imposter to set the velocity on
  115414. * @param velocity velocity to set
  115415. */
  115416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115417. /**
  115418. * Sets the angular velocity of the physics body
  115419. * @param impostor imposter to set the velocity on
  115420. * @param velocity velocity to set
  115421. */
  115422. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115423. /**
  115424. * gets the linear velocity
  115425. * @param impostor imposter to get linear velocity from
  115426. * @returns linear velocity
  115427. */
  115428. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115429. /**
  115430. * gets the angular velocity
  115431. * @param impostor imposter to get angular velocity from
  115432. * @returns angular velocity
  115433. */
  115434. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115435. /**
  115436. * Sets the mass of physics body
  115437. * @param impostor imposter to set the mass on
  115438. * @param mass mass to set
  115439. */
  115440. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115441. /**
  115442. * Gets the mass of the physics body
  115443. * @param impostor imposter to get the mass from
  115444. * @returns mass
  115445. */
  115446. getBodyMass(impostor: PhysicsImpostor): number;
  115447. /**
  115448. * Gets friction of the impostor
  115449. * @param impostor impostor to get friction from
  115450. * @returns friction value
  115451. */
  115452. getBodyFriction(impostor: PhysicsImpostor): number;
  115453. /**
  115454. * Sets friction of the impostor
  115455. * @param impostor impostor to set friction on
  115456. * @param friction friction value
  115457. */
  115458. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115459. /**
  115460. * Gets restitution of the impostor
  115461. * @param impostor impostor to get restitution from
  115462. * @returns restitution value
  115463. */
  115464. getBodyRestitution(impostor: PhysicsImpostor): number;
  115465. /**
  115466. * Sets resitution of the impostor
  115467. * @param impostor impostor to set resitution on
  115468. * @param restitution resitution value
  115469. */
  115470. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115471. /**
  115472. * Gets pressure inside the impostor
  115473. * @param impostor impostor to get pressure from
  115474. * @returns pressure value
  115475. */
  115476. getBodyPressure(impostor: PhysicsImpostor): number;
  115477. /**
  115478. * Sets pressure inside a soft body impostor
  115479. * Cloth and rope must remain 0 pressure
  115480. * @param impostor impostor to set pressure on
  115481. * @param pressure pressure value
  115482. */
  115483. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  115484. /**
  115485. * Gets stiffness of the impostor
  115486. * @param impostor impostor to get stiffness from
  115487. * @returns pressure value
  115488. */
  115489. getBodyStiffness(impostor: PhysicsImpostor): number;
  115490. /**
  115491. * Sets stiffness of the impostor
  115492. * @param impostor impostor to set stiffness on
  115493. * @param stiffness stiffness value from 0 to 1
  115494. */
  115495. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  115496. /**
  115497. * Gets velocityIterations of the impostor
  115498. * @param impostor impostor to get velocity iterations from
  115499. * @returns velocityIterations value
  115500. */
  115501. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  115502. /**
  115503. * Sets velocityIterations of the impostor
  115504. * @param impostor impostor to set velocity iterations on
  115505. * @param velocityIterations velocityIterations value
  115506. */
  115507. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  115508. /**
  115509. * Gets positionIterations of the impostor
  115510. * @param impostor impostor to get position iterations from
  115511. * @returns positionIterations value
  115512. */
  115513. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  115514. /**
  115515. * Sets positionIterations of the impostor
  115516. * @param impostor impostor to set position on
  115517. * @param positionIterations positionIterations value
  115518. */
  115519. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  115520. /**
  115521. * Append an anchor to a cloth object
  115522. * @param impostor is the cloth impostor to add anchor to
  115523. * @param otherImpostor is the rigid impostor to anchor to
  115524. * @param width ratio across width from 0 to 1
  115525. * @param height ratio up height from 0 to 1
  115526. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  115527. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115528. */
  115529. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115530. /**
  115531. * Append an hook to a rope object
  115532. * @param impostor is the rope impostor to add hook to
  115533. * @param otherImpostor is the rigid impostor to hook to
  115534. * @param length ratio along the rope from 0 to 1
  115535. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  115536. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115537. */
  115538. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115539. /**
  115540. * Sleeps the physics body and stops it from being active
  115541. * @param impostor impostor to sleep
  115542. */
  115543. sleepBody(impostor: PhysicsImpostor): void;
  115544. /**
  115545. * Activates the physics body
  115546. * @param impostor impostor to activate
  115547. */
  115548. wakeUpBody(impostor: PhysicsImpostor): void;
  115549. /**
  115550. * Updates the distance parameters of the joint
  115551. * @param joint joint to update
  115552. * @param maxDistance maximum distance of the joint
  115553. * @param minDistance minimum distance of the joint
  115554. */
  115555. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115556. /**
  115557. * Sets a motor on the joint
  115558. * @param joint joint to set motor on
  115559. * @param speed speed of the motor
  115560. * @param maxForce maximum force of the motor
  115561. * @param motorIndex index of the motor
  115562. */
  115563. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115564. /**
  115565. * Sets the motors limit
  115566. * @param joint joint to set limit on
  115567. * @param upperLimit upper limit
  115568. * @param lowerLimit lower limit
  115569. */
  115570. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115571. /**
  115572. * Syncs the position and rotation of a mesh with the impostor
  115573. * @param mesh mesh to sync
  115574. * @param impostor impostor to update the mesh with
  115575. */
  115576. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115577. /**
  115578. * Gets the radius of the impostor
  115579. * @param impostor impostor to get radius from
  115580. * @returns the radius
  115581. */
  115582. getRadius(impostor: PhysicsImpostor): number;
  115583. /**
  115584. * Gets the box size of the impostor
  115585. * @param impostor impostor to get box size from
  115586. * @param result the resulting box size
  115587. */
  115588. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115589. /**
  115590. * Disposes of the impostor
  115591. */
  115592. dispose(): void;
  115593. /**
  115594. * Does a raycast in the physics world
  115595. * @param from when should the ray start?
  115596. * @param to when should the ray end?
  115597. * @returns PhysicsRaycastResult
  115598. */
  115599. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115600. }
  115601. }
  115602. declare module BABYLON {
  115603. interface AbstractScene {
  115604. /**
  115605. * The list of reflection probes added to the scene
  115606. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115607. */
  115608. reflectionProbes: Array<ReflectionProbe>;
  115609. /**
  115610. * Removes the given reflection probe from this scene.
  115611. * @param toRemove The reflection probe to remove
  115612. * @returns The index of the removed reflection probe
  115613. */
  115614. removeReflectionProbe(toRemove: ReflectionProbe): number;
  115615. /**
  115616. * Adds the given reflection probe to this scene.
  115617. * @param newReflectionProbe The reflection probe to add
  115618. */
  115619. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  115620. }
  115621. /**
  115622. * Class used to generate realtime reflection / refraction cube textures
  115623. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115624. */
  115625. export class ReflectionProbe {
  115626. /** defines the name of the probe */
  115627. name: string;
  115628. private _scene;
  115629. private _renderTargetTexture;
  115630. private _projectionMatrix;
  115631. private _viewMatrix;
  115632. private _target;
  115633. private _add;
  115634. private _attachedMesh;
  115635. private _invertYAxis;
  115636. /** Gets or sets probe position (center of the cube map) */
  115637. position: Vector3;
  115638. /**
  115639. * Creates a new reflection probe
  115640. * @param name defines the name of the probe
  115641. * @param size defines the texture resolution (for each face)
  115642. * @param scene defines the hosting scene
  115643. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  115644. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  115645. */
  115646. constructor(
  115647. /** defines the name of the probe */
  115648. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  115649. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  115650. samples: number;
  115651. /** Gets or sets the refresh rate to use (on every frame by default) */
  115652. refreshRate: number;
  115653. /**
  115654. * Gets the hosting scene
  115655. * @returns a Scene
  115656. */
  115657. getScene(): Scene;
  115658. /** Gets the internal CubeTexture used to render to */
  115659. readonly cubeTexture: RenderTargetTexture;
  115660. /** Gets the list of meshes to render */
  115661. readonly renderList: Nullable<AbstractMesh[]>;
  115662. /**
  115663. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  115664. * @param mesh defines the mesh to attach to
  115665. */
  115666. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115667. /**
  115668. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  115669. * @param renderingGroupId The rendering group id corresponding to its index
  115670. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  115671. */
  115672. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  115673. /**
  115674. * Clean all associated resources
  115675. */
  115676. dispose(): void;
  115677. /**
  115678. * Converts the reflection probe information to a readable string for debug purpose.
  115679. * @param fullDetails Supports for multiple levels of logging within scene loading
  115680. * @returns the human readable reflection probe info
  115681. */
  115682. toString(fullDetails?: boolean): string;
  115683. /**
  115684. * Get the class name of the relfection probe.
  115685. * @returns "ReflectionProbe"
  115686. */
  115687. getClassName(): string;
  115688. /**
  115689. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  115690. * @returns The JSON representation of the texture
  115691. */
  115692. serialize(): any;
  115693. /**
  115694. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  115695. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  115696. * @param scene Define the scene the parsed reflection probe should be instantiated in
  115697. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  115698. * @returns The parsed reflection probe if successful
  115699. */
  115700. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  115701. }
  115702. }
  115703. declare module BABYLON {
  115704. /** @hidden */
  115705. export var _BabylonLoaderRegistered: boolean;
  115706. }
  115707. declare module BABYLON {
  115708. /**
  115709. * The Physically based simple base material of BJS.
  115710. *
  115711. * This enables better naming and convention enforcements on top of the pbrMaterial.
  115712. * It is used as the base class for both the specGloss and metalRough conventions.
  115713. */
  115714. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  115715. /**
  115716. * Number of Simultaneous lights allowed on the material.
  115717. */
  115718. maxSimultaneousLights: number;
  115719. /**
  115720. * If sets to true, disables all the lights affecting the material.
  115721. */
  115722. disableLighting: boolean;
  115723. /**
  115724. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  115725. */
  115726. environmentTexture: BaseTexture;
  115727. /**
  115728. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115729. */
  115730. invertNormalMapX: boolean;
  115731. /**
  115732. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115733. */
  115734. invertNormalMapY: boolean;
  115735. /**
  115736. * Normal map used in the model.
  115737. */
  115738. normalTexture: BaseTexture;
  115739. /**
  115740. * Emissivie color used to self-illuminate the model.
  115741. */
  115742. emissiveColor: Color3;
  115743. /**
  115744. * Emissivie texture used to self-illuminate the model.
  115745. */
  115746. emissiveTexture: BaseTexture;
  115747. /**
  115748. * Occlusion Channel Strenght.
  115749. */
  115750. occlusionStrength: number;
  115751. /**
  115752. * Occlusion Texture of the material (adding extra occlusion effects).
  115753. */
  115754. occlusionTexture: BaseTexture;
  115755. /**
  115756. * Defines the alpha limits in alpha test mode.
  115757. */
  115758. alphaCutOff: number;
  115759. /**
  115760. * Gets the current double sided mode.
  115761. */
  115762. /**
  115763. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115764. */
  115765. doubleSided: boolean;
  115766. /**
  115767. * Stores the pre-calculated light information of a mesh in a texture.
  115768. */
  115769. lightmapTexture: BaseTexture;
  115770. /**
  115771. * If true, the light map contains occlusion information instead of lighting info.
  115772. */
  115773. useLightmapAsShadowmap: boolean;
  115774. /**
  115775. * Instantiates a new PBRMaterial instance.
  115776. *
  115777. * @param name The material name
  115778. * @param scene The scene the material will be use in.
  115779. */
  115780. constructor(name: string, scene: Scene);
  115781. getClassName(): string;
  115782. }
  115783. }
  115784. declare module BABYLON {
  115785. /**
  115786. * The PBR material of BJS following the metal roughness convention.
  115787. *
  115788. * This fits to the PBR convention in the GLTF definition:
  115789. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  115790. */
  115791. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  115792. /**
  115793. * The base color has two different interpretations depending on the value of metalness.
  115794. * When the material is a metal, the base color is the specific measured reflectance value
  115795. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  115796. * of the material.
  115797. */
  115798. baseColor: Color3;
  115799. /**
  115800. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  115801. * well as opacity information in the alpha channel.
  115802. */
  115803. baseTexture: BaseTexture;
  115804. /**
  115805. * Specifies the metallic scalar value of the material.
  115806. * Can also be used to scale the metalness values of the metallic texture.
  115807. */
  115808. metallic: number;
  115809. /**
  115810. * Specifies the roughness scalar value of the material.
  115811. * Can also be used to scale the roughness values of the metallic texture.
  115812. */
  115813. roughness: number;
  115814. /**
  115815. * Texture containing both the metallic value in the B channel and the
  115816. * roughness value in the G channel to keep better precision.
  115817. */
  115818. metallicRoughnessTexture: BaseTexture;
  115819. /**
  115820. * Instantiates a new PBRMetalRoughnessMaterial instance.
  115821. *
  115822. * @param name The material name
  115823. * @param scene The scene the material will be use in.
  115824. */
  115825. constructor(name: string, scene: Scene);
  115826. /**
  115827. * Return the currrent class name of the material.
  115828. */
  115829. getClassName(): string;
  115830. /**
  115831. * Makes a duplicate of the current material.
  115832. * @param name - name to use for the new material.
  115833. */
  115834. clone(name: string): PBRMetallicRoughnessMaterial;
  115835. /**
  115836. * Serialize the material to a parsable JSON object.
  115837. */
  115838. serialize(): any;
  115839. /**
  115840. * Parses a JSON object correponding to the serialize function.
  115841. */
  115842. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  115843. }
  115844. }
  115845. declare module BABYLON {
  115846. /**
  115847. * The PBR material of BJS following the specular glossiness convention.
  115848. *
  115849. * This fits to the PBR convention in the GLTF definition:
  115850. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  115851. */
  115852. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  115853. /**
  115854. * Specifies the diffuse color of the material.
  115855. */
  115856. diffuseColor: Color3;
  115857. /**
  115858. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  115859. * channel.
  115860. */
  115861. diffuseTexture: BaseTexture;
  115862. /**
  115863. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  115864. */
  115865. specularColor: Color3;
  115866. /**
  115867. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  115868. */
  115869. glossiness: number;
  115870. /**
  115871. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  115872. */
  115873. specularGlossinessTexture: BaseTexture;
  115874. /**
  115875. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  115876. *
  115877. * @param name The material name
  115878. * @param scene The scene the material will be use in.
  115879. */
  115880. constructor(name: string, scene: Scene);
  115881. /**
  115882. * Return the currrent class name of the material.
  115883. */
  115884. getClassName(): string;
  115885. /**
  115886. * Makes a duplicate of the current material.
  115887. * @param name - name to use for the new material.
  115888. */
  115889. clone(name: string): PBRSpecularGlossinessMaterial;
  115890. /**
  115891. * Serialize the material to a parsable JSON object.
  115892. */
  115893. serialize(): any;
  115894. /**
  115895. * Parses a JSON object correponding to the serialize function.
  115896. */
  115897. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  115898. }
  115899. }
  115900. declare module BABYLON {
  115901. /**
  115902. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  115903. * It can help converting any input color in a desired output one. This can then be used to create effects
  115904. * from sepia, black and white to sixties or futuristic rendering...
  115905. *
  115906. * The only supported format is currently 3dl.
  115907. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  115908. */
  115909. export class ColorGradingTexture extends BaseTexture {
  115910. /**
  115911. * The current texture matrix. (will always be identity in color grading texture)
  115912. */
  115913. private _textureMatrix;
  115914. /**
  115915. * The texture URL.
  115916. */
  115917. url: string;
  115918. /**
  115919. * Empty line regex stored for GC.
  115920. */
  115921. private static _noneEmptyLineRegex;
  115922. private _engine;
  115923. /**
  115924. * Instantiates a ColorGradingTexture from the following parameters.
  115925. *
  115926. * @param url The location of the color gradind data (currently only supporting 3dl)
  115927. * @param scene The scene the texture will be used in
  115928. */
  115929. constructor(url: string, scene: Scene);
  115930. /**
  115931. * Returns the texture matrix used in most of the material.
  115932. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  115933. */
  115934. getTextureMatrix(): Matrix;
  115935. /**
  115936. * Occurs when the file being loaded is a .3dl LUT file.
  115937. */
  115938. private load3dlTexture;
  115939. /**
  115940. * Starts the loading process of the texture.
  115941. */
  115942. private loadTexture;
  115943. /**
  115944. * Clones the color gradind texture.
  115945. */
  115946. clone(): ColorGradingTexture;
  115947. /**
  115948. * Called during delayed load for textures.
  115949. */
  115950. delayLoad(): void;
  115951. /**
  115952. * Parses a color grading texture serialized by Babylon.
  115953. * @param parsedTexture The texture information being parsedTexture
  115954. * @param scene The scene to load the texture in
  115955. * @param rootUrl The root url of the data assets to load
  115956. * @return A color gradind texture
  115957. */
  115958. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  115959. /**
  115960. * Serializes the LUT texture to json format.
  115961. */
  115962. serialize(): any;
  115963. }
  115964. }
  115965. declare module BABYLON {
  115966. /**
  115967. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  115968. */
  115969. export class EquiRectangularCubeTexture extends BaseTexture {
  115970. /** The six faces of the cube. */
  115971. private static _FacesMapping;
  115972. private _noMipmap;
  115973. private _onLoad;
  115974. private _onError;
  115975. /** The size of the cubemap. */
  115976. private _size;
  115977. /** The buffer of the image. */
  115978. private _buffer;
  115979. /** The width of the input image. */
  115980. private _width;
  115981. /** The height of the input image. */
  115982. private _height;
  115983. /** The URL to the image. */
  115984. url: string;
  115985. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  115986. coordinatesMode: number;
  115987. /**
  115988. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  115989. * @param url The location of the image
  115990. * @param scene The scene the texture will be used in
  115991. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115992. * @param noMipmap Forces to not generate the mipmap if true
  115993. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115994. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115995. * @param onLoad — defines a callback called when texture is loaded
  115996. * @param onError — defines a callback called if there is an error
  115997. */
  115998. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  115999. /**
  116000. * Load the image data, by putting the image on a canvas and extracting its buffer.
  116001. */
  116002. private loadImage;
  116003. /**
  116004. * Convert the image buffer into a cubemap and create a CubeTexture.
  116005. */
  116006. private loadTexture;
  116007. /**
  116008. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  116009. * @param buffer The ArrayBuffer that should be converted.
  116010. * @returns The buffer as Float32Array.
  116011. */
  116012. private getFloat32ArrayFromArrayBuffer;
  116013. /**
  116014. * Get the current class name of the texture useful for serialization or dynamic coding.
  116015. * @returns "EquiRectangularCubeTexture"
  116016. */
  116017. getClassName(): string;
  116018. /**
  116019. * Create a clone of the current EquiRectangularCubeTexture and return it.
  116020. * @returns A clone of the current EquiRectangularCubeTexture.
  116021. */
  116022. clone(): EquiRectangularCubeTexture;
  116023. }
  116024. }
  116025. declare module BABYLON {
  116026. /**
  116027. * Based on jsTGALoader - Javascript loader for TGA file
  116028. * By Vincent Thibault
  116029. * @see http://blog.robrowser.com/javascript-tga-loader.html
  116030. */
  116031. export class TGATools {
  116032. private static _TYPE_INDEXED;
  116033. private static _TYPE_RGB;
  116034. private static _TYPE_GREY;
  116035. private static _TYPE_RLE_INDEXED;
  116036. private static _TYPE_RLE_RGB;
  116037. private static _TYPE_RLE_GREY;
  116038. private static _ORIGIN_MASK;
  116039. private static _ORIGIN_SHIFT;
  116040. private static _ORIGIN_BL;
  116041. private static _ORIGIN_BR;
  116042. private static _ORIGIN_UL;
  116043. private static _ORIGIN_UR;
  116044. /**
  116045. * Gets the header of a TGA file
  116046. * @param data defines the TGA data
  116047. * @returns the header
  116048. */
  116049. static GetTGAHeader(data: Uint8Array): any;
  116050. /**
  116051. * Uploads TGA content to a Babylon Texture
  116052. * @hidden
  116053. */
  116054. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  116055. /** @hidden */
  116056. 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;
  116057. /** @hidden */
  116058. 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;
  116059. /** @hidden */
  116060. 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;
  116061. /** @hidden */
  116062. 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;
  116063. /** @hidden */
  116064. 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;
  116065. /** @hidden */
  116066. 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;
  116067. }
  116068. }
  116069. declare module BABYLON {
  116070. /**
  116071. * Implementation of the TGA Texture Loader.
  116072. * @hidden
  116073. */
  116074. export class _TGATextureLoader implements IInternalTextureLoader {
  116075. /**
  116076. * Defines wether the loader supports cascade loading the different faces.
  116077. */
  116078. readonly supportCascades: boolean;
  116079. /**
  116080. * This returns if the loader support the current file information.
  116081. * @param extension defines the file extension of the file being loaded
  116082. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116083. * @param fallback defines the fallback internal texture if any
  116084. * @param isBase64 defines whether the texture is encoded as a base64
  116085. * @param isBuffer defines whether the texture data are stored as a buffer
  116086. * @returns true if the loader can load the specified file
  116087. */
  116088. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116089. /**
  116090. * Transform the url before loading if required.
  116091. * @param rootUrl the url of the texture
  116092. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116093. * @returns the transformed texture
  116094. */
  116095. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116096. /**
  116097. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116098. * @param rootUrl the url of the texture
  116099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116100. * @returns the fallback texture
  116101. */
  116102. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116103. /**
  116104. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116105. * @param data contains the texture data
  116106. * @param texture defines the BabylonJS internal texture
  116107. * @param createPolynomials will be true if polynomials have been requested
  116108. * @param onLoad defines the callback to trigger once the texture is ready
  116109. * @param onError defines the callback to trigger in case of error
  116110. */
  116111. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116112. /**
  116113. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116114. * @param data contains the texture data
  116115. * @param texture defines the BabylonJS internal texture
  116116. * @param callback defines the method to call once ready to upload
  116117. */
  116118. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116119. }
  116120. }
  116121. declare module BABYLON {
  116122. /**
  116123. * Info about the .basis files
  116124. */
  116125. class BasisFileInfo {
  116126. /**
  116127. * If the file has alpha
  116128. */
  116129. hasAlpha: boolean;
  116130. /**
  116131. * Info about each image of the basis file
  116132. */
  116133. images: Array<{
  116134. levels: Array<{
  116135. width: number;
  116136. height: number;
  116137. transcodedPixels: ArrayBufferView;
  116138. }>;
  116139. }>;
  116140. }
  116141. /**
  116142. * Result of transcoding a basis file
  116143. */
  116144. class TranscodeResult {
  116145. /**
  116146. * Info about the .basis file
  116147. */
  116148. fileInfo: BasisFileInfo;
  116149. /**
  116150. * Format to use when loading the file
  116151. */
  116152. format: number;
  116153. }
  116154. /**
  116155. * Configuration options for the Basis transcoder
  116156. */
  116157. export class BasisTranscodeConfiguration {
  116158. /**
  116159. * Supported compression formats used to determine the supported output format of the transcoder
  116160. */
  116161. supportedCompressionFormats?: {
  116162. /**
  116163. * etc1 compression format
  116164. */
  116165. etc1?: boolean;
  116166. /**
  116167. * s3tc compression format
  116168. */
  116169. s3tc?: boolean;
  116170. /**
  116171. * pvrtc compression format
  116172. */
  116173. pvrtc?: boolean;
  116174. /**
  116175. * etc2 compression format
  116176. */
  116177. etc2?: boolean;
  116178. };
  116179. /**
  116180. * If mipmap levels should be loaded for transcoded images (Default: true)
  116181. */
  116182. loadMipmapLevels?: boolean;
  116183. /**
  116184. * Index of a single image to load (Default: all images)
  116185. */
  116186. loadSingleImage?: number;
  116187. }
  116188. /**
  116189. * Used to load .Basis files
  116190. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  116191. */
  116192. export class BasisTools {
  116193. private static _IgnoreSupportedFormats;
  116194. /**
  116195. * URL to use when loading the basis transcoder
  116196. */
  116197. static JSModuleURL: string;
  116198. /**
  116199. * URL to use when loading the wasm module for the transcoder
  116200. */
  116201. static WasmModuleURL: string;
  116202. /**
  116203. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  116204. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  116205. * @returns internal format corresponding to the Basis format
  116206. */
  116207. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  116208. private static _WorkerPromise;
  116209. private static _Worker;
  116210. private static _actionId;
  116211. private static _CreateWorkerAsync;
  116212. /**
  116213. * Transcodes a loaded image file to compressed pixel data
  116214. * @param imageData image data to transcode
  116215. * @param config configuration options for the transcoding
  116216. * @returns a promise resulting in the transcoded image
  116217. */
  116218. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  116219. /**
  116220. * Loads a texture from the transcode result
  116221. * @param texture texture load to
  116222. * @param transcodeResult the result of transcoding the basis file to load from
  116223. */
  116224. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  116225. }
  116226. }
  116227. declare module BABYLON {
  116228. /**
  116229. * Loader for .basis file format
  116230. */
  116231. export class _BasisTextureLoader implements IInternalTextureLoader {
  116232. /**
  116233. * Defines whether the loader supports cascade loading the different faces.
  116234. */
  116235. readonly supportCascades: boolean;
  116236. /**
  116237. * This returns if the loader support the current file information.
  116238. * @param extension defines the file extension of the file being loaded
  116239. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116240. * @param fallback defines the fallback internal texture if any
  116241. * @param isBase64 defines whether the texture is encoded as a base64
  116242. * @param isBuffer defines whether the texture data are stored as a buffer
  116243. * @returns true if the loader can load the specified file
  116244. */
  116245. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116246. /**
  116247. * Transform the url before loading if required.
  116248. * @param rootUrl the url of the texture
  116249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116250. * @returns the transformed texture
  116251. */
  116252. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116253. /**
  116254. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116255. * @param rootUrl the url of the texture
  116256. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116257. * @returns the fallback texture
  116258. */
  116259. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116260. /**
  116261. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  116262. * @param data contains the texture data
  116263. * @param texture defines the BabylonJS internal texture
  116264. * @param createPolynomials will be true if polynomials have been requested
  116265. * @param onLoad defines the callback to trigger once the texture is ready
  116266. * @param onError defines the callback to trigger in case of error
  116267. */
  116268. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116269. /**
  116270. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116271. * @param data contains the texture data
  116272. * @param texture defines the BabylonJS internal texture
  116273. * @param callback defines the method to call once ready to upload
  116274. */
  116275. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116276. }
  116277. }
  116278. declare module BABYLON {
  116279. /**
  116280. * 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.
  116281. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  116282. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  116283. */
  116284. export class CustomProceduralTexture extends ProceduralTexture {
  116285. private _animate;
  116286. private _time;
  116287. private _config;
  116288. private _texturePath;
  116289. /**
  116290. * Instantiates a new Custom Procedural Texture.
  116291. * 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.
  116292. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  116293. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  116294. * @param name Define the name of the texture
  116295. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  116296. * @param size Define the size of the texture to create
  116297. * @param scene Define the scene the texture belongs to
  116298. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  116299. * @param generateMipMaps Define if the texture should creates mip maps or not
  116300. */
  116301. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  116302. private _loadJson;
  116303. /**
  116304. * Is the texture ready to be used ? (rendered at least once)
  116305. * @returns true if ready, otherwise, false.
  116306. */
  116307. isReady(): boolean;
  116308. /**
  116309. * Render the texture to its associated render target.
  116310. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  116311. */
  116312. render(useCameraPostProcess?: boolean): void;
  116313. /**
  116314. * Update the list of dependant textures samplers in the shader.
  116315. */
  116316. updateTextures(): void;
  116317. /**
  116318. * Update the uniform values of the procedural texture in the shader.
  116319. */
  116320. updateShaderUniforms(): void;
  116321. /**
  116322. * Define if the texture animates or not.
  116323. */
  116324. animate: boolean;
  116325. }
  116326. }
  116327. declare module BABYLON {
  116328. /** @hidden */
  116329. export var noisePixelShader: {
  116330. name: string;
  116331. shader: string;
  116332. };
  116333. }
  116334. declare module BABYLON {
  116335. /**
  116336. * Class used to generate noise procedural textures
  116337. */
  116338. export class NoiseProceduralTexture extends ProceduralTexture {
  116339. private _time;
  116340. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  116341. brightness: number;
  116342. /** Defines the number of octaves to process */
  116343. octaves: number;
  116344. /** Defines the level of persistence (0.8 by default) */
  116345. persistence: number;
  116346. /** Gets or sets animation speed factor (default is 1) */
  116347. animationSpeedFactor: number;
  116348. /**
  116349. * Creates a new NoiseProceduralTexture
  116350. * @param name defines the name fo the texture
  116351. * @param size defines the size of the texture (default is 256)
  116352. * @param scene defines the hosting scene
  116353. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  116354. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  116355. */
  116356. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  116357. private _updateShaderUniforms;
  116358. protected _getDefines(): string;
  116359. /** Generate the current state of the procedural texture */
  116360. render(useCameraPostProcess?: boolean): void;
  116361. /**
  116362. * Serializes this noise procedural texture
  116363. * @returns a serialized noise procedural texture object
  116364. */
  116365. serialize(): any;
  116366. /**
  116367. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  116368. * @param parsedTexture defines parsed texture data
  116369. * @param scene defines the current scene
  116370. * @param rootUrl defines the root URL containing noise procedural texture information
  116371. * @returns a parsed NoiseProceduralTexture
  116372. */
  116373. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  116374. }
  116375. }
  116376. declare module BABYLON {
  116377. /**
  116378. * Raw cube texture where the raw buffers are passed in
  116379. */
  116380. export class RawCubeTexture extends CubeTexture {
  116381. /**
  116382. * Creates a cube texture where the raw buffers are passed in.
  116383. * @param scene defines the scene the texture is attached to
  116384. * @param data defines the array of data to use to create each face
  116385. * @param size defines the size of the textures
  116386. * @param format defines the format of the data
  116387. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  116388. * @param generateMipMaps defines if the engine should generate the mip levels
  116389. * @param invertY defines if data must be stored with Y axis inverted
  116390. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  116391. * @param compression defines the compression used (null by default)
  116392. */
  116393. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  116394. /**
  116395. * Updates the raw cube texture.
  116396. * @param data defines the data to store
  116397. * @param format defines the data format
  116398. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  116399. * @param invertY defines if data must be stored with Y axis inverted
  116400. * @param compression defines the compression used (null by default)
  116401. * @param level defines which level of the texture to update
  116402. */
  116403. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  116404. /**
  116405. * Updates a raw cube texture with RGBD encoded data.
  116406. * @param data defines the array of data [mipmap][face] to use to create each face
  116407. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  116408. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  116409. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  116410. * @returns a promsie that resolves when the operation is complete
  116411. */
  116412. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  116413. /**
  116414. * Clones the raw cube texture.
  116415. * @return a new cube texture
  116416. */
  116417. clone(): CubeTexture;
  116418. /** @hidden */
  116419. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  116420. }
  116421. }
  116422. declare module BABYLON {
  116423. /**
  116424. * Class used to store 3D textures containing user data
  116425. */
  116426. export class RawTexture3D extends Texture {
  116427. /** Gets or sets the texture format to use */
  116428. format: number;
  116429. private _engine;
  116430. /**
  116431. * Create a new RawTexture3D
  116432. * @param data defines the data of the texture
  116433. * @param width defines the width of the texture
  116434. * @param height defines the height of the texture
  116435. * @param depth defines the depth of the texture
  116436. * @param format defines the texture format to use
  116437. * @param scene defines the hosting scene
  116438. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  116439. * @param invertY defines if texture must be stored with Y axis inverted
  116440. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  116441. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  116442. */
  116443. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  116444. /** Gets or sets the texture format to use */
  116445. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  116446. /**
  116447. * Update the texture with new data
  116448. * @param data defines the data to store in the texture
  116449. */
  116450. update(data: ArrayBufferView): void;
  116451. }
  116452. }
  116453. declare module BABYLON {
  116454. /**
  116455. * Creates a refraction texture used by refraction channel of the standard material.
  116456. * It is like a mirror but to see through a material.
  116457. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116458. */
  116459. export class RefractionTexture extends RenderTargetTexture {
  116460. /**
  116461. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  116462. * 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.
  116463. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116464. */
  116465. refractionPlane: Plane;
  116466. /**
  116467. * Define how deep under the surface we should see.
  116468. */
  116469. depth: number;
  116470. /**
  116471. * Creates a refraction texture used by refraction channel of the standard material.
  116472. * It is like a mirror but to see through a material.
  116473. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116474. * @param name Define the texture name
  116475. * @param size Define the size of the underlying texture
  116476. * @param scene Define the scene the refraction belongs to
  116477. * @param generateMipMaps Define if we need to generate mips level for the refraction
  116478. */
  116479. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  116480. /**
  116481. * Clone the refraction texture.
  116482. * @returns the cloned texture
  116483. */
  116484. clone(): RefractionTexture;
  116485. /**
  116486. * Serialize the texture to a JSON representation you could use in Parse later on
  116487. * @returns the serialized JSON representation
  116488. */
  116489. serialize(): any;
  116490. }
  116491. }
  116492. declare module BABYLON {
  116493. /**
  116494. * Defines the options related to the creation of an HtmlElementTexture
  116495. */
  116496. export interface IHtmlElementTextureOptions {
  116497. /**
  116498. * Defines wether mip maps should be created or not.
  116499. */
  116500. generateMipMaps?: boolean;
  116501. /**
  116502. * Defines the sampling mode of the texture.
  116503. */
  116504. samplingMode?: number;
  116505. /**
  116506. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  116507. */
  116508. engine: Nullable<Engine>;
  116509. /**
  116510. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  116511. */
  116512. scene: Nullable<Scene>;
  116513. }
  116514. /**
  116515. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  116516. * To be as efficient as possible depending on your constraints nothing aside the first upload
  116517. * is automatically managed.
  116518. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  116519. * in your application.
  116520. *
  116521. * As the update is not automatic, you need to call them manually.
  116522. */
  116523. export class HtmlElementTexture extends BaseTexture {
  116524. /**
  116525. * The texture URL.
  116526. */
  116527. element: HTMLVideoElement | HTMLCanvasElement;
  116528. private static readonly DefaultOptions;
  116529. private _textureMatrix;
  116530. private _engine;
  116531. private _isVideo;
  116532. private _generateMipMaps;
  116533. private _samplingMode;
  116534. /**
  116535. * Instantiates a HtmlElementTexture from the following parameters.
  116536. *
  116537. * @param name Defines the name of the texture
  116538. * @param element Defines the video or canvas the texture is filled with
  116539. * @param options Defines the other none mandatory texture creation options
  116540. */
  116541. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  116542. private _createInternalTexture;
  116543. /**
  116544. * Returns the texture matrix used in most of the material.
  116545. */
  116546. getTextureMatrix(): Matrix;
  116547. /**
  116548. * Updates the content of the texture.
  116549. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  116550. */
  116551. update(invertY?: Nullable<boolean>): void;
  116552. }
  116553. }
  116554. declare module BABYLON {
  116555. /**
  116556. * Enum used to define the target of a block
  116557. */
  116558. export enum NodeMaterialBlockTargets {
  116559. /** Vertex shader */
  116560. Vertex = 1,
  116561. /** Fragment shader */
  116562. Fragment = 2,
  116563. /** Neutral */
  116564. Neutral = 4,
  116565. /** Vertex and Fragment */
  116566. VertexAndFragment = 3
  116567. }
  116568. }
  116569. declare module BABYLON {
  116570. /**
  116571. * Defines the kind of connection point for node based material
  116572. */
  116573. export enum NodeMaterialBlockConnectionPointTypes {
  116574. /** Float */
  116575. Float = 1,
  116576. /** Int */
  116577. Int = 2,
  116578. /** Vector2 */
  116579. Vector2 = 4,
  116580. /** Vector3 */
  116581. Vector3 = 8,
  116582. /** Vector4 */
  116583. Vector4 = 16,
  116584. /** Color3 */
  116585. Color3 = 32,
  116586. /** Color4 */
  116587. Color4 = 64,
  116588. /** Matrix */
  116589. Matrix = 128,
  116590. /** Detect type based on connection */
  116591. AutoDetect = 1024,
  116592. /** Output type that will be defined by input type */
  116593. BasedOnInput = 2048
  116594. }
  116595. }
  116596. declare module BABYLON {
  116597. /**
  116598. * Root class for all node material optimizers
  116599. */
  116600. export class NodeMaterialOptimizer {
  116601. /**
  116602. * Function used to optimize a NodeMaterial graph
  116603. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  116604. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  116605. */
  116606. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  116607. }
  116608. }
  116609. declare module BABYLON {
  116610. /**
  116611. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  116612. */
  116613. export class TransformBlock extends NodeMaterialBlock {
  116614. /**
  116615. * Defines the value to use to complement W value to transform it to a Vector4
  116616. */
  116617. complementW: number;
  116618. /**
  116619. * Defines the value to use to complement z value to transform it to a Vector4
  116620. */
  116621. complementZ: number;
  116622. /**
  116623. * Creates a new TransformBlock
  116624. * @param name defines the block name
  116625. */
  116626. constructor(name: string);
  116627. /**
  116628. * Gets the current class name
  116629. * @returns the class name
  116630. */
  116631. getClassName(): string;
  116632. /**
  116633. * Gets the vector input
  116634. */
  116635. readonly vector: NodeMaterialConnectionPoint;
  116636. /**
  116637. * Gets the output component
  116638. */
  116639. readonly output: NodeMaterialConnectionPoint;
  116640. /**
  116641. * Gets the matrix transform input
  116642. */
  116643. readonly transform: NodeMaterialConnectionPoint;
  116644. protected _buildBlock(state: NodeMaterialBuildState): this;
  116645. serialize(): any;
  116646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116647. protected _dumpPropertiesCode(): string;
  116648. }
  116649. }
  116650. declare module BABYLON {
  116651. /**
  116652. * Block used to output the vertex position
  116653. */
  116654. export class VertexOutputBlock extends NodeMaterialBlock {
  116655. /**
  116656. * Creates a new VertexOutputBlock
  116657. * @param name defines the block name
  116658. */
  116659. constructor(name: string);
  116660. /**
  116661. * Gets the current class name
  116662. * @returns the class name
  116663. */
  116664. getClassName(): string;
  116665. /**
  116666. * Gets the vector input component
  116667. */
  116668. readonly vector: NodeMaterialConnectionPoint;
  116669. protected _buildBlock(state: NodeMaterialBuildState): this;
  116670. }
  116671. }
  116672. declare module BABYLON {
  116673. /**
  116674. * Block used to output the final color
  116675. */
  116676. export class FragmentOutputBlock extends NodeMaterialBlock {
  116677. /**
  116678. * Create a new FragmentOutputBlock
  116679. * @param name defines the block name
  116680. */
  116681. constructor(name: string);
  116682. /**
  116683. * Gets the current class name
  116684. * @returns the class name
  116685. */
  116686. getClassName(): string;
  116687. /**
  116688. * Gets the rgba input component
  116689. */
  116690. readonly rgba: NodeMaterialConnectionPoint;
  116691. /**
  116692. * Gets the rgb input component
  116693. */
  116694. readonly rgb: NodeMaterialConnectionPoint;
  116695. /**
  116696. * Gets the a input component
  116697. */
  116698. readonly a: NodeMaterialConnectionPoint;
  116699. protected _buildBlock(state: NodeMaterialBuildState): this;
  116700. }
  116701. }
  116702. declare module BABYLON {
  116703. /**
  116704. * Enum used to define well known values e.g. values automatically provided by the system
  116705. */
  116706. export enum NodeMaterialWellKnownValues {
  116707. /** World */
  116708. World = 1,
  116709. /** View */
  116710. View = 2,
  116711. /** Projection */
  116712. Projection = 3,
  116713. /** ViewProjection */
  116714. ViewProjection = 4,
  116715. /** WorldView */
  116716. WorldView = 5,
  116717. /** WorldViewProjection */
  116718. WorldViewProjection = 6,
  116719. /** CameraPosition */
  116720. CameraPosition = 7,
  116721. /** Fog Color */
  116722. FogColor = 8
  116723. }
  116724. }
  116725. declare module BABYLON {
  116726. /**
  116727. * Block used to read a reflection texture from a sampler
  116728. */
  116729. export class ReflectionTextureBlock extends NodeMaterialBlock {
  116730. private _define3DName;
  116731. private _defineCubicName;
  116732. private _defineExplicitName;
  116733. private _defineProjectionName;
  116734. private _defineLocalCubicName;
  116735. private _defineSphericalName;
  116736. private _definePlanarName;
  116737. private _defineEquirectangularName;
  116738. private _defineMirroredEquirectangularFixedName;
  116739. private _defineEquirectangularFixedName;
  116740. private _defineSkyboxName;
  116741. private _cubeSamplerName;
  116742. private _2DSamplerName;
  116743. private _positionUVWName;
  116744. private _directionWName;
  116745. private _reflectionCoordsName;
  116746. private _reflection2DCoordsName;
  116747. private _reflectionColorName;
  116748. private _reflectionMatrixName;
  116749. /**
  116750. * Gets or sets the texture associated with the node
  116751. */
  116752. texture: Nullable<BaseTexture>;
  116753. /**
  116754. * Create a new TextureBlock
  116755. * @param name defines the block name
  116756. */
  116757. constructor(name: string);
  116758. /**
  116759. * Gets the current class name
  116760. * @returns the class name
  116761. */
  116762. getClassName(): string;
  116763. /**
  116764. * Gets the world position input component
  116765. */
  116766. readonly position: NodeMaterialConnectionPoint;
  116767. /**
  116768. * Gets the world position input component
  116769. */
  116770. readonly worldPosition: NodeMaterialConnectionPoint;
  116771. /**
  116772. * Gets the world normal input component
  116773. */
  116774. readonly worldNormal: NodeMaterialConnectionPoint;
  116775. /**
  116776. * Gets the world input component
  116777. */
  116778. readonly world: NodeMaterialConnectionPoint;
  116779. /**
  116780. * Gets the camera (or eye) position component
  116781. */
  116782. readonly cameraPosition: NodeMaterialConnectionPoint;
  116783. /**
  116784. * Gets the view input component
  116785. */
  116786. readonly view: NodeMaterialConnectionPoint;
  116787. /**
  116788. * Gets the rgb output component
  116789. */
  116790. readonly rgb: NodeMaterialConnectionPoint;
  116791. /**
  116792. * Gets the r output component
  116793. */
  116794. readonly r: NodeMaterialConnectionPoint;
  116795. /**
  116796. * Gets the g output component
  116797. */
  116798. readonly g: NodeMaterialConnectionPoint;
  116799. /**
  116800. * Gets the b output component
  116801. */
  116802. readonly b: NodeMaterialConnectionPoint;
  116803. autoConfigure(): void;
  116804. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116805. isReady(): boolean;
  116806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116807. private _injectVertexCode;
  116808. private _writeOutput;
  116809. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116810. serialize(): any;
  116811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116812. }
  116813. }
  116814. declare module BABYLON {
  116815. /**
  116816. * Interface used to configure the node material editor
  116817. */
  116818. export interface INodeMaterialEditorOptions {
  116819. /** Define the URl to load node editor script */
  116820. editorURL?: string;
  116821. }
  116822. /** @hidden */
  116823. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  116824. /** BONES */
  116825. NUM_BONE_INFLUENCERS: number;
  116826. BonesPerMesh: number;
  116827. BONETEXTURE: boolean;
  116828. /** MORPH TARGETS */
  116829. MORPHTARGETS: boolean;
  116830. MORPHTARGETS_NORMAL: boolean;
  116831. MORPHTARGETS_TANGENT: boolean;
  116832. MORPHTARGETS_UV: boolean;
  116833. NUM_MORPH_INFLUENCERS: number;
  116834. /** IMAGE PROCESSING */
  116835. IMAGEPROCESSING: boolean;
  116836. VIGNETTE: boolean;
  116837. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116838. VIGNETTEBLENDMODEOPAQUE: boolean;
  116839. TONEMAPPING: boolean;
  116840. TONEMAPPING_ACES: boolean;
  116841. CONTRAST: boolean;
  116842. EXPOSURE: boolean;
  116843. COLORCURVES: boolean;
  116844. COLORGRADING: boolean;
  116845. COLORGRADING3D: boolean;
  116846. SAMPLER3DGREENDEPTH: boolean;
  116847. SAMPLER3DBGRMAP: boolean;
  116848. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116849. constructor();
  116850. setValue(name: string, value: boolean): void;
  116851. }
  116852. /**
  116853. * Class used to configure NodeMaterial
  116854. */
  116855. export interface INodeMaterialOptions {
  116856. /**
  116857. * Defines if blocks should emit comments
  116858. */
  116859. emitComments: boolean;
  116860. }
  116861. /**
  116862. * Class used to create a node based material built by assembling shader blocks
  116863. */
  116864. export class NodeMaterial extends PushMaterial {
  116865. private static _BuildIdGenerator;
  116866. private _options;
  116867. private _vertexCompilationState;
  116868. private _fragmentCompilationState;
  116869. private _sharedData;
  116870. private _buildId;
  116871. private _buildWasSuccessful;
  116872. private _cachedWorldViewMatrix;
  116873. private _cachedWorldViewProjectionMatrix;
  116874. private _optimizers;
  116875. private _animationFrame;
  116876. /** Define the URl to load node editor script */
  116877. static EditorURL: string;
  116878. private BJSNODEMATERIALEDITOR;
  116879. /** Get the inspector from bundle or global */
  116880. private _getGlobalNodeMaterialEditor;
  116881. /**
  116882. * 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)
  116883. */
  116884. ignoreAlpha: boolean;
  116885. /**
  116886. * Defines the maximum number of lights that can be used in the material
  116887. */
  116888. maxSimultaneousLights: number;
  116889. /**
  116890. * Observable raised when the material is built
  116891. */
  116892. onBuildObservable: Observable<NodeMaterial>;
  116893. /**
  116894. * Gets or sets the root nodes of the material vertex shader
  116895. */
  116896. _vertexOutputNodes: NodeMaterialBlock[];
  116897. /**
  116898. * Gets or sets the root nodes of the material fragment (pixel) shader
  116899. */
  116900. _fragmentOutputNodes: NodeMaterialBlock[];
  116901. /** Gets or sets options to control the node material overall behavior */
  116902. options: INodeMaterialOptions;
  116903. /**
  116904. * Default configuration related to image processing available in the standard Material.
  116905. */
  116906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116907. /**
  116908. * Gets the image processing configuration used either in this material.
  116909. */
  116910. /**
  116911. * Sets the Default image processing configuration used either in the this material.
  116912. *
  116913. * If sets to null, the scene one is in use.
  116914. */
  116915. imageProcessingConfiguration: ImageProcessingConfiguration;
  116916. /**
  116917. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  116918. */
  116919. attachedBlocks: NodeMaterialBlock[];
  116920. /**
  116921. * Create a new node based material
  116922. * @param name defines the material name
  116923. * @param scene defines the hosting scene
  116924. * @param options defines creation option
  116925. */
  116926. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  116927. /**
  116928. * Gets the current class name of the material e.g. "NodeMaterial"
  116929. * @returns the class name
  116930. */
  116931. getClassName(): string;
  116932. /**
  116933. * Keep track of the image processing observer to allow dispose and replace.
  116934. */
  116935. private _imageProcessingObserver;
  116936. /**
  116937. * Attaches a new image processing configuration to the Standard Material.
  116938. * @param configuration
  116939. */
  116940. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116941. /**
  116942. * Get a block by its name
  116943. * @param name defines the name of the block to retrieve
  116944. * @returns the required block or null if not found
  116945. */
  116946. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  116947. /**
  116948. * Gets the list of input blocks attached to this material
  116949. * @returns an array of InputBlocks
  116950. */
  116951. getInputBlocks(): InputBlock[];
  116952. /**
  116953. * Adds a new optimizer to the list of optimizers
  116954. * @param optimizer defines the optimizers to add
  116955. * @returns the current material
  116956. */
  116957. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116958. /**
  116959. * Remove an optimizer from the list of optimizers
  116960. * @param optimizer defines the optimizers to remove
  116961. * @returns the current material
  116962. */
  116963. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116964. /**
  116965. * Add a new block to the list of output nodes
  116966. * @param node defines the node to add
  116967. * @returns the current material
  116968. */
  116969. addOutputNode(node: NodeMaterialBlock): this;
  116970. /**
  116971. * Remove a block from the list of root nodes
  116972. * @param node defines the node to remove
  116973. * @returns the current material
  116974. */
  116975. removeOutputNode(node: NodeMaterialBlock): this;
  116976. private _addVertexOutputNode;
  116977. private _removeVertexOutputNode;
  116978. private _addFragmentOutputNode;
  116979. private _removeFragmentOutputNode;
  116980. /**
  116981. * Specifies if the material will require alpha blending
  116982. * @returns a boolean specifying if alpha blending is needed
  116983. */
  116984. needAlphaBlending(): boolean;
  116985. /**
  116986. * Specifies if this material should be rendered in alpha test mode
  116987. * @returns a boolean specifying if an alpha test is needed.
  116988. */
  116989. needAlphaTesting(): boolean;
  116990. private _initializeBlock;
  116991. private _resetDualBlocks;
  116992. /**
  116993. * Build the material and generates the inner effect
  116994. * @param verbose defines if the build should log activity
  116995. */
  116996. build(verbose?: boolean): void;
  116997. /**
  116998. * Runs an otpimization phase to try to improve the shader code
  116999. */
  117000. optimize(): void;
  117001. private _prepareDefinesForAttributes;
  117002. /**
  117003. * Get if the submesh is ready to be used and all its information available.
  117004. * Child classes can use it to update shaders
  117005. * @param mesh defines the mesh to check
  117006. * @param subMesh defines which submesh to check
  117007. * @param useInstances specifies that instances should be used
  117008. * @returns a boolean indicating that the submesh is ready or not
  117009. */
  117010. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117011. /**
  117012. * Get a string representing the shaders built by the current node graph
  117013. */
  117014. readonly compiledShaders: string;
  117015. /**
  117016. * Binds the world matrix to the material
  117017. * @param world defines the world transformation matrix
  117018. */
  117019. bindOnlyWorldMatrix(world: Matrix): void;
  117020. /**
  117021. * Binds the submesh to this material by preparing the effect and shader to draw
  117022. * @param world defines the world transformation matrix
  117023. * @param mesh defines the mesh containing the submesh
  117024. * @param subMesh defines the submesh to bind the material to
  117025. */
  117026. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117027. /**
  117028. * Gets the active textures from the material
  117029. * @returns an array of textures
  117030. */
  117031. getActiveTextures(): BaseTexture[];
  117032. /**
  117033. * Gets the list of texture blocks
  117034. * @returns an array of texture blocks
  117035. */
  117036. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  117037. /**
  117038. * Specifies if the material uses a texture
  117039. * @param texture defines the texture to check against the material
  117040. * @returns a boolean specifying if the material uses the texture
  117041. */
  117042. hasTexture(texture: BaseTexture): boolean;
  117043. /**
  117044. * Disposes the material
  117045. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  117046. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  117047. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  117048. */
  117049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  117050. /** Creates the node editor window. */
  117051. private _createNodeEditor;
  117052. /**
  117053. * Launch the node material editor
  117054. * @param config Define the configuration of the editor
  117055. * @return a promise fulfilled when the node editor is visible
  117056. */
  117057. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  117058. /**
  117059. * Clear the current material
  117060. */
  117061. clear(): void;
  117062. /**
  117063. * Clear the current material and set it to a default state
  117064. */
  117065. setToDefault(): void;
  117066. /**
  117067. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  117068. * @param url defines the url to load from
  117069. * @returns a promise that will fullfil when the material is fully loaded
  117070. */
  117071. loadAsync(url: string): Promise<unknown>;
  117072. private _gatherBlocks;
  117073. /**
  117074. * Generate a string containing the code declaration required to create an equivalent of this material
  117075. * @returns a string
  117076. */
  117077. generateCode(): string;
  117078. /**
  117079. * Serializes this material in a JSON representation
  117080. * @returns the serialized material object
  117081. */
  117082. serialize(): any;
  117083. private _restoreConnections;
  117084. /**
  117085. * Clear the current graph and load a new one from a serialization object
  117086. * @param source defines the JSON representation of the material
  117087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117088. */
  117089. loadFromSerialization(source: any, rootUrl?: string): void;
  117090. /**
  117091. * Creates a node material from parsed material data
  117092. * @param source defines the JSON representation of the material
  117093. * @param scene defines the hosting scene
  117094. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117095. * @returns a new node material
  117096. */
  117097. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  117098. /**
  117099. * Creates a new node material set to default basic configuration
  117100. * @param name defines the name of the material
  117101. * @param scene defines the hosting scene
  117102. * @returns a new NodeMaterial
  117103. */
  117104. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  117105. }
  117106. }
  117107. declare module BABYLON {
  117108. /**
  117109. * Block used to read a texture from a sampler
  117110. */
  117111. export class TextureBlock extends NodeMaterialBlock {
  117112. private _defineName;
  117113. private _samplerName;
  117114. private _transformedUVName;
  117115. private _textureTransformName;
  117116. private _textureInfoName;
  117117. private _mainUVName;
  117118. private _mainUVDefineName;
  117119. /**
  117120. * Gets or sets the texture associated with the node
  117121. */
  117122. texture: Nullable<BaseTexture>;
  117123. /**
  117124. * Create a new TextureBlock
  117125. * @param name defines the block name
  117126. */
  117127. constructor(name: string);
  117128. /**
  117129. * Gets the current class name
  117130. * @returns the class name
  117131. */
  117132. getClassName(): string;
  117133. /**
  117134. * Gets the uv input component
  117135. */
  117136. readonly uv: NodeMaterialConnectionPoint;
  117137. /**
  117138. * Gets the rgba output component
  117139. */
  117140. readonly rgba: NodeMaterialConnectionPoint;
  117141. /**
  117142. * Gets the rgb output component
  117143. */
  117144. readonly rgb: NodeMaterialConnectionPoint;
  117145. /**
  117146. * Gets the r output component
  117147. */
  117148. readonly r: NodeMaterialConnectionPoint;
  117149. /**
  117150. * Gets the g output component
  117151. */
  117152. readonly g: NodeMaterialConnectionPoint;
  117153. /**
  117154. * Gets the b output component
  117155. */
  117156. readonly b: NodeMaterialConnectionPoint;
  117157. /**
  117158. * Gets the a output component
  117159. */
  117160. readonly a: NodeMaterialConnectionPoint;
  117161. readonly target: NodeMaterialBlockTargets;
  117162. autoConfigure(): void;
  117163. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117165. isReady(): boolean;
  117166. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117167. private readonly _isMixed;
  117168. private _injectVertexCode;
  117169. private _writeOutput;
  117170. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117171. protected _dumpPropertiesCode(): string;
  117172. serialize(): any;
  117173. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117174. }
  117175. }
  117176. declare module BABYLON {
  117177. /**
  117178. * Class used to store shared data between 2 NodeMaterialBuildState
  117179. */
  117180. export class NodeMaterialBuildStateSharedData {
  117181. /**
  117182. * Gets the list of emitted varyings
  117183. */
  117184. temps: string[];
  117185. /**
  117186. * Gets the list of emitted varyings
  117187. */
  117188. varyings: string[];
  117189. /**
  117190. * Gets the varying declaration string
  117191. */
  117192. varyingDeclaration: string;
  117193. /**
  117194. * Input blocks
  117195. */
  117196. inputBlocks: InputBlock[];
  117197. /**
  117198. * Input blocks
  117199. */
  117200. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  117201. /**
  117202. * Bindable blocks (Blocks that need to set data to the effect)
  117203. */
  117204. bindableBlocks: NodeMaterialBlock[];
  117205. /**
  117206. * List of blocks that can provide a compilation fallback
  117207. */
  117208. blocksWithFallbacks: NodeMaterialBlock[];
  117209. /**
  117210. * List of blocks that can provide a define update
  117211. */
  117212. blocksWithDefines: NodeMaterialBlock[];
  117213. /**
  117214. * List of blocks that can provide a repeatable content
  117215. */
  117216. repeatableContentBlocks: NodeMaterialBlock[];
  117217. /**
  117218. * List of blocks that can provide a dynamic list of uniforms
  117219. */
  117220. dynamicUniformBlocks: NodeMaterialBlock[];
  117221. /**
  117222. * List of blocks that can block the isReady function for the material
  117223. */
  117224. blockingBlocks: NodeMaterialBlock[];
  117225. /**
  117226. * Gets the list of animated inputs
  117227. */
  117228. animatedInputs: InputBlock[];
  117229. /**
  117230. * Build Id used to avoid multiple recompilations
  117231. */
  117232. buildId: number;
  117233. /** List of emitted variables */
  117234. variableNames: {
  117235. [key: string]: number;
  117236. };
  117237. /** List of emitted defines */
  117238. defineNames: {
  117239. [key: string]: number;
  117240. };
  117241. /** Should emit comments? */
  117242. emitComments: boolean;
  117243. /** Emit build activity */
  117244. verbose: boolean;
  117245. /**
  117246. * Gets the compilation hints emitted at compilation time
  117247. */
  117248. hints: {
  117249. needWorldViewMatrix: boolean;
  117250. needWorldViewProjectionMatrix: boolean;
  117251. needAlphaBlending: boolean;
  117252. needAlphaTesting: boolean;
  117253. };
  117254. /**
  117255. * List of compilation checks
  117256. */
  117257. checks: {
  117258. emitVertex: boolean;
  117259. emitFragment: boolean;
  117260. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  117261. };
  117262. /** Creates a new shared data */
  117263. constructor();
  117264. /**
  117265. * Emits console errors and exceptions if there is a failing check
  117266. */
  117267. emitErrors(): void;
  117268. }
  117269. }
  117270. declare module BABYLON {
  117271. /**
  117272. * Class used to store node based material build state
  117273. */
  117274. export class NodeMaterialBuildState {
  117275. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  117276. supportUniformBuffers: boolean;
  117277. /**
  117278. * Gets the list of emitted attributes
  117279. */
  117280. attributes: string[];
  117281. /**
  117282. * Gets the list of emitted uniforms
  117283. */
  117284. uniforms: string[];
  117285. /**
  117286. * Gets the list of emitted uniform buffers
  117287. */
  117288. uniformBuffers: string[];
  117289. /**
  117290. * Gets the list of emitted samplers
  117291. */
  117292. samplers: string[];
  117293. /**
  117294. * Gets the list of emitted functions
  117295. */
  117296. functions: {
  117297. [key: string]: string;
  117298. };
  117299. /**
  117300. * Gets the target of the compilation state
  117301. */
  117302. target: NodeMaterialBlockTargets;
  117303. /**
  117304. * Gets the list of emitted counters
  117305. */
  117306. counters: {
  117307. [key: string]: number;
  117308. };
  117309. /**
  117310. * Shared data between multiple NodeMaterialBuildState instances
  117311. */
  117312. sharedData: NodeMaterialBuildStateSharedData;
  117313. /** @hidden */
  117314. _vertexState: NodeMaterialBuildState;
  117315. /** @hidden */
  117316. _attributeDeclaration: string;
  117317. /** @hidden */
  117318. _uniformDeclaration: string;
  117319. /** @hidden */
  117320. _samplerDeclaration: string;
  117321. /** @hidden */
  117322. _varyingTransfer: string;
  117323. private _repeatableContentAnchorIndex;
  117324. /** @hidden */
  117325. _builtCompilationString: string;
  117326. /**
  117327. * Gets the emitted compilation strings
  117328. */
  117329. compilationString: string;
  117330. /**
  117331. * Finalize the compilation strings
  117332. * @param state defines the current compilation state
  117333. */
  117334. finalize(state: NodeMaterialBuildState): void;
  117335. /** @hidden */
  117336. readonly _repeatableContentAnchor: string;
  117337. /** @hidden */
  117338. _getFreeVariableName(prefix: string): string;
  117339. /** @hidden */
  117340. _getFreeDefineName(prefix: string): string;
  117341. /** @hidden */
  117342. _excludeVariableName(name: string): void;
  117343. /** @hidden */
  117344. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  117345. /** @hidden */
  117346. _emitFunction(name: string, code: string, comments: string): void;
  117347. /** @hidden */
  117348. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  117349. replaceStrings?: {
  117350. search: RegExp;
  117351. replace: string;
  117352. }[];
  117353. repeatKey?: string;
  117354. }): string;
  117355. /** @hidden */
  117356. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  117357. repeatKey?: string;
  117358. removeAttributes?: boolean;
  117359. removeUniforms?: boolean;
  117360. removeVaryings?: boolean;
  117361. removeIfDef?: boolean;
  117362. replaceStrings?: {
  117363. search: RegExp;
  117364. replace: string;
  117365. }[];
  117366. }, storeKey?: string): void;
  117367. /** @hidden */
  117368. _registerTempVariable(name: string): boolean;
  117369. /** @hidden */
  117370. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  117371. /** @hidden */
  117372. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  117373. }
  117374. }
  117375. declare module BABYLON {
  117376. /**
  117377. * Defines a block that can be used inside a node based material
  117378. */
  117379. export class NodeMaterialBlock {
  117380. private _buildId;
  117381. private _buildTarget;
  117382. private _target;
  117383. private _isFinalMerger;
  117384. private _isInput;
  117385. /** @hidden */
  117386. _codeVariableName: string;
  117387. /** @hidden */
  117388. _inputs: NodeMaterialConnectionPoint[];
  117389. /** @hidden */
  117390. _outputs: NodeMaterialConnectionPoint[];
  117391. /**
  117392. * Gets or sets the name of the block
  117393. */
  117394. name: string;
  117395. /**
  117396. * Gets or sets the unique id of the node
  117397. */
  117398. uniqueId: number;
  117399. /**
  117400. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  117401. */
  117402. readonly isFinalMerger: boolean;
  117403. /**
  117404. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  117405. */
  117406. readonly isInput: boolean;
  117407. /**
  117408. * Gets or sets the build Id
  117409. */
  117410. buildId: number;
  117411. /**
  117412. * Gets or sets the target of the block
  117413. */
  117414. target: NodeMaterialBlockTargets;
  117415. /**
  117416. * Gets the list of input points
  117417. */
  117418. readonly inputs: NodeMaterialConnectionPoint[];
  117419. /** Gets the list of output points */
  117420. readonly outputs: NodeMaterialConnectionPoint[];
  117421. /**
  117422. * Find an input by its name
  117423. * @param name defines the name of the input to look for
  117424. * @returns the input or null if not found
  117425. */
  117426. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117427. /**
  117428. * Find an output by its name
  117429. * @param name defines the name of the outputto look for
  117430. * @returns the output or null if not found
  117431. */
  117432. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117433. /**
  117434. * Creates a new NodeMaterialBlock
  117435. * @param name defines the block name
  117436. * @param target defines the target of that block (Vertex by default)
  117437. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  117438. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  117439. */
  117440. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  117441. /**
  117442. * Initialize the block and prepare the context for build
  117443. * @param state defines the state that will be used for the build
  117444. */
  117445. initialize(state: NodeMaterialBuildState): void;
  117446. /**
  117447. * Bind data to effect. Will only be called for blocks with isBindable === true
  117448. * @param effect defines the effect to bind data to
  117449. * @param nodeMaterial defines the hosting NodeMaterial
  117450. * @param mesh defines the mesh that will be rendered
  117451. */
  117452. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117453. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  117454. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  117455. protected _writeFloat(value: number): string;
  117456. /**
  117457. * Gets the current class name e.g. "NodeMaterialBlock"
  117458. * @returns the class name
  117459. */
  117460. getClassName(): string;
  117461. /**
  117462. * Register a new input. Must be called inside a block constructor
  117463. * @param name defines the connection point name
  117464. * @param type defines the connection point type
  117465. * @param isOptional defines a boolean indicating that this input can be omitted
  117466. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  117467. * @returns the current block
  117468. */
  117469. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  117470. /**
  117471. * Register a new output. Must be called inside a block constructor
  117472. * @param name defines the connection point name
  117473. * @param type defines the connection point type
  117474. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  117475. * @returns the current block
  117476. */
  117477. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  117478. /**
  117479. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  117480. * @param forOutput defines an optional connection point to check compatibility with
  117481. * @returns the first available input or null
  117482. */
  117483. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  117484. /**
  117485. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  117486. * @param forBlock defines an optional block to check compatibility with
  117487. * @returns the first available input or null
  117488. */
  117489. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  117490. /**
  117491. * Gets the sibling of the given output
  117492. * @param current defines the current output
  117493. * @returns the next output in the list or null
  117494. */
  117495. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  117496. /**
  117497. * Connect current block with another block
  117498. * @param other defines the block to connect with
  117499. * @param options define the various options to help pick the right connections
  117500. * @returns the current block
  117501. */
  117502. connectTo(other: NodeMaterialBlock, options?: {
  117503. input?: string;
  117504. output?: string;
  117505. outputSwizzle?: string;
  117506. }): this | undefined;
  117507. protected _buildBlock(state: NodeMaterialBuildState): void;
  117508. /**
  117509. * Add uniforms, samplers and uniform buffers at compilation time
  117510. * @param state defines the state to update
  117511. * @param nodeMaterial defines the node material requesting the update
  117512. * @param defines defines the material defines to update
  117513. */
  117514. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117515. /**
  117516. * Add potential fallbacks if shader compilation fails
  117517. * @param mesh defines the mesh to be rendered
  117518. * @param fallbacks defines the current prioritized list of fallbacks
  117519. */
  117520. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117521. /**
  117522. * Update defines for shader compilation
  117523. * @param mesh defines the mesh to be rendered
  117524. * @param nodeMaterial defines the node material requesting the update
  117525. * @param defines defines the material defines to update
  117526. * @param useInstances specifies that instances should be used
  117527. */
  117528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117529. /**
  117530. * Initialize defines for shader compilation
  117531. * @param mesh defines the mesh to be rendered
  117532. * @param nodeMaterial defines the node material requesting the update
  117533. * @param defines defines the material defines to be prepared
  117534. * @param useInstances specifies that instances should be used
  117535. */
  117536. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117537. /**
  117538. * Lets the block try to connect some inputs automatically
  117539. * @param material defines the hosting NodeMaterial
  117540. */
  117541. autoConfigure(material: NodeMaterial): void;
  117542. /**
  117543. * Function called when a block is declared as repeatable content generator
  117544. * @param vertexShaderState defines the current compilation state for the vertex shader
  117545. * @param fragmentShaderState defines the current compilation state for the fragment shader
  117546. * @param mesh defines the mesh to be rendered
  117547. * @param defines defines the material defines to update
  117548. */
  117549. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117550. /**
  117551. * Checks if the block is ready
  117552. * @param mesh defines the mesh to be rendered
  117553. * @param nodeMaterial defines the node material requesting the update
  117554. * @param defines defines the material defines to update
  117555. * @param useInstances specifies that instances should be used
  117556. * @returns true if the block is ready
  117557. */
  117558. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  117559. private _processBuild;
  117560. /**
  117561. * Compile the current node and generate the shader code
  117562. * @param state defines the current compilation state (uniforms, samplers, current string)
  117563. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  117564. * @returns true if already built
  117565. */
  117566. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  117567. protected _inputRename(name: string): string;
  117568. protected _outputRename(name: string): string;
  117569. protected _dumpPropertiesCode(): string;
  117570. /** @hidden */
  117571. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  117572. /**
  117573. * Clone the current block to a new identical block
  117574. * @param scene defines the hosting scene
  117575. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117576. * @returns a copy of the current block
  117577. */
  117578. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  117579. /**
  117580. * Serializes this block in a JSON representation
  117581. * @returns the serialized block object
  117582. */
  117583. serialize(): any;
  117584. /** @hidden */
  117585. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117586. }
  117587. }
  117588. declare module BABYLON {
  117589. /**
  117590. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117591. */
  117592. export enum NodeMaterialBlockConnectionPointMode {
  117593. /** Value is an uniform */
  117594. Uniform = 0,
  117595. /** Value is a mesh attribute */
  117596. Attribute = 1,
  117597. /** Value is a varying between vertex and fragment shaders */
  117598. Varying = 2,
  117599. /** Mode is undefined */
  117600. Undefined = 3
  117601. }
  117602. }
  117603. declare module BABYLON {
  117604. /**
  117605. * Enum defining the type of animations supported by InputBlock
  117606. */
  117607. export enum AnimatedInputBlockTypes {
  117608. /** No animation */
  117609. None = 0,
  117610. /** Time based animation. Will only work for floats */
  117611. Time = 1
  117612. }
  117613. }
  117614. declare module BABYLON {
  117615. /**
  117616. * Block used to expose an input value
  117617. */
  117618. export class InputBlock extends NodeMaterialBlock {
  117619. private _mode;
  117620. private _associatedVariableName;
  117621. private _storedValue;
  117622. private _valueCallback;
  117623. private _type;
  117624. private _animationType;
  117625. /** @hidden */
  117626. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117627. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  117628. visibleInInspector: boolean;
  117629. /**
  117630. * Gets or sets the connection point type (default is float)
  117631. */
  117632. readonly type: NodeMaterialBlockConnectionPointTypes;
  117633. /**
  117634. * Creates a new InputBlock
  117635. * @param name defines the block name
  117636. * @param target defines the target of that block (Vertex by default)
  117637. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  117638. */
  117639. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  117640. /**
  117641. * Gets the output component
  117642. */
  117643. readonly output: NodeMaterialConnectionPoint;
  117644. /**
  117645. * Set the source of this connection point to a vertex attribute
  117646. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  117647. * @returns the current connection point
  117648. */
  117649. setAsAttribute(attributeName?: string): InputBlock;
  117650. /**
  117651. * Set the source of this connection point to a well known value
  117652. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  117653. * @returns the current connection point
  117654. */
  117655. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  117656. /**
  117657. * Gets or sets the value of that point.
  117658. * Please note that this value will be ignored if valueCallback is defined
  117659. */
  117660. value: any;
  117661. /**
  117662. * Gets or sets a callback used to get the value of that point.
  117663. * Please note that setting this value will force the connection point to ignore the value property
  117664. */
  117665. valueCallback: () => any;
  117666. /**
  117667. * Gets or sets the associated variable name in the shader
  117668. */
  117669. associatedVariableName: string;
  117670. /** Gets or sets the type of animation applied to the input */
  117671. animationType: AnimatedInputBlockTypes;
  117672. /**
  117673. * Gets a boolean indicating that this connection point not defined yet
  117674. */
  117675. readonly isUndefined: boolean;
  117676. /**
  117677. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  117678. * In this case the connection point name must be the name of the uniform to use.
  117679. * Can only be set on inputs
  117680. */
  117681. isUniform: boolean;
  117682. /**
  117683. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  117684. * In this case the connection point name must be the name of the attribute to use
  117685. * Can only be set on inputs
  117686. */
  117687. isAttribute: boolean;
  117688. /**
  117689. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  117690. * Can only be set on exit points
  117691. */
  117692. isVarying: boolean;
  117693. /**
  117694. * Gets a boolean indicating that the current connection point is a well known value
  117695. */
  117696. readonly isWellKnownValue: boolean;
  117697. /**
  117698. * Gets or sets the current well known value or null if not defined as well know value
  117699. */
  117700. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117701. /**
  117702. * Gets the current class name
  117703. * @returns the class name
  117704. */
  117705. getClassName(): string;
  117706. /**
  117707. * Animate the input if animationType !== None
  117708. * @param scene defines the rendering scene
  117709. */
  117710. animate(scene: Scene): void;
  117711. private _emitDefine;
  117712. /**
  117713. * Set the input block to its default value (based on its type)
  117714. */
  117715. setDefaultValue(): void;
  117716. protected _dumpPropertiesCode(): string;
  117717. private _emit;
  117718. /** @hidden */
  117719. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  117720. /** @hidden */
  117721. _transmit(effect: Effect, scene: Scene): void;
  117722. protected _buildBlock(state: NodeMaterialBuildState): void;
  117723. serialize(): any;
  117724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117725. }
  117726. }
  117727. declare module BABYLON {
  117728. /**
  117729. * Defines a connection point for a block
  117730. */
  117731. export class NodeMaterialConnectionPoint {
  117732. /** @hidden */
  117733. _ownerBlock: NodeMaterialBlock;
  117734. /** @hidden */
  117735. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117736. private _endpoints;
  117737. private _associatedVariableName;
  117738. /** @hidden */
  117739. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117740. private _type;
  117741. /** @hidden */
  117742. _enforceAssociatedVariableName: boolean;
  117743. /**
  117744. * Gets or sets the additional types supported byt this connection point
  117745. */
  117746. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  117747. /**
  117748. * Gets or sets the associated variable name in the shader
  117749. */
  117750. associatedVariableName: string;
  117751. /**
  117752. * Gets or sets the connection point type (default is float)
  117753. */
  117754. type: NodeMaterialBlockConnectionPointTypes;
  117755. /**
  117756. * Gets or sets the connection point name
  117757. */
  117758. name: string;
  117759. /**
  117760. * Gets or sets a boolean indicating that this connection point can be omitted
  117761. */
  117762. isOptional: boolean;
  117763. /**
  117764. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  117765. */
  117766. define: string;
  117767. /** Gets or sets the target of that connection point */
  117768. target: NodeMaterialBlockTargets;
  117769. /**
  117770. * Gets a boolean indicating that the current point is connected
  117771. */
  117772. readonly isConnected: boolean;
  117773. /**
  117774. * Gets a boolean indicating that the current point is connected to an input block
  117775. */
  117776. readonly isConnectedToInputBlock: boolean;
  117777. /**
  117778. * Gets a the connected input block (if any)
  117779. */
  117780. readonly connectInputBlock: Nullable<InputBlock>;
  117781. /** Get the other side of the connection (if any) */
  117782. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117783. /** Get the block that owns this connection point */
  117784. readonly ownerBlock: NodeMaterialBlock;
  117785. /** Get the block connected on the other side of this connection (if any) */
  117786. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  117787. /** Get the block connected on the endpoints of this connection (if any) */
  117788. readonly connectedBlocks: Array<NodeMaterialBlock>;
  117789. /** Gets the list of connected endpoints */
  117790. readonly endpoints: NodeMaterialConnectionPoint[];
  117791. /** Gets a boolean indicating if that output point is connected to at least one input */
  117792. readonly hasEndpoints: boolean;
  117793. /**
  117794. * Creates a new connection point
  117795. * @param name defines the connection point name
  117796. * @param ownerBlock defines the block hosting this connection point
  117797. */
  117798. constructor(name: string, ownerBlock: NodeMaterialBlock);
  117799. /**
  117800. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  117801. * @returns the class name
  117802. */
  117803. getClassName(): string;
  117804. /**
  117805. * Gets an boolean indicating if the current point can be connected to another point
  117806. * @param connectionPoint defines the other connection point
  117807. * @returns true if the connection is possible
  117808. */
  117809. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  117810. /**
  117811. * Connect this point to another connection point
  117812. * @param connectionPoint defines the other connection point
  117813. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  117814. * @returns the current connection point
  117815. */
  117816. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  117817. /**
  117818. * Disconnect this point from one of his endpoint
  117819. * @param endpoint defines the other connection point
  117820. * @returns the current connection point
  117821. */
  117822. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117823. /**
  117824. * Serializes this point in a JSON representation
  117825. * @returns the serialized point object
  117826. */
  117827. serialize(): any;
  117828. }
  117829. }
  117830. declare module BABYLON {
  117831. /**
  117832. * Block used to add support for vertex skinning (bones)
  117833. */
  117834. export class BonesBlock extends NodeMaterialBlock {
  117835. /**
  117836. * Creates a new BonesBlock
  117837. * @param name defines the block name
  117838. */
  117839. constructor(name: string);
  117840. /**
  117841. * Initialize the block and prepare the context for build
  117842. * @param state defines the state that will be used for the build
  117843. */
  117844. initialize(state: NodeMaterialBuildState): void;
  117845. /**
  117846. * Gets the current class name
  117847. * @returns the class name
  117848. */
  117849. getClassName(): string;
  117850. /**
  117851. * Gets the matrix indices input component
  117852. */
  117853. readonly matricesIndices: NodeMaterialConnectionPoint;
  117854. /**
  117855. * Gets the matrix weights input component
  117856. */
  117857. readonly matricesWeights: NodeMaterialConnectionPoint;
  117858. /**
  117859. * Gets the extra matrix indices input component
  117860. */
  117861. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  117862. /**
  117863. * Gets the extra matrix weights input component
  117864. */
  117865. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  117866. /**
  117867. * Gets the world input component
  117868. */
  117869. readonly world: NodeMaterialConnectionPoint;
  117870. /**
  117871. * Gets the output component
  117872. */
  117873. readonly output: NodeMaterialConnectionPoint;
  117874. autoConfigure(): void;
  117875. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117876. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117878. protected _buildBlock(state: NodeMaterialBuildState): this;
  117879. }
  117880. }
  117881. declare module BABYLON {
  117882. /**
  117883. * Block used to add support for instances
  117884. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  117885. */
  117886. export class InstancesBlock extends NodeMaterialBlock {
  117887. /**
  117888. * Creates a new InstancesBlock
  117889. * @param name defines the block name
  117890. */
  117891. constructor(name: string);
  117892. /**
  117893. * Gets the current class name
  117894. * @returns the class name
  117895. */
  117896. getClassName(): string;
  117897. /**
  117898. * Gets the first world row input component
  117899. */
  117900. readonly world0: NodeMaterialConnectionPoint;
  117901. /**
  117902. * Gets the second world row input component
  117903. */
  117904. readonly world1: NodeMaterialConnectionPoint;
  117905. /**
  117906. * Gets the third world row input component
  117907. */
  117908. readonly world2: NodeMaterialConnectionPoint;
  117909. /**
  117910. * Gets the forth world row input component
  117911. */
  117912. readonly world3: NodeMaterialConnectionPoint;
  117913. /**
  117914. * Gets the world input component
  117915. */
  117916. readonly world: NodeMaterialConnectionPoint;
  117917. /**
  117918. * Gets the output component
  117919. */
  117920. readonly output: NodeMaterialConnectionPoint;
  117921. autoConfigure(): void;
  117922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117923. protected _buildBlock(state: NodeMaterialBuildState): this;
  117924. }
  117925. }
  117926. declare module BABYLON {
  117927. /**
  117928. * Block used to add morph targets support to vertex shader
  117929. */
  117930. export class MorphTargetsBlock extends NodeMaterialBlock {
  117931. private _repeatableContentAnchor;
  117932. private _repeatebleContentGenerated;
  117933. /**
  117934. * Create a new MorphTargetsBlock
  117935. * @param name defines the block name
  117936. */
  117937. constructor(name: string);
  117938. /**
  117939. * Gets the current class name
  117940. * @returns the class name
  117941. */
  117942. getClassName(): string;
  117943. /**
  117944. * Gets the position input component
  117945. */
  117946. readonly position: NodeMaterialConnectionPoint;
  117947. /**
  117948. * Gets the normal input component
  117949. */
  117950. readonly normal: NodeMaterialConnectionPoint;
  117951. /**
  117952. * Gets the tangent input component
  117953. */
  117954. readonly tangent: NodeMaterialConnectionPoint;
  117955. /**
  117956. * Gets the tangent input component
  117957. */
  117958. readonly uv: NodeMaterialConnectionPoint;
  117959. /**
  117960. * Gets the position output component
  117961. */
  117962. readonly positionOutput: NodeMaterialConnectionPoint;
  117963. /**
  117964. * Gets the normal output component
  117965. */
  117966. readonly normalOutput: NodeMaterialConnectionPoint;
  117967. /**
  117968. * Gets the tangent output component
  117969. */
  117970. readonly tangentOutput: NodeMaterialConnectionPoint;
  117971. /**
  117972. * Gets the tangent output component
  117973. */
  117974. readonly uvOutput: NodeMaterialConnectionPoint;
  117975. initialize(state: NodeMaterialBuildState): void;
  117976. autoConfigure(): void;
  117977. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117979. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117980. protected _buildBlock(state: NodeMaterialBuildState): this;
  117981. }
  117982. }
  117983. declare module BABYLON {
  117984. /**
  117985. * Block used to add an alpha test in the fragment shader
  117986. */
  117987. export class AlphaTestBlock extends NodeMaterialBlock {
  117988. /**
  117989. * Gets or sets the alpha value where alpha testing happens
  117990. */
  117991. alphaCutOff: number;
  117992. /**
  117993. * Create a new AlphaTestBlock
  117994. * @param name defines the block name
  117995. */
  117996. constructor(name: string);
  117997. /**
  117998. * Gets the current class name
  117999. * @returns the class name
  118000. */
  118001. getClassName(): string;
  118002. /**
  118003. * Gets the color input component
  118004. */
  118005. readonly color: NodeMaterialConnectionPoint;
  118006. /**
  118007. * Gets the alpha input component
  118008. */
  118009. readonly alpha: NodeMaterialConnectionPoint;
  118010. protected _buildBlock(state: NodeMaterialBuildState): this;
  118011. protected _dumpPropertiesCode(): string;
  118012. serialize(): any;
  118013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118014. }
  118015. }
  118016. declare module BABYLON {
  118017. /**
  118018. * Block used to compute fresnel value
  118019. */
  118020. export class FresnelBlock extends NodeMaterialBlock {
  118021. /**
  118022. * Create a new FresnelBlock
  118023. * @param name defines the block name
  118024. */
  118025. constructor(name: string);
  118026. /**
  118027. * Gets the current class name
  118028. * @returns the class name
  118029. */
  118030. getClassName(): string;
  118031. /**
  118032. * Gets the world position input component
  118033. */
  118034. readonly worldPosition: NodeMaterialConnectionPoint;
  118035. /**
  118036. * Gets the world normal input component
  118037. */
  118038. readonly worldNormal: NodeMaterialConnectionPoint;
  118039. /**
  118040. * Gets the camera (or eye) position component
  118041. */
  118042. readonly cameraPosition: NodeMaterialConnectionPoint;
  118043. /**
  118044. * Gets the bias input component
  118045. */
  118046. readonly bias: NodeMaterialConnectionPoint;
  118047. /**
  118048. * Gets the camera (or eye) position component
  118049. */
  118050. readonly power: NodeMaterialConnectionPoint;
  118051. /**
  118052. * Gets the fresnel output component
  118053. */
  118054. readonly fresnel: NodeMaterialConnectionPoint;
  118055. autoConfigure(material: NodeMaterial): void;
  118056. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118057. }
  118058. }
  118059. declare module BABYLON {
  118060. /**
  118061. * Block used to add image processing support to fragment shader
  118062. */
  118063. export class ImageProcessingBlock extends NodeMaterialBlock {
  118064. /**
  118065. * Create a new ImageProcessingBlock
  118066. * @param name defines the block name
  118067. */
  118068. constructor(name: string);
  118069. /**
  118070. * Gets the current class name
  118071. * @returns the class name
  118072. */
  118073. getClassName(): string;
  118074. /**
  118075. * Gets the color input component
  118076. */
  118077. readonly color: NodeMaterialConnectionPoint;
  118078. /**
  118079. * Gets the output component
  118080. */
  118081. readonly output: NodeMaterialConnectionPoint;
  118082. /**
  118083. * Initialize the block and prepare the context for build
  118084. * @param state defines the state that will be used for the build
  118085. */
  118086. initialize(state: NodeMaterialBuildState): void;
  118087. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  118088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118090. protected _buildBlock(state: NodeMaterialBuildState): this;
  118091. }
  118092. }
  118093. declare module BABYLON {
  118094. /**
  118095. * Block used to add support for scene fog
  118096. */
  118097. export class FogBlock extends NodeMaterialBlock {
  118098. private _fogDistanceName;
  118099. private _fogParameters;
  118100. /**
  118101. * Create a new FogBlock
  118102. * @param name defines the block name
  118103. */
  118104. constructor(name: string);
  118105. /**
  118106. * Gets the current class name
  118107. * @returns the class name
  118108. */
  118109. getClassName(): string;
  118110. /**
  118111. * Gets the world position input component
  118112. */
  118113. readonly worldPosition: NodeMaterialConnectionPoint;
  118114. /**
  118115. * Gets the view input component
  118116. */
  118117. readonly view: NodeMaterialConnectionPoint;
  118118. /**
  118119. * Gets the color input component
  118120. */
  118121. readonly input: NodeMaterialConnectionPoint;
  118122. /**
  118123. * Gets the fog color input component
  118124. */
  118125. readonly fogColor: NodeMaterialConnectionPoint;
  118126. /**
  118127. * Gets the output component
  118128. */
  118129. readonly output: NodeMaterialConnectionPoint;
  118130. autoConfigure(): void;
  118131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118132. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118133. protected _buildBlock(state: NodeMaterialBuildState): this;
  118134. }
  118135. }
  118136. declare module BABYLON {
  118137. /**
  118138. * Block used to add light in the fragment shader
  118139. */
  118140. export class LightBlock extends NodeMaterialBlock {
  118141. private _lightId;
  118142. /**
  118143. * Gets or sets the light associated with this block
  118144. */
  118145. light: Nullable<Light>;
  118146. /**
  118147. * Create a new LightBlock
  118148. * @param name defines the block name
  118149. */
  118150. constructor(name: string);
  118151. /**
  118152. * Gets the current class name
  118153. * @returns the class name
  118154. */
  118155. getClassName(): string;
  118156. /**
  118157. * Gets the world position input component
  118158. */
  118159. readonly worldPosition: NodeMaterialConnectionPoint;
  118160. /**
  118161. * Gets the world normal input component
  118162. */
  118163. readonly worldNormal: NodeMaterialConnectionPoint;
  118164. /**
  118165. * Gets the camera (or eye) position component
  118166. */
  118167. readonly cameraPosition: NodeMaterialConnectionPoint;
  118168. /**
  118169. * Gets the diffuse output component
  118170. */
  118171. readonly diffuseOutput: NodeMaterialConnectionPoint;
  118172. /**
  118173. * Gets the specular output component
  118174. */
  118175. readonly specularOutput: NodeMaterialConnectionPoint;
  118176. autoConfigure(): void;
  118177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118178. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118180. private _injectVertexCode;
  118181. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118182. serialize(): any;
  118183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118184. }
  118185. }
  118186. declare module BABYLON {
  118187. /**
  118188. * Block used to multiply 2 values
  118189. */
  118190. export class MultiplyBlock extends NodeMaterialBlock {
  118191. /**
  118192. * Creates a new MultiplyBlock
  118193. * @param name defines the block name
  118194. */
  118195. constructor(name: string);
  118196. /**
  118197. * Gets the current class name
  118198. * @returns the class name
  118199. */
  118200. getClassName(): string;
  118201. /**
  118202. * Gets the left operand input component
  118203. */
  118204. readonly left: NodeMaterialConnectionPoint;
  118205. /**
  118206. * Gets the right operand input component
  118207. */
  118208. readonly right: NodeMaterialConnectionPoint;
  118209. /**
  118210. * Gets the output component
  118211. */
  118212. readonly output: NodeMaterialConnectionPoint;
  118213. protected _buildBlock(state: NodeMaterialBuildState): this;
  118214. }
  118215. }
  118216. declare module BABYLON {
  118217. /**
  118218. * Block used to add 2 vectors
  118219. */
  118220. export class AddBlock extends NodeMaterialBlock {
  118221. /**
  118222. * Creates a new AddBlock
  118223. * @param name defines the block name
  118224. */
  118225. constructor(name: string);
  118226. /**
  118227. * Gets the current class name
  118228. * @returns the class name
  118229. */
  118230. getClassName(): string;
  118231. /**
  118232. * Gets the left operand input component
  118233. */
  118234. readonly left: NodeMaterialConnectionPoint;
  118235. /**
  118236. * Gets the right operand input component
  118237. */
  118238. readonly right: NodeMaterialConnectionPoint;
  118239. /**
  118240. * Gets the output component
  118241. */
  118242. readonly output: NodeMaterialConnectionPoint;
  118243. protected _buildBlock(state: NodeMaterialBuildState): this;
  118244. }
  118245. }
  118246. declare module BABYLON {
  118247. /**
  118248. * Block used to scale a vector by a float
  118249. */
  118250. export class ScaleBlock extends NodeMaterialBlock {
  118251. /**
  118252. * Creates a new ScaleBlock
  118253. * @param name defines the block name
  118254. */
  118255. constructor(name: string);
  118256. /**
  118257. * Gets the current class name
  118258. * @returns the class name
  118259. */
  118260. getClassName(): string;
  118261. /**
  118262. * Gets the input component
  118263. */
  118264. readonly input: NodeMaterialConnectionPoint;
  118265. /**
  118266. * Gets the factor input component
  118267. */
  118268. readonly factor: NodeMaterialConnectionPoint;
  118269. /**
  118270. * Gets the output component
  118271. */
  118272. readonly output: NodeMaterialConnectionPoint;
  118273. protected _buildBlock(state: NodeMaterialBuildState): this;
  118274. }
  118275. }
  118276. declare module BABYLON {
  118277. /**
  118278. * Block used to clamp a float
  118279. */
  118280. export class ClampBlock extends NodeMaterialBlock {
  118281. /** Gets or sets the minimum range */
  118282. minimum: number;
  118283. /** Gets or sets the maximum range */
  118284. maximum: number;
  118285. /**
  118286. * Creates a new ClampBlock
  118287. * @param name defines the block name
  118288. */
  118289. constructor(name: string);
  118290. /**
  118291. * Gets the current class name
  118292. * @returns the class name
  118293. */
  118294. getClassName(): string;
  118295. /**
  118296. * Gets the value input component
  118297. */
  118298. readonly value: NodeMaterialConnectionPoint;
  118299. /**
  118300. * Gets the output component
  118301. */
  118302. readonly output: NodeMaterialConnectionPoint;
  118303. protected _buildBlock(state: NodeMaterialBuildState): this;
  118304. protected _dumpPropertiesCode(): string;
  118305. serialize(): any;
  118306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118307. }
  118308. }
  118309. declare module BABYLON {
  118310. /**
  118311. * Block used to apply a cross product between 2 vectors
  118312. */
  118313. export class CrossBlock extends NodeMaterialBlock {
  118314. /**
  118315. * Creates a new CrossBlock
  118316. * @param name defines the block name
  118317. */
  118318. constructor(name: string);
  118319. /**
  118320. * Gets the current class name
  118321. * @returns the class name
  118322. */
  118323. getClassName(): string;
  118324. /**
  118325. * Gets the left operand input component
  118326. */
  118327. readonly left: NodeMaterialConnectionPoint;
  118328. /**
  118329. * Gets the right operand input component
  118330. */
  118331. readonly right: NodeMaterialConnectionPoint;
  118332. /**
  118333. * Gets the output component
  118334. */
  118335. readonly output: NodeMaterialConnectionPoint;
  118336. protected _buildBlock(state: NodeMaterialBuildState): this;
  118337. }
  118338. }
  118339. declare module BABYLON {
  118340. /**
  118341. * Block used to apply a dot product between 2 vectors
  118342. */
  118343. export class DotBlock extends NodeMaterialBlock {
  118344. /**
  118345. * Creates a new DotBlock
  118346. * @param name defines the block name
  118347. */
  118348. constructor(name: string);
  118349. /**
  118350. * Gets the current class name
  118351. * @returns the class name
  118352. */
  118353. getClassName(): string;
  118354. /**
  118355. * Gets the left operand input component
  118356. */
  118357. readonly left: NodeMaterialConnectionPoint;
  118358. /**
  118359. * Gets the right operand input component
  118360. */
  118361. readonly right: NodeMaterialConnectionPoint;
  118362. /**
  118363. * Gets the output component
  118364. */
  118365. readonly output: NodeMaterialConnectionPoint;
  118366. protected _buildBlock(state: NodeMaterialBuildState): this;
  118367. }
  118368. }
  118369. declare module BABYLON {
  118370. /**
  118371. * Block used to remap a float from a range to a new one
  118372. */
  118373. export class RemapBlock extends NodeMaterialBlock {
  118374. /**
  118375. * Gets or sets the source range
  118376. */
  118377. sourceRange: Vector2;
  118378. /**
  118379. * Gets or sets the target range
  118380. */
  118381. targetRange: Vector2;
  118382. /**
  118383. * Creates a new RemapBlock
  118384. * @param name defines the block name
  118385. */
  118386. constructor(name: string);
  118387. /**
  118388. * Gets the current class name
  118389. * @returns the class name
  118390. */
  118391. getClassName(): string;
  118392. /**
  118393. * Gets the input component
  118394. */
  118395. readonly input: NodeMaterialConnectionPoint;
  118396. /**
  118397. * Gets the output component
  118398. */
  118399. readonly output: NodeMaterialConnectionPoint;
  118400. protected _buildBlock(state: NodeMaterialBuildState): this;
  118401. protected _dumpPropertiesCode(): string;
  118402. serialize(): any;
  118403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118404. }
  118405. }
  118406. declare module BABYLON {
  118407. /**
  118408. * Block used to normalize a vector
  118409. */
  118410. export class NormalizeBlock extends NodeMaterialBlock {
  118411. /**
  118412. * Creates a new NormalizeBlock
  118413. * @param name defines the block name
  118414. */
  118415. constructor(name: string);
  118416. /**
  118417. * Gets the current class name
  118418. * @returns the class name
  118419. */
  118420. getClassName(): string;
  118421. /**
  118422. * Gets the input component
  118423. */
  118424. readonly input: NodeMaterialConnectionPoint;
  118425. /**
  118426. * Gets the output component
  118427. */
  118428. readonly output: NodeMaterialConnectionPoint;
  118429. protected _buildBlock(state: NodeMaterialBuildState): this;
  118430. }
  118431. }
  118432. declare module BABYLON {
  118433. /**
  118434. * Operations supported by the Trigonometry block
  118435. */
  118436. export enum TrigonometryBlockOperations {
  118437. /** Cos */
  118438. Cos = 0,
  118439. /** Sin */
  118440. Sin = 1,
  118441. /** Abs */
  118442. Abs = 2,
  118443. /** Exp */
  118444. Exp = 3,
  118445. /** Exp2 */
  118446. Exp2 = 4,
  118447. /** Round */
  118448. Round = 5,
  118449. /** Floor */
  118450. Floor = 6,
  118451. /** Ceiling */
  118452. Ceiling = 7
  118453. }
  118454. /**
  118455. * Block used to apply trigonometry operation to floats
  118456. */
  118457. export class TrigonometryBlock extends NodeMaterialBlock {
  118458. /**
  118459. * Gets or sets the operation applied by the block
  118460. */
  118461. operation: TrigonometryBlockOperations;
  118462. /**
  118463. * Creates a new TrigonometryBlock
  118464. * @param name defines the block name
  118465. */
  118466. constructor(name: string);
  118467. /**
  118468. * Gets the current class name
  118469. * @returns the class name
  118470. */
  118471. getClassName(): string;
  118472. /**
  118473. * Gets the input component
  118474. */
  118475. readonly input: NodeMaterialConnectionPoint;
  118476. /**
  118477. * Gets the output component
  118478. */
  118479. readonly output: NodeMaterialConnectionPoint;
  118480. protected _buildBlock(state: NodeMaterialBuildState): this;
  118481. }
  118482. }
  118483. declare module BABYLON {
  118484. /**
  118485. * Block used to create a Color3/4 out of individual inputs (one for each component)
  118486. */
  118487. export class ColorMergerBlock extends NodeMaterialBlock {
  118488. /**
  118489. * Create a new ColorMergerBlock
  118490. * @param name defines the block name
  118491. */
  118492. constructor(name: string);
  118493. /**
  118494. * Gets the current class name
  118495. * @returns the class name
  118496. */
  118497. getClassName(): string;
  118498. /**
  118499. * Gets the r component (input)
  118500. */
  118501. readonly r: NodeMaterialConnectionPoint;
  118502. /**
  118503. * Gets the g component (input)
  118504. */
  118505. readonly g: NodeMaterialConnectionPoint;
  118506. /**
  118507. * Gets the b component (input)
  118508. */
  118509. readonly b: NodeMaterialConnectionPoint;
  118510. /**
  118511. * Gets the a component (input)
  118512. */
  118513. readonly a: NodeMaterialConnectionPoint;
  118514. /**
  118515. * Gets the rgba component (output)
  118516. */
  118517. readonly rgba: NodeMaterialConnectionPoint;
  118518. /**
  118519. * Gets the rgb component (output)
  118520. */
  118521. readonly rgb: NodeMaterialConnectionPoint;
  118522. protected _buildBlock(state: NodeMaterialBuildState): this;
  118523. }
  118524. }
  118525. declare module BABYLON {
  118526. /**
  118527. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  118528. */
  118529. export class VectorMergerBlock extends NodeMaterialBlock {
  118530. /**
  118531. * Create a new VectorMergerBlock
  118532. * @param name defines the block name
  118533. */
  118534. constructor(name: string);
  118535. /**
  118536. * Gets the current class name
  118537. * @returns the class name
  118538. */
  118539. getClassName(): string;
  118540. /**
  118541. * Gets the x component (input)
  118542. */
  118543. readonly x: NodeMaterialConnectionPoint;
  118544. /**
  118545. * Gets the y component (input)
  118546. */
  118547. readonly y: NodeMaterialConnectionPoint;
  118548. /**
  118549. * Gets the z component (input)
  118550. */
  118551. readonly z: NodeMaterialConnectionPoint;
  118552. /**
  118553. * Gets the w component (input)
  118554. */
  118555. readonly w: NodeMaterialConnectionPoint;
  118556. /**
  118557. * Gets the xyzw component (output)
  118558. */
  118559. readonly xyzw: NodeMaterialConnectionPoint;
  118560. /**
  118561. * Gets the xyz component (output)
  118562. */
  118563. readonly xyz: NodeMaterialConnectionPoint;
  118564. /**
  118565. * Gets the xy component (output)
  118566. */
  118567. readonly xy: NodeMaterialConnectionPoint;
  118568. protected _buildBlock(state: NodeMaterialBuildState): this;
  118569. }
  118570. }
  118571. declare module BABYLON {
  118572. /**
  118573. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  118574. */
  118575. export class ColorSplitterBlock extends NodeMaterialBlock {
  118576. /**
  118577. * Create a new ColorSplitterBlock
  118578. * @param name defines the block name
  118579. */
  118580. constructor(name: string);
  118581. /**
  118582. * Gets the current class name
  118583. * @returns the class name
  118584. */
  118585. getClassName(): string;
  118586. /**
  118587. * Gets the rgba component (input)
  118588. */
  118589. readonly rgba: NodeMaterialConnectionPoint;
  118590. /**
  118591. * Gets the rgb component (input)
  118592. */
  118593. readonly rgbIn: NodeMaterialConnectionPoint;
  118594. /**
  118595. * Gets the rgb component (output)
  118596. */
  118597. readonly rgbOut: NodeMaterialConnectionPoint;
  118598. /**
  118599. * Gets the r component (output)
  118600. */
  118601. readonly r: NodeMaterialConnectionPoint;
  118602. /**
  118603. * Gets the g component (output)
  118604. */
  118605. readonly g: NodeMaterialConnectionPoint;
  118606. /**
  118607. * Gets the b component (output)
  118608. */
  118609. readonly b: NodeMaterialConnectionPoint;
  118610. /**
  118611. * Gets the a component (output)
  118612. */
  118613. readonly a: NodeMaterialConnectionPoint;
  118614. protected _inputRename(name: string): string;
  118615. protected _outputRename(name: string): string;
  118616. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118617. }
  118618. }
  118619. declare module BABYLON {
  118620. /**
  118621. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  118622. */
  118623. export class VectorSplitterBlock extends NodeMaterialBlock {
  118624. /**
  118625. * Create a new VectorSplitterBlock
  118626. * @param name defines the block name
  118627. */
  118628. constructor(name: string);
  118629. /**
  118630. * Gets the current class name
  118631. * @returns the class name
  118632. */
  118633. getClassName(): string;
  118634. /**
  118635. * Gets the xyzw component (input)
  118636. */
  118637. readonly xyzw: NodeMaterialConnectionPoint;
  118638. /**
  118639. * Gets the xyz component (input)
  118640. */
  118641. readonly xyzIn: NodeMaterialConnectionPoint;
  118642. /**
  118643. * Gets the xy component (input)
  118644. */
  118645. readonly xyIn: NodeMaterialConnectionPoint;
  118646. /**
  118647. * Gets the xyz component (output)
  118648. */
  118649. readonly xyzOut: NodeMaterialConnectionPoint;
  118650. /**
  118651. * Gets the xy component (output)
  118652. */
  118653. readonly xyOut: NodeMaterialConnectionPoint;
  118654. /**
  118655. * Gets the x component (output)
  118656. */
  118657. readonly x: NodeMaterialConnectionPoint;
  118658. /**
  118659. * Gets the y component (output)
  118660. */
  118661. readonly y: NodeMaterialConnectionPoint;
  118662. /**
  118663. * Gets the z component (output)
  118664. */
  118665. readonly z: NodeMaterialConnectionPoint;
  118666. /**
  118667. * Gets the w component (output)
  118668. */
  118669. readonly w: NodeMaterialConnectionPoint;
  118670. protected _inputRename(name: string): string;
  118671. protected _outputRename(name: string): string;
  118672. protected _buildBlock(state: NodeMaterialBuildState): this;
  118673. }
  118674. }
  118675. declare module BABYLON {
  118676. /**
  118677. * Block used to lerp 2 values
  118678. */
  118679. export class LerpBlock extends NodeMaterialBlock {
  118680. /**
  118681. * Creates a new LerpBlock
  118682. * @param name defines the block name
  118683. */
  118684. constructor(name: string);
  118685. /**
  118686. * Gets the current class name
  118687. * @returns the class name
  118688. */
  118689. getClassName(): string;
  118690. /**
  118691. * Gets the left operand input component
  118692. */
  118693. readonly left: NodeMaterialConnectionPoint;
  118694. /**
  118695. * Gets the right operand input component
  118696. */
  118697. readonly right: NodeMaterialConnectionPoint;
  118698. /**
  118699. * Gets the gradient operand input component
  118700. */
  118701. readonly gradient: NodeMaterialConnectionPoint;
  118702. /**
  118703. * Gets the output component
  118704. */
  118705. readonly output: NodeMaterialConnectionPoint;
  118706. protected _buildBlock(state: NodeMaterialBuildState): this;
  118707. }
  118708. }
  118709. declare module BABYLON {
  118710. /**
  118711. * Block used to divide 2 vectors
  118712. */
  118713. export class DivideBlock extends NodeMaterialBlock {
  118714. /**
  118715. * Creates a new DivideBlock
  118716. * @param name defines the block name
  118717. */
  118718. constructor(name: string);
  118719. /**
  118720. * Gets the current class name
  118721. * @returns the class name
  118722. */
  118723. getClassName(): string;
  118724. /**
  118725. * Gets the left operand input component
  118726. */
  118727. readonly left: NodeMaterialConnectionPoint;
  118728. /**
  118729. * Gets the right operand input component
  118730. */
  118731. readonly right: NodeMaterialConnectionPoint;
  118732. /**
  118733. * Gets the output component
  118734. */
  118735. readonly output: NodeMaterialConnectionPoint;
  118736. protected _buildBlock(state: NodeMaterialBuildState): this;
  118737. }
  118738. }
  118739. declare module BABYLON {
  118740. /**
  118741. * Block used to subtract 2 vectors
  118742. */
  118743. export class SubtractBlock extends NodeMaterialBlock {
  118744. /**
  118745. * Creates a new SubtractBlock
  118746. * @param name defines the block name
  118747. */
  118748. constructor(name: string);
  118749. /**
  118750. * Gets the current class name
  118751. * @returns the class name
  118752. */
  118753. getClassName(): string;
  118754. /**
  118755. * Gets the left operand input component
  118756. */
  118757. readonly left: NodeMaterialConnectionPoint;
  118758. /**
  118759. * Gets the right operand input component
  118760. */
  118761. readonly right: NodeMaterialConnectionPoint;
  118762. /**
  118763. * Gets the output component
  118764. */
  118765. readonly output: NodeMaterialConnectionPoint;
  118766. protected _buildBlock(state: NodeMaterialBuildState): this;
  118767. }
  118768. }
  118769. declare module BABYLON {
  118770. /**
  118771. * Block used to step a value
  118772. */
  118773. export class StepBlock extends NodeMaterialBlock {
  118774. /**
  118775. * Creates a new AddBlock
  118776. * @param name defines the block name
  118777. */
  118778. constructor(name: string);
  118779. /**
  118780. * Gets the current class name
  118781. * @returns the class name
  118782. */
  118783. getClassName(): string;
  118784. /**
  118785. * Gets the value operand input component
  118786. */
  118787. readonly value: NodeMaterialConnectionPoint;
  118788. /**
  118789. * Gets the edge operand input component
  118790. */
  118791. readonly edge: NodeMaterialConnectionPoint;
  118792. /**
  118793. * Gets the output component
  118794. */
  118795. readonly output: NodeMaterialConnectionPoint;
  118796. protected _buildBlock(state: NodeMaterialBuildState): this;
  118797. }
  118798. }
  118799. declare module BABYLON {
  118800. /**
  118801. * Effect Render Options
  118802. */
  118803. export interface IEffectRendererOptions {
  118804. /**
  118805. * Defines the vertices positions.
  118806. */
  118807. positions?: number[];
  118808. /**
  118809. * Defines the indices.
  118810. */
  118811. indices?: number[];
  118812. }
  118813. /**
  118814. * Helper class to render one or more effects
  118815. */
  118816. export class EffectRenderer {
  118817. private engine;
  118818. private static _DefaultOptions;
  118819. private _vertexBuffers;
  118820. private _indexBuffer;
  118821. private _ringBufferIndex;
  118822. private _ringScreenBuffer;
  118823. private _fullscreenViewport;
  118824. private _getNextFrameBuffer;
  118825. /**
  118826. * Creates an effect renderer
  118827. * @param engine the engine to use for rendering
  118828. * @param options defines the options of the effect renderer
  118829. */
  118830. constructor(engine: Engine, options?: IEffectRendererOptions);
  118831. /**
  118832. * Sets the current viewport in normalized coordinates 0-1
  118833. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  118834. */
  118835. setViewport(viewport?: Viewport): void;
  118836. /**
  118837. * Sets the current effect wrapper to use during draw.
  118838. * The effect needs to be ready before calling this api.
  118839. * This also sets the default full screen position attribute.
  118840. * @param effectWrapper Defines the effect to draw with
  118841. */
  118842. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  118843. /**
  118844. * Draws a full screen quad.
  118845. */
  118846. draw(): void;
  118847. /**
  118848. * renders one or more effects to a specified texture
  118849. * @param effectWrappers list of effects to renderer
  118850. * @param outputTexture texture to draw to, if null it will render to the screen
  118851. */
  118852. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  118853. /**
  118854. * Disposes of the effect renderer
  118855. */
  118856. dispose(): void;
  118857. }
  118858. /**
  118859. * Options to create an EffectWrapper
  118860. */
  118861. interface EffectWrapperCreationOptions {
  118862. /**
  118863. * Engine to use to create the effect
  118864. */
  118865. engine: Engine;
  118866. /**
  118867. * Fragment shader for the effect
  118868. */
  118869. fragmentShader: string;
  118870. /**
  118871. * Vertex shader for the effect
  118872. */
  118873. vertexShader?: string;
  118874. /**
  118875. * Attributes to use in the shader
  118876. */
  118877. attributeNames?: Array<string>;
  118878. /**
  118879. * Uniforms to use in the shader
  118880. */
  118881. uniformNames?: Array<string>;
  118882. /**
  118883. * Texture sampler names to use in the shader
  118884. */
  118885. samplerNames?: Array<string>;
  118886. /**
  118887. * The friendly name of the effect displayed in Spector.
  118888. */
  118889. name?: string;
  118890. }
  118891. /**
  118892. * Wraps an effect to be used for rendering
  118893. */
  118894. export class EffectWrapper {
  118895. /**
  118896. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  118897. */
  118898. onApplyObservable: Observable<{}>;
  118899. /**
  118900. * The underlying effect
  118901. */
  118902. effect: Effect;
  118903. /**
  118904. * Creates an effect to be renderer
  118905. * @param creationOptions options to create the effect
  118906. */
  118907. constructor(creationOptions: EffectWrapperCreationOptions);
  118908. /**
  118909. * Disposes of the effect wrapper
  118910. */
  118911. dispose(): void;
  118912. }
  118913. }
  118914. declare module BABYLON {
  118915. /**
  118916. * Helper class to push actions to a pool of workers.
  118917. */
  118918. export class WorkerPool implements IDisposable {
  118919. private _workerInfos;
  118920. private _pendingActions;
  118921. /**
  118922. * Constructor
  118923. * @param workers Array of workers to use for actions
  118924. */
  118925. constructor(workers: Array<Worker>);
  118926. /**
  118927. * Terminates all workers and clears any pending actions.
  118928. */
  118929. dispose(): void;
  118930. /**
  118931. * Pushes an action to the worker pool. If all the workers are active, the action will be
  118932. * pended until a worker has completed its action.
  118933. * @param action The action to perform. Call onComplete when the action is complete.
  118934. */
  118935. push(action: (worker: Worker, onComplete: () => void) => void): void;
  118936. private _execute;
  118937. }
  118938. }
  118939. declare module BABYLON {
  118940. /**
  118941. * Configuration for Draco compression
  118942. */
  118943. export interface IDracoCompressionConfiguration {
  118944. /**
  118945. * Configuration for the decoder.
  118946. */
  118947. decoder: {
  118948. /**
  118949. * The url to the WebAssembly module.
  118950. */
  118951. wasmUrl?: string;
  118952. /**
  118953. * The url to the WebAssembly binary.
  118954. */
  118955. wasmBinaryUrl?: string;
  118956. /**
  118957. * The url to the fallback JavaScript module.
  118958. */
  118959. fallbackUrl?: string;
  118960. };
  118961. }
  118962. /**
  118963. * Draco compression (https://google.github.io/draco/)
  118964. *
  118965. * This class wraps the Draco module.
  118966. *
  118967. * **Encoder**
  118968. *
  118969. * The encoder is not currently implemented.
  118970. *
  118971. * **Decoder**
  118972. *
  118973. * 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.
  118974. *
  118975. * To update the configuration, use the following code:
  118976. * ```javascript
  118977. * DracoCompression.Configuration = {
  118978. * decoder: {
  118979. * wasmUrl: "<url to the WebAssembly library>",
  118980. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  118981. * fallbackUrl: "<url to the fallback JavaScript library>",
  118982. * }
  118983. * };
  118984. * ```
  118985. *
  118986. * 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.
  118987. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  118988. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  118989. *
  118990. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  118991. * ```javascript
  118992. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  118993. * ```
  118994. *
  118995. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  118996. */
  118997. export class DracoCompression implements IDisposable {
  118998. private _workerPoolPromise?;
  118999. private _decoderModulePromise?;
  119000. /**
  119001. * The configuration. Defaults to the following urls:
  119002. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  119003. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  119004. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  119005. */
  119006. static Configuration: IDracoCompressionConfiguration;
  119007. /**
  119008. * Returns true if the decoder configuration is available.
  119009. */
  119010. static readonly DecoderAvailable: boolean;
  119011. /**
  119012. * Default number of workers to create when creating the draco compression object.
  119013. */
  119014. static DefaultNumWorkers: number;
  119015. private static GetDefaultNumWorkers;
  119016. private static _Default;
  119017. /**
  119018. * Default instance for the draco compression object.
  119019. */
  119020. static readonly Default: DracoCompression;
  119021. /**
  119022. * Constructor
  119023. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  119024. */
  119025. constructor(numWorkers?: number);
  119026. /**
  119027. * Stop all async operations and release resources.
  119028. */
  119029. dispose(): void;
  119030. /**
  119031. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  119032. * @returns a promise that resolves when ready
  119033. */
  119034. whenReadyAsync(): Promise<void>;
  119035. /**
  119036. * Decode Draco compressed mesh data to vertex data.
  119037. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  119038. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  119039. * @returns A promise that resolves with the decoded vertex data
  119040. */
  119041. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  119042. [kind: string]: number;
  119043. }): Promise<VertexData>;
  119044. }
  119045. }
  119046. declare module BABYLON {
  119047. /**
  119048. * Class for building Constructive Solid Geometry
  119049. */
  119050. export class CSG {
  119051. private polygons;
  119052. /**
  119053. * The world matrix
  119054. */
  119055. matrix: Matrix;
  119056. /**
  119057. * Stores the position
  119058. */
  119059. position: Vector3;
  119060. /**
  119061. * Stores the rotation
  119062. */
  119063. rotation: Vector3;
  119064. /**
  119065. * Stores the rotation quaternion
  119066. */
  119067. rotationQuaternion: Nullable<Quaternion>;
  119068. /**
  119069. * Stores the scaling vector
  119070. */
  119071. scaling: Vector3;
  119072. /**
  119073. * Convert the Mesh to CSG
  119074. * @param mesh The Mesh to convert to CSG
  119075. * @returns A new CSG from the Mesh
  119076. */
  119077. static FromMesh(mesh: Mesh): CSG;
  119078. /**
  119079. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  119080. * @param polygons Polygons used to construct a CSG solid
  119081. */
  119082. private static FromPolygons;
  119083. /**
  119084. * Clones, or makes a deep copy, of the CSG
  119085. * @returns A new CSG
  119086. */
  119087. clone(): CSG;
  119088. /**
  119089. * Unions this CSG with another CSG
  119090. * @param csg The CSG to union against this CSG
  119091. * @returns The unioned CSG
  119092. */
  119093. union(csg: CSG): CSG;
  119094. /**
  119095. * Unions this CSG with another CSG in place
  119096. * @param csg The CSG to union against this CSG
  119097. */
  119098. unionInPlace(csg: CSG): void;
  119099. /**
  119100. * Subtracts this CSG with another CSG
  119101. * @param csg The CSG to subtract against this CSG
  119102. * @returns A new CSG
  119103. */
  119104. subtract(csg: CSG): CSG;
  119105. /**
  119106. * Subtracts this CSG with another CSG in place
  119107. * @param csg The CSG to subtact against this CSG
  119108. */
  119109. subtractInPlace(csg: CSG): void;
  119110. /**
  119111. * Intersect this CSG with another CSG
  119112. * @param csg The CSG to intersect against this CSG
  119113. * @returns A new CSG
  119114. */
  119115. intersect(csg: CSG): CSG;
  119116. /**
  119117. * Intersects this CSG with another CSG in place
  119118. * @param csg The CSG to intersect against this CSG
  119119. */
  119120. intersectInPlace(csg: CSG): void;
  119121. /**
  119122. * Return a new CSG solid with solid and empty space switched. This solid is
  119123. * not modified.
  119124. * @returns A new CSG solid with solid and empty space switched
  119125. */
  119126. inverse(): CSG;
  119127. /**
  119128. * Inverses the CSG in place
  119129. */
  119130. inverseInPlace(): void;
  119131. /**
  119132. * This is used to keep meshes transformations so they can be restored
  119133. * when we build back a Babylon Mesh
  119134. * NB : All CSG operations are performed in world coordinates
  119135. * @param csg The CSG to copy the transform attributes from
  119136. * @returns This CSG
  119137. */
  119138. copyTransformAttributes(csg: CSG): CSG;
  119139. /**
  119140. * Build Raw mesh from CSG
  119141. * Coordinates here are in world space
  119142. * @param name The name of the mesh geometry
  119143. * @param scene The Scene
  119144. * @param keepSubMeshes Specifies if the submeshes should be kept
  119145. * @returns A new Mesh
  119146. */
  119147. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  119148. /**
  119149. * Build Mesh from CSG taking material and transforms into account
  119150. * @param name The name of the Mesh
  119151. * @param material The material of the Mesh
  119152. * @param scene The Scene
  119153. * @param keepSubMeshes Specifies if submeshes should be kept
  119154. * @returns The new Mesh
  119155. */
  119156. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  119157. }
  119158. }
  119159. declare module BABYLON {
  119160. /**
  119161. * Class used to create a trail following a mesh
  119162. */
  119163. export class TrailMesh extends Mesh {
  119164. private _generator;
  119165. private _autoStart;
  119166. private _running;
  119167. private _diameter;
  119168. private _length;
  119169. private _sectionPolygonPointsCount;
  119170. private _sectionVectors;
  119171. private _sectionNormalVectors;
  119172. private _beforeRenderObserver;
  119173. /**
  119174. * @constructor
  119175. * @param name The value used by scene.getMeshByName() to do a lookup.
  119176. * @param generator The mesh to generate a trail.
  119177. * @param scene The scene to add this mesh to.
  119178. * @param diameter Diameter of trailing mesh. Default is 1.
  119179. * @param length Length of trailing mesh. Default is 60.
  119180. * @param autoStart Automatically start trailing mesh. Default true.
  119181. */
  119182. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  119183. /**
  119184. * "TrailMesh"
  119185. * @returns "TrailMesh"
  119186. */
  119187. getClassName(): string;
  119188. private _createMesh;
  119189. /**
  119190. * Start trailing mesh.
  119191. */
  119192. start(): void;
  119193. /**
  119194. * Stop trailing mesh.
  119195. */
  119196. stop(): void;
  119197. /**
  119198. * Update trailing mesh geometry.
  119199. */
  119200. update(): void;
  119201. /**
  119202. * Returns a new TrailMesh object.
  119203. * @param name is a string, the name given to the new mesh
  119204. * @param newGenerator use new generator object for cloned trail mesh
  119205. * @returns a new mesh
  119206. */
  119207. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  119208. /**
  119209. * Serializes this trail mesh
  119210. * @param serializationObject object to write serialization to
  119211. */
  119212. serialize(serializationObject: any): void;
  119213. /**
  119214. * Parses a serialized trail mesh
  119215. * @param parsedMesh the serialized mesh
  119216. * @param scene the scene to create the trail mesh in
  119217. * @returns the created trail mesh
  119218. */
  119219. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  119220. }
  119221. }
  119222. declare module BABYLON {
  119223. /**
  119224. * Class containing static functions to help procedurally build meshes
  119225. */
  119226. export class TiledBoxBuilder {
  119227. /**
  119228. * Creates a box mesh
  119229. * 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)
  119230. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119234. * @param name defines the name of the mesh
  119235. * @param options defines the options used to create the mesh
  119236. * @param scene defines the hosting scene
  119237. * @returns the box mesh
  119238. */
  119239. static CreateTiledBox(name: string, options: {
  119240. pattern?: number;
  119241. width?: number;
  119242. height?: number;
  119243. depth?: number;
  119244. tileSize?: number;
  119245. tileWidth?: number;
  119246. tileHeight?: number;
  119247. alignHorizontal?: number;
  119248. alignVertical?: number;
  119249. faceUV?: Vector4[];
  119250. faceColors?: Color4[];
  119251. sideOrientation?: number;
  119252. updatable?: boolean;
  119253. }, scene?: Nullable<Scene>): Mesh;
  119254. }
  119255. }
  119256. declare module BABYLON {
  119257. /**
  119258. * Class containing static functions to help procedurally build meshes
  119259. */
  119260. export class TorusKnotBuilder {
  119261. /**
  119262. * Creates a torus knot mesh
  119263. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  119264. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  119265. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  119266. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  119267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119270. * @param name defines the name of the mesh
  119271. * @param options defines the options used to create the mesh
  119272. * @param scene defines the hosting scene
  119273. * @returns the torus knot mesh
  119274. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  119275. */
  119276. static CreateTorusKnot(name: string, options: {
  119277. radius?: number;
  119278. tube?: number;
  119279. radialSegments?: number;
  119280. tubularSegments?: number;
  119281. p?: number;
  119282. q?: number;
  119283. updatable?: boolean;
  119284. sideOrientation?: number;
  119285. frontUVs?: Vector4;
  119286. backUVs?: Vector4;
  119287. }, scene: any): Mesh;
  119288. }
  119289. }
  119290. declare module BABYLON {
  119291. /**
  119292. * Polygon
  119293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  119294. */
  119295. export class Polygon {
  119296. /**
  119297. * Creates a rectangle
  119298. * @param xmin bottom X coord
  119299. * @param ymin bottom Y coord
  119300. * @param xmax top X coord
  119301. * @param ymax top Y coord
  119302. * @returns points that make the resulting rectation
  119303. */
  119304. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  119305. /**
  119306. * Creates a circle
  119307. * @param radius radius of circle
  119308. * @param cx scale in x
  119309. * @param cy scale in y
  119310. * @param numberOfSides number of sides that make up the circle
  119311. * @returns points that make the resulting circle
  119312. */
  119313. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  119314. /**
  119315. * Creates a polygon from input string
  119316. * @param input Input polygon data
  119317. * @returns the parsed points
  119318. */
  119319. static Parse(input: string): Vector2[];
  119320. /**
  119321. * Starts building a polygon from x and y coordinates
  119322. * @param x x coordinate
  119323. * @param y y coordinate
  119324. * @returns the started path2
  119325. */
  119326. static StartingAt(x: number, y: number): Path2;
  119327. }
  119328. /**
  119329. * Builds a polygon
  119330. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  119331. */
  119332. export class PolygonMeshBuilder {
  119333. private _points;
  119334. private _outlinepoints;
  119335. private _holes;
  119336. private _name;
  119337. private _scene;
  119338. private _epoints;
  119339. private _eholes;
  119340. private _addToepoint;
  119341. /**
  119342. * Babylon reference to the earcut plugin.
  119343. */
  119344. bjsEarcut: any;
  119345. /**
  119346. * Creates a PolygonMeshBuilder
  119347. * @param name name of the builder
  119348. * @param contours Path of the polygon
  119349. * @param scene scene to add to when creating the mesh
  119350. * @param earcutInjection can be used to inject your own earcut reference
  119351. */
  119352. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  119353. /**
  119354. * Adds a whole within the polygon
  119355. * @param hole Array of points defining the hole
  119356. * @returns this
  119357. */
  119358. addHole(hole: Vector2[]): PolygonMeshBuilder;
  119359. /**
  119360. * Creates the polygon
  119361. * @param updatable If the mesh should be updatable
  119362. * @param depth The depth of the mesh created
  119363. * @returns the created mesh
  119364. */
  119365. build(updatable?: boolean, depth?: number): Mesh;
  119366. /**
  119367. * Creates the polygon
  119368. * @param depth The depth of the mesh created
  119369. * @returns the created VertexData
  119370. */
  119371. buildVertexData(depth?: number): VertexData;
  119372. /**
  119373. * Adds a side to the polygon
  119374. * @param positions points that make the polygon
  119375. * @param normals normals of the polygon
  119376. * @param uvs uvs of the polygon
  119377. * @param indices indices of the polygon
  119378. * @param bounds bounds of the polygon
  119379. * @param points points of the polygon
  119380. * @param depth depth of the polygon
  119381. * @param flip flip of the polygon
  119382. */
  119383. private addSide;
  119384. }
  119385. }
  119386. declare module BABYLON {
  119387. /**
  119388. * Class containing static functions to help procedurally build meshes
  119389. */
  119390. export class PolygonBuilder {
  119391. /**
  119392. * Creates a polygon mesh
  119393. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  119394. * * 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
  119395. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  119398. * * Remember you can only change the shape positions, not their number when updating a polygon
  119399. * @param name defines the name of the mesh
  119400. * @param options defines the options used to create the mesh
  119401. * @param scene defines the hosting scene
  119402. * @param earcutInjection can be used to inject your own earcut reference
  119403. * @returns the polygon mesh
  119404. */
  119405. static CreatePolygon(name: string, options: {
  119406. shape: Vector3[];
  119407. holes?: Vector3[][];
  119408. depth?: number;
  119409. faceUV?: Vector4[];
  119410. faceColors?: Color4[];
  119411. updatable?: boolean;
  119412. sideOrientation?: number;
  119413. frontUVs?: Vector4;
  119414. backUVs?: Vector4;
  119415. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119416. /**
  119417. * Creates an extruded polygon mesh, with depth in the Y direction.
  119418. * * 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)
  119419. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119420. * @param name defines the name of the mesh
  119421. * @param options defines the options used to create the mesh
  119422. * @param scene defines the hosting scene
  119423. * @param earcutInjection can be used to inject your own earcut reference
  119424. * @returns the polygon mesh
  119425. */
  119426. static ExtrudePolygon(name: string, options: {
  119427. shape: Vector3[];
  119428. holes?: Vector3[][];
  119429. depth?: number;
  119430. faceUV?: Vector4[];
  119431. faceColors?: Color4[];
  119432. updatable?: boolean;
  119433. sideOrientation?: number;
  119434. frontUVs?: Vector4;
  119435. backUVs?: Vector4;
  119436. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119437. }
  119438. }
  119439. declare module BABYLON {
  119440. /**
  119441. * Class containing static functions to help procedurally build meshes
  119442. */
  119443. export class LatheBuilder {
  119444. /**
  119445. * Creates lathe mesh.
  119446. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  119447. * * 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
  119448. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  119449. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  119450. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  119451. * * 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
  119452. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  119453. * * 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
  119454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119458. * @param name defines the name of the mesh
  119459. * @param options defines the options used to create the mesh
  119460. * @param scene defines the hosting scene
  119461. * @returns the lathe mesh
  119462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  119463. */
  119464. static CreateLathe(name: string, options: {
  119465. shape: Vector3[];
  119466. radius?: number;
  119467. tessellation?: number;
  119468. clip?: number;
  119469. arc?: number;
  119470. closed?: boolean;
  119471. updatable?: boolean;
  119472. sideOrientation?: number;
  119473. frontUVs?: Vector4;
  119474. backUVs?: Vector4;
  119475. cap?: number;
  119476. invertUV?: boolean;
  119477. }, scene?: Nullable<Scene>): Mesh;
  119478. }
  119479. }
  119480. declare module BABYLON {
  119481. /**
  119482. * Class containing static functions to help procedurally build meshes
  119483. */
  119484. export class TiledPlaneBuilder {
  119485. /**
  119486. * Creates a tiled plane mesh
  119487. * * The parameter `pattern` will, depending on value, do nothing or
  119488. * * * flip (reflect about central vertical) alternate tiles across and up
  119489. * * * flip every tile on alternate rows
  119490. * * * rotate (180 degs) alternate tiles across and up
  119491. * * * rotate every tile on alternate rows
  119492. * * * flip and rotate alternate tiles across and up
  119493. * * * flip and rotate every tile on alternate rows
  119494. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  119495. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  119496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119498. * * 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)
  119499. * * 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)
  119500. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119501. * @param name defines the name of the mesh
  119502. * @param options defines the options used to create the mesh
  119503. * @param scene defines the hosting scene
  119504. * @returns the box mesh
  119505. */
  119506. static CreateTiledPlane(name: string, options: {
  119507. pattern?: number;
  119508. tileSize?: number;
  119509. tileWidth?: number;
  119510. tileHeight?: number;
  119511. size?: number;
  119512. width?: number;
  119513. height?: number;
  119514. alignHorizontal?: number;
  119515. alignVertical?: number;
  119516. sideOrientation?: number;
  119517. frontUVs?: Vector4;
  119518. backUVs?: Vector4;
  119519. updatable?: boolean;
  119520. }, scene?: Nullable<Scene>): Mesh;
  119521. }
  119522. }
  119523. declare module BABYLON {
  119524. /**
  119525. * Class containing static functions to help procedurally build meshes
  119526. */
  119527. export class TubeBuilder {
  119528. /**
  119529. * Creates a tube mesh.
  119530. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119531. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  119532. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  119533. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  119534. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  119535. * * 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)
  119536. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  119537. * * 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
  119538. * * 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
  119539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119543. * @param name defines the name of the mesh
  119544. * @param options defines the options used to create the mesh
  119545. * @param scene defines the hosting scene
  119546. * @returns the tube mesh
  119547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119548. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  119549. */
  119550. static CreateTube(name: string, options: {
  119551. path: Vector3[];
  119552. radius?: number;
  119553. tessellation?: number;
  119554. radiusFunction?: {
  119555. (i: number, distance: number): number;
  119556. };
  119557. cap?: number;
  119558. arc?: number;
  119559. updatable?: boolean;
  119560. sideOrientation?: number;
  119561. frontUVs?: Vector4;
  119562. backUVs?: Vector4;
  119563. instance?: Mesh;
  119564. invertUV?: boolean;
  119565. }, scene?: Nullable<Scene>): Mesh;
  119566. }
  119567. }
  119568. declare module BABYLON {
  119569. /**
  119570. * Class containing static functions to help procedurally build meshes
  119571. */
  119572. export class IcoSphereBuilder {
  119573. /**
  119574. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119575. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119576. * * 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`)
  119577. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119578. * * 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
  119579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119582. * @param name defines the name of the mesh
  119583. * @param options defines the options used to create the mesh
  119584. * @param scene defines the hosting scene
  119585. * @returns the icosahedron mesh
  119586. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119587. */
  119588. static CreateIcoSphere(name: string, options: {
  119589. radius?: number;
  119590. radiusX?: number;
  119591. radiusY?: number;
  119592. radiusZ?: number;
  119593. flat?: boolean;
  119594. subdivisions?: number;
  119595. sideOrientation?: number;
  119596. frontUVs?: Vector4;
  119597. backUVs?: Vector4;
  119598. updatable?: boolean;
  119599. }, scene?: Nullable<Scene>): Mesh;
  119600. }
  119601. }
  119602. declare module BABYLON {
  119603. /**
  119604. * Class containing static functions to help procedurally build meshes
  119605. */
  119606. export class DecalBuilder {
  119607. /**
  119608. * Creates a decal mesh.
  119609. * 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
  119610. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119611. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119612. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119613. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119614. * @param name defines the name of the mesh
  119615. * @param sourceMesh defines the mesh where the decal must be applied
  119616. * @param options defines the options used to create the mesh
  119617. * @param scene defines the hosting scene
  119618. * @returns the decal mesh
  119619. * @see https://doc.babylonjs.com/how_to/decals
  119620. */
  119621. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119622. position?: Vector3;
  119623. normal?: Vector3;
  119624. size?: Vector3;
  119625. angle?: number;
  119626. }): Mesh;
  119627. }
  119628. }
  119629. declare module BABYLON {
  119630. /**
  119631. * Class containing static functions to help procedurally build meshes
  119632. */
  119633. export class MeshBuilder {
  119634. /**
  119635. * Creates a box mesh
  119636. * * The parameter `size` sets the size (float) of each box side (default 1)
  119637. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119638. * * 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)
  119639. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119643. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119644. * @param name defines the name of the mesh
  119645. * @param options defines the options used to create the mesh
  119646. * @param scene defines the hosting scene
  119647. * @returns the box mesh
  119648. */
  119649. static CreateBox(name: string, options: {
  119650. size?: number;
  119651. width?: number;
  119652. height?: number;
  119653. depth?: number;
  119654. faceUV?: Vector4[];
  119655. faceColors?: Color4[];
  119656. sideOrientation?: number;
  119657. frontUVs?: Vector4;
  119658. backUVs?: Vector4;
  119659. updatable?: boolean;
  119660. }, scene?: Nullable<Scene>): Mesh;
  119661. /**
  119662. * Creates a tiled box mesh
  119663. * * faceTiles sets the pattern, tile size and number of tiles for a face
  119664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119665. * @param name defines the name of the mesh
  119666. * @param options defines the options used to create the mesh
  119667. * @param scene defines the hosting scene
  119668. * @returns the tiled box mesh
  119669. */
  119670. static CreateTiledBox(name: string, options: {
  119671. pattern?: number;
  119672. size?: number;
  119673. width?: number;
  119674. height?: number;
  119675. depth: number;
  119676. tileSize?: number;
  119677. tileWidth?: number;
  119678. tileHeight?: number;
  119679. faceUV?: Vector4[];
  119680. faceColors?: Color4[];
  119681. alignHorizontal?: number;
  119682. alignVertical?: number;
  119683. sideOrientation?: number;
  119684. updatable?: boolean;
  119685. }, scene?: Nullable<Scene>): Mesh;
  119686. /**
  119687. * Creates a sphere mesh
  119688. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  119689. * * 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`)
  119690. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  119691. * * 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
  119692. * * 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)
  119693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119696. * @param name defines the name of the mesh
  119697. * @param options defines the options used to create the mesh
  119698. * @param scene defines the hosting scene
  119699. * @returns the sphere mesh
  119700. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  119701. */
  119702. static CreateSphere(name: string, options: {
  119703. segments?: number;
  119704. diameter?: number;
  119705. diameterX?: number;
  119706. diameterY?: number;
  119707. diameterZ?: number;
  119708. arc?: number;
  119709. slice?: number;
  119710. sideOrientation?: number;
  119711. frontUVs?: Vector4;
  119712. backUVs?: Vector4;
  119713. updatable?: boolean;
  119714. }, scene?: Nullable<Scene>): Mesh;
  119715. /**
  119716. * Creates a plane polygonal mesh. By default, this is a disc
  119717. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  119718. * * 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
  119719. * * 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
  119720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119723. * @param name defines the name of the mesh
  119724. * @param options defines the options used to create the mesh
  119725. * @param scene defines the hosting scene
  119726. * @returns the plane polygonal mesh
  119727. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119728. */
  119729. static CreateDisc(name: string, options: {
  119730. radius?: number;
  119731. tessellation?: number;
  119732. arc?: number;
  119733. updatable?: boolean;
  119734. sideOrientation?: number;
  119735. frontUVs?: Vector4;
  119736. backUVs?: Vector4;
  119737. }, scene?: Nullable<Scene>): Mesh;
  119738. /**
  119739. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119740. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119741. * * 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`)
  119742. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119743. * * 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
  119744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119747. * @param name defines the name of the mesh
  119748. * @param options defines the options used to create the mesh
  119749. * @param scene defines the hosting scene
  119750. * @returns the icosahedron mesh
  119751. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119752. */
  119753. static CreateIcoSphere(name: string, options: {
  119754. radius?: number;
  119755. radiusX?: number;
  119756. radiusY?: number;
  119757. radiusZ?: number;
  119758. flat?: boolean;
  119759. subdivisions?: number;
  119760. sideOrientation?: number;
  119761. frontUVs?: Vector4;
  119762. backUVs?: Vector4;
  119763. updatable?: boolean;
  119764. }, scene?: Nullable<Scene>): Mesh;
  119765. /**
  119766. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119767. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119768. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119769. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119770. * * 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
  119771. * * 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
  119772. * * 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
  119773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119775. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119776. * * 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
  119777. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119778. * * 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
  119779. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119781. * @param name defines the name of the mesh
  119782. * @param options defines the options used to create the mesh
  119783. * @param scene defines the hosting scene
  119784. * @returns the ribbon mesh
  119785. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119786. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119787. */
  119788. static CreateRibbon(name: string, options: {
  119789. pathArray: Vector3[][];
  119790. closeArray?: boolean;
  119791. closePath?: boolean;
  119792. offset?: number;
  119793. updatable?: boolean;
  119794. sideOrientation?: number;
  119795. frontUVs?: Vector4;
  119796. backUVs?: Vector4;
  119797. instance?: Mesh;
  119798. invertUV?: boolean;
  119799. uvs?: Vector2[];
  119800. colors?: Color4[];
  119801. }, scene?: Nullable<Scene>): Mesh;
  119802. /**
  119803. * Creates a cylinder or a cone mesh
  119804. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  119805. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  119806. * * 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.
  119807. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119808. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119809. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119810. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119811. * * 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).
  119812. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119813. * * 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).
  119814. * * 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
  119815. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119816. * * 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
  119817. * * 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.
  119818. * * If `enclose` is false, a ring surface is one element.
  119819. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119820. * * 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
  119821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119824. * @param name defines the name of the mesh
  119825. * @param options defines the options used to create the mesh
  119826. * @param scene defines the hosting scene
  119827. * @returns the cylinder mesh
  119828. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119829. */
  119830. static CreateCylinder(name: string, options: {
  119831. height?: number;
  119832. diameterTop?: number;
  119833. diameterBottom?: number;
  119834. diameter?: number;
  119835. tessellation?: number;
  119836. subdivisions?: number;
  119837. arc?: number;
  119838. faceColors?: Color4[];
  119839. faceUV?: Vector4[];
  119840. updatable?: boolean;
  119841. hasRings?: boolean;
  119842. enclose?: boolean;
  119843. cap?: number;
  119844. sideOrientation?: number;
  119845. frontUVs?: Vector4;
  119846. backUVs?: Vector4;
  119847. }, scene?: Nullable<Scene>): Mesh;
  119848. /**
  119849. * Creates a torus mesh
  119850. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  119851. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  119852. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  119853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119856. * @param name defines the name of the mesh
  119857. * @param options defines the options used to create the mesh
  119858. * @param scene defines the hosting scene
  119859. * @returns the torus mesh
  119860. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  119861. */
  119862. static CreateTorus(name: string, options: {
  119863. diameter?: number;
  119864. thickness?: number;
  119865. tessellation?: number;
  119866. updatable?: boolean;
  119867. sideOrientation?: number;
  119868. frontUVs?: Vector4;
  119869. backUVs?: Vector4;
  119870. }, scene?: Nullable<Scene>): Mesh;
  119871. /**
  119872. * Creates a torus knot mesh
  119873. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  119874. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  119875. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  119876. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  119877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119880. * @param name defines the name of the mesh
  119881. * @param options defines the options used to create the mesh
  119882. * @param scene defines the hosting scene
  119883. * @returns the torus knot mesh
  119884. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  119885. */
  119886. static CreateTorusKnot(name: string, options: {
  119887. radius?: number;
  119888. tube?: number;
  119889. radialSegments?: number;
  119890. tubularSegments?: number;
  119891. p?: number;
  119892. q?: number;
  119893. updatable?: boolean;
  119894. sideOrientation?: number;
  119895. frontUVs?: Vector4;
  119896. backUVs?: Vector4;
  119897. }, scene?: Nullable<Scene>): Mesh;
  119898. /**
  119899. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119900. * * 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
  119901. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119902. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119903. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119904. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119905. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119906. * * 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
  119907. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119910. * @param name defines the name of the new line system
  119911. * @param options defines the options used to create the line system
  119912. * @param scene defines the hosting scene
  119913. * @returns a new line system mesh
  119914. */
  119915. static CreateLineSystem(name: string, options: {
  119916. lines: Vector3[][];
  119917. updatable?: boolean;
  119918. instance?: Nullable<LinesMesh>;
  119919. colors?: Nullable<Color4[][]>;
  119920. useVertexAlpha?: boolean;
  119921. }, scene: Nullable<Scene>): LinesMesh;
  119922. /**
  119923. * Creates a line mesh
  119924. * 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
  119925. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119926. * * The parameter `points` is an array successive Vector3
  119927. * * 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
  119928. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119929. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119930. * * When updating an instance, remember that only point positions can change, not the number of points
  119931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119933. * @param name defines the name of the new line system
  119934. * @param options defines the options used to create the line system
  119935. * @param scene defines the hosting scene
  119936. * @returns a new line mesh
  119937. */
  119938. static CreateLines(name: string, options: {
  119939. points: Vector3[];
  119940. updatable?: boolean;
  119941. instance?: Nullable<LinesMesh>;
  119942. colors?: Color4[];
  119943. useVertexAlpha?: boolean;
  119944. }, scene?: Nullable<Scene>): LinesMesh;
  119945. /**
  119946. * Creates a dashed line mesh
  119947. * * 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
  119948. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119949. * * The parameter `points` is an array successive Vector3
  119950. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119951. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119952. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119953. * * 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
  119954. * * When updating an instance, remember that only point positions can change, not the number of points
  119955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119956. * @param name defines the name of the mesh
  119957. * @param options defines the options used to create the mesh
  119958. * @param scene defines the hosting scene
  119959. * @returns the dashed line mesh
  119960. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119961. */
  119962. static CreateDashedLines(name: string, options: {
  119963. points: Vector3[];
  119964. dashSize?: number;
  119965. gapSize?: number;
  119966. dashNb?: number;
  119967. updatable?: boolean;
  119968. instance?: LinesMesh;
  119969. }, scene?: Nullable<Scene>): LinesMesh;
  119970. /**
  119971. * 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.
  119972. * * 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.
  119973. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119974. * * 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.
  119975. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119976. * * 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
  119977. * * 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
  119978. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119981. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119983. * @param name defines the name of the mesh
  119984. * @param options defines the options used to create the mesh
  119985. * @param scene defines the hosting scene
  119986. * @returns the extruded shape mesh
  119987. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119989. */
  119990. static ExtrudeShape(name: string, options: {
  119991. shape: Vector3[];
  119992. path: Vector3[];
  119993. scale?: number;
  119994. rotation?: number;
  119995. cap?: number;
  119996. updatable?: boolean;
  119997. sideOrientation?: number;
  119998. frontUVs?: Vector4;
  119999. backUVs?: Vector4;
  120000. instance?: Mesh;
  120001. invertUV?: boolean;
  120002. }, scene?: Nullable<Scene>): Mesh;
  120003. /**
  120004. * Creates an custom extruded shape mesh.
  120005. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120006. * * 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.
  120007. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120008. * * 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
  120009. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120010. * * 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
  120011. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120012. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120013. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120014. * * 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
  120015. * * 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
  120016. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120019. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120021. * @param name defines the name of the mesh
  120022. * @param options defines the options used to create the mesh
  120023. * @param scene defines the hosting scene
  120024. * @returns the custom extruded shape mesh
  120025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120026. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120028. */
  120029. static ExtrudeShapeCustom(name: string, options: {
  120030. shape: Vector3[];
  120031. path: Vector3[];
  120032. scaleFunction?: any;
  120033. rotationFunction?: any;
  120034. ribbonCloseArray?: boolean;
  120035. ribbonClosePath?: boolean;
  120036. cap?: number;
  120037. updatable?: boolean;
  120038. sideOrientation?: number;
  120039. frontUVs?: Vector4;
  120040. backUVs?: Vector4;
  120041. instance?: Mesh;
  120042. invertUV?: boolean;
  120043. }, scene?: Nullable<Scene>): Mesh;
  120044. /**
  120045. * Creates lathe mesh.
  120046. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  120047. * * 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
  120048. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  120049. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  120050. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  120051. * * 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
  120052. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  120053. * * 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
  120054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120056. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120058. * @param name defines the name of the mesh
  120059. * @param options defines the options used to create the mesh
  120060. * @param scene defines the hosting scene
  120061. * @returns the lathe mesh
  120062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  120063. */
  120064. static CreateLathe(name: string, options: {
  120065. shape: Vector3[];
  120066. radius?: number;
  120067. tessellation?: number;
  120068. clip?: number;
  120069. arc?: number;
  120070. closed?: boolean;
  120071. updatable?: boolean;
  120072. sideOrientation?: number;
  120073. frontUVs?: Vector4;
  120074. backUVs?: Vector4;
  120075. cap?: number;
  120076. invertUV?: boolean;
  120077. }, scene?: Nullable<Scene>): Mesh;
  120078. /**
  120079. * Creates a tiled plane mesh
  120080. * * You can set a limited pattern arrangement with the tiles
  120081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120084. * @param name defines the name of the mesh
  120085. * @param options defines the options used to create the mesh
  120086. * @param scene defines the hosting scene
  120087. * @returns the plane mesh
  120088. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120089. */
  120090. static CreateTiledPlane(name: string, options: {
  120091. pattern?: number;
  120092. tileSize?: number;
  120093. tileWidth?: number;
  120094. tileHeight?: number;
  120095. size?: number;
  120096. width?: number;
  120097. height?: number;
  120098. alignHorizontal?: number;
  120099. alignVertical?: number;
  120100. sideOrientation?: number;
  120101. frontUVs?: Vector4;
  120102. backUVs?: Vector4;
  120103. updatable?: boolean;
  120104. }, scene?: Nullable<Scene>): Mesh;
  120105. /**
  120106. * Creates a plane mesh
  120107. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120108. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120109. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120113. * @param name defines the name of the mesh
  120114. * @param options defines the options used to create the mesh
  120115. * @param scene defines the hosting scene
  120116. * @returns the plane mesh
  120117. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120118. */
  120119. static CreatePlane(name: string, options: {
  120120. size?: number;
  120121. width?: number;
  120122. height?: number;
  120123. sideOrientation?: number;
  120124. frontUVs?: Vector4;
  120125. backUVs?: Vector4;
  120126. updatable?: boolean;
  120127. sourcePlane?: Plane;
  120128. }, scene?: Nullable<Scene>): Mesh;
  120129. /**
  120130. * Creates a ground mesh
  120131. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  120132. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  120133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120134. * @param name defines the name of the mesh
  120135. * @param options defines the options used to create the mesh
  120136. * @param scene defines the hosting scene
  120137. * @returns the ground mesh
  120138. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  120139. */
  120140. static CreateGround(name: string, options: {
  120141. width?: number;
  120142. height?: number;
  120143. subdivisions?: number;
  120144. subdivisionsX?: number;
  120145. subdivisionsY?: number;
  120146. updatable?: boolean;
  120147. }, scene?: Nullable<Scene>): Mesh;
  120148. /**
  120149. * Creates a tiled ground mesh
  120150. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  120151. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  120152. * * 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
  120153. * * 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
  120154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120155. * @param name defines the name of the mesh
  120156. * @param options defines the options used to create the mesh
  120157. * @param scene defines the hosting scene
  120158. * @returns the tiled ground mesh
  120159. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  120160. */
  120161. static CreateTiledGround(name: string, options: {
  120162. xmin: number;
  120163. zmin: number;
  120164. xmax: number;
  120165. zmax: number;
  120166. subdivisions?: {
  120167. w: number;
  120168. h: number;
  120169. };
  120170. precision?: {
  120171. w: number;
  120172. h: number;
  120173. };
  120174. updatable?: boolean;
  120175. }, scene?: Nullable<Scene>): Mesh;
  120176. /**
  120177. * Creates a ground mesh from a height map
  120178. * * The parameter `url` sets the URL of the height map image resource.
  120179. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  120180. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  120181. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  120182. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  120183. * * 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.
  120184. * * 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).
  120185. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  120186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120187. * @param name defines the name of the mesh
  120188. * @param url defines the url to the height map
  120189. * @param options defines the options used to create the mesh
  120190. * @param scene defines the hosting scene
  120191. * @returns the ground mesh
  120192. * @see https://doc.babylonjs.com/babylon101/height_map
  120193. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  120194. */
  120195. static CreateGroundFromHeightMap(name: string, url: string, options: {
  120196. width?: number;
  120197. height?: number;
  120198. subdivisions?: number;
  120199. minHeight?: number;
  120200. maxHeight?: number;
  120201. colorFilter?: Color3;
  120202. alphaFilter?: number;
  120203. updatable?: boolean;
  120204. onReady?: (mesh: GroundMesh) => void;
  120205. }, scene?: Nullable<Scene>): GroundMesh;
  120206. /**
  120207. * Creates a polygon mesh
  120208. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  120209. * * 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
  120210. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  120213. * * Remember you can only change the shape positions, not their number when updating a polygon
  120214. * @param name defines the name of the mesh
  120215. * @param options defines the options used to create the mesh
  120216. * @param scene defines the hosting scene
  120217. * @param earcutInjection can be used to inject your own earcut reference
  120218. * @returns the polygon mesh
  120219. */
  120220. static CreatePolygon(name: string, options: {
  120221. shape: Vector3[];
  120222. holes?: Vector3[][];
  120223. depth?: number;
  120224. faceUV?: Vector4[];
  120225. faceColors?: Color4[];
  120226. updatable?: boolean;
  120227. sideOrientation?: number;
  120228. frontUVs?: Vector4;
  120229. backUVs?: Vector4;
  120230. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120231. /**
  120232. * Creates an extruded polygon mesh, with depth in the Y direction.
  120233. * * 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)
  120234. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120235. * @param name defines the name of the mesh
  120236. * @param options defines the options used to create the mesh
  120237. * @param scene defines the hosting scene
  120238. * @param earcutInjection can be used to inject your own earcut reference
  120239. * @returns the polygon mesh
  120240. */
  120241. static ExtrudePolygon(name: string, options: {
  120242. shape: Vector3[];
  120243. holes?: Vector3[][];
  120244. depth?: number;
  120245. faceUV?: Vector4[];
  120246. faceColors?: Color4[];
  120247. updatable?: boolean;
  120248. sideOrientation?: number;
  120249. frontUVs?: Vector4;
  120250. backUVs?: Vector4;
  120251. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120252. /**
  120253. * Creates a tube mesh.
  120254. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120255. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  120256. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  120257. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  120258. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  120259. * * 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)
  120260. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  120261. * * 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
  120262. * * 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
  120263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120265. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120267. * @param name defines the name of the mesh
  120268. * @param options defines the options used to create the mesh
  120269. * @param scene defines the hosting scene
  120270. * @returns the tube mesh
  120271. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120272. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  120273. */
  120274. static CreateTube(name: string, options: {
  120275. path: Vector3[];
  120276. radius?: number;
  120277. tessellation?: number;
  120278. radiusFunction?: {
  120279. (i: number, distance: number): number;
  120280. };
  120281. cap?: number;
  120282. arc?: number;
  120283. updatable?: boolean;
  120284. sideOrientation?: number;
  120285. frontUVs?: Vector4;
  120286. backUVs?: Vector4;
  120287. instance?: Mesh;
  120288. invertUV?: boolean;
  120289. }, scene?: Nullable<Scene>): Mesh;
  120290. /**
  120291. * Creates a polyhedron mesh
  120292. * * 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
  120293. * * The parameter `size` (positive float, default 1) sets the polygon size
  120294. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  120295. * * 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`
  120296. * * 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
  120297. * * 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)`)
  120298. * * 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
  120299. * * 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
  120300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120303. * @param name defines the name of the mesh
  120304. * @param options defines the options used to create the mesh
  120305. * @param scene defines the hosting scene
  120306. * @returns the polyhedron mesh
  120307. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  120308. */
  120309. static CreatePolyhedron(name: string, options: {
  120310. type?: number;
  120311. size?: number;
  120312. sizeX?: number;
  120313. sizeY?: number;
  120314. sizeZ?: number;
  120315. custom?: any;
  120316. faceUV?: Vector4[];
  120317. faceColors?: Color4[];
  120318. flat?: boolean;
  120319. updatable?: boolean;
  120320. sideOrientation?: number;
  120321. frontUVs?: Vector4;
  120322. backUVs?: Vector4;
  120323. }, scene?: Nullable<Scene>): Mesh;
  120324. /**
  120325. * Creates a decal mesh.
  120326. * 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
  120327. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  120328. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  120329. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  120330. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  120331. * @param name defines the name of the mesh
  120332. * @param sourceMesh defines the mesh where the decal must be applied
  120333. * @param options defines the options used to create the mesh
  120334. * @param scene defines the hosting scene
  120335. * @returns the decal mesh
  120336. * @see https://doc.babylonjs.com/how_to/decals
  120337. */
  120338. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  120339. position?: Vector3;
  120340. normal?: Vector3;
  120341. size?: Vector3;
  120342. angle?: number;
  120343. }): Mesh;
  120344. }
  120345. }
  120346. declare module BABYLON {
  120347. /**
  120348. * A simplifier interface for future simplification implementations
  120349. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120350. */
  120351. export interface ISimplifier {
  120352. /**
  120353. * Simplification of a given mesh according to the given settings.
  120354. * Since this requires computation, it is assumed that the function runs async.
  120355. * @param settings The settings of the simplification, including quality and distance
  120356. * @param successCallback A callback that will be called after the mesh was simplified.
  120357. * @param errorCallback in case of an error, this callback will be called. optional.
  120358. */
  120359. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  120360. }
  120361. /**
  120362. * Expected simplification settings.
  120363. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  120364. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120365. */
  120366. export interface ISimplificationSettings {
  120367. /**
  120368. * Gets or sets the expected quality
  120369. */
  120370. quality: number;
  120371. /**
  120372. * Gets or sets the distance when this optimized version should be used
  120373. */
  120374. distance: number;
  120375. /**
  120376. * Gets an already optimized mesh
  120377. */
  120378. optimizeMesh?: boolean;
  120379. }
  120380. /**
  120381. * Class used to specify simplification options
  120382. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120383. */
  120384. export class SimplificationSettings implements ISimplificationSettings {
  120385. /** expected quality */
  120386. quality: number;
  120387. /** distance when this optimized version should be used */
  120388. distance: number;
  120389. /** already optimized mesh */
  120390. optimizeMesh?: boolean | undefined;
  120391. /**
  120392. * Creates a SimplificationSettings
  120393. * @param quality expected quality
  120394. * @param distance distance when this optimized version should be used
  120395. * @param optimizeMesh already optimized mesh
  120396. */
  120397. constructor(
  120398. /** expected quality */
  120399. quality: number,
  120400. /** distance when this optimized version should be used */
  120401. distance: number,
  120402. /** already optimized mesh */
  120403. optimizeMesh?: boolean | undefined);
  120404. }
  120405. /**
  120406. * Interface used to define a simplification task
  120407. */
  120408. export interface ISimplificationTask {
  120409. /**
  120410. * Array of settings
  120411. */
  120412. settings: Array<ISimplificationSettings>;
  120413. /**
  120414. * Simplification type
  120415. */
  120416. simplificationType: SimplificationType;
  120417. /**
  120418. * Mesh to simplify
  120419. */
  120420. mesh: Mesh;
  120421. /**
  120422. * Callback called on success
  120423. */
  120424. successCallback?: () => void;
  120425. /**
  120426. * Defines if parallel processing can be used
  120427. */
  120428. parallelProcessing: boolean;
  120429. }
  120430. /**
  120431. * Queue used to order the simplification tasks
  120432. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120433. */
  120434. export class SimplificationQueue {
  120435. private _simplificationArray;
  120436. /**
  120437. * Gets a boolean indicating that the process is still running
  120438. */
  120439. running: boolean;
  120440. /**
  120441. * Creates a new queue
  120442. */
  120443. constructor();
  120444. /**
  120445. * Adds a new simplification task
  120446. * @param task defines a task to add
  120447. */
  120448. addTask(task: ISimplificationTask): void;
  120449. /**
  120450. * Execute next task
  120451. */
  120452. executeNext(): void;
  120453. /**
  120454. * Execute a simplification task
  120455. * @param task defines the task to run
  120456. */
  120457. runSimplification(task: ISimplificationTask): void;
  120458. private getSimplifier;
  120459. }
  120460. /**
  120461. * The implemented types of simplification
  120462. * At the moment only Quadratic Error Decimation is implemented
  120463. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120464. */
  120465. export enum SimplificationType {
  120466. /** Quadratic error decimation */
  120467. QUADRATIC = 0
  120468. }
  120469. }
  120470. declare module BABYLON {
  120471. interface Scene {
  120472. /** @hidden (Backing field) */
  120473. _simplificationQueue: SimplificationQueue;
  120474. /**
  120475. * Gets or sets the simplification queue attached to the scene
  120476. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120477. */
  120478. simplificationQueue: SimplificationQueue;
  120479. }
  120480. interface Mesh {
  120481. /**
  120482. * Simplify the mesh according to the given array of settings.
  120483. * Function will return immediately and will simplify async
  120484. * @param settings a collection of simplification settings
  120485. * @param parallelProcessing should all levels calculate parallel or one after the other
  120486. * @param simplificationType the type of simplification to run
  120487. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  120488. * @returns the current mesh
  120489. */
  120490. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  120491. }
  120492. /**
  120493. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  120494. * created in a scene
  120495. */
  120496. export class SimplicationQueueSceneComponent implements ISceneComponent {
  120497. /**
  120498. * The component name helpfull to identify the component in the list of scene components.
  120499. */
  120500. readonly name: string;
  120501. /**
  120502. * The scene the component belongs to.
  120503. */
  120504. scene: Scene;
  120505. /**
  120506. * Creates a new instance of the component for the given scene
  120507. * @param scene Defines the scene to register the component in
  120508. */
  120509. constructor(scene: Scene);
  120510. /**
  120511. * Registers the component in a given scene
  120512. */
  120513. register(): void;
  120514. /**
  120515. * Rebuilds the elements related to this component in case of
  120516. * context lost for instance.
  120517. */
  120518. rebuild(): void;
  120519. /**
  120520. * Disposes the component and the associated ressources
  120521. */
  120522. dispose(): void;
  120523. private _beforeCameraUpdate;
  120524. }
  120525. }
  120526. declare module BABYLON {
  120527. /**
  120528. * Navigation plugin interface to add navigation constrained by a navigation mesh
  120529. */
  120530. export interface INavigationEnginePlugin {
  120531. /**
  120532. * plugin name
  120533. */
  120534. name: string;
  120535. /**
  120536. * Creates a navigation mesh
  120537. * @param meshes array of all the geometry used to compute the navigatio mesh
  120538. * @param parameters bunch of parameters used to filter geometry
  120539. */
  120540. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120541. /**
  120542. * Create a navigation mesh debug mesh
  120543. * @param scene is where the mesh will be added
  120544. * @returns debug display mesh
  120545. */
  120546. createDebugNavMesh(scene: Scene): Mesh;
  120547. /**
  120548. * Get a navigation mesh constrained position, closest to the parameter position
  120549. * @param position world position
  120550. * @returns the closest point to position constrained by the navigation mesh
  120551. */
  120552. getClosestPoint(position: Vector3): Vector3;
  120553. /**
  120554. * Get a navigation mesh constrained position, within a particular radius
  120555. * @param position world position
  120556. * @param maxRadius the maximum distance to the constrained world position
  120557. * @returns the closest point to position constrained by the navigation mesh
  120558. */
  120559. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120560. /**
  120561. * Compute the final position from a segment made of destination-position
  120562. * @param position world position
  120563. * @param destination world position
  120564. * @returns the resulting point along the navmesh
  120565. */
  120566. moveAlong(position: Vector3, destination: Vector3): Vector3;
  120567. /**
  120568. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120569. * @param start world position
  120570. * @param end world position
  120571. * @returns array containing world position composing the path
  120572. */
  120573. computePath(start: Vector3, end: Vector3): Vector3[];
  120574. /**
  120575. * If this plugin is supported
  120576. * @returns true if plugin is supported
  120577. */
  120578. isSupported(): boolean;
  120579. /**
  120580. * Create a new Crowd so you can add agents
  120581. * @param maxAgents the maximum agent count in the crowd
  120582. * @param maxAgentRadius the maximum radius an agent can have
  120583. * @param scene to attach the crowd to
  120584. * @returns the crowd you can add agents to
  120585. */
  120586. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120587. /**
  120588. * Release all resources
  120589. */
  120590. dispose(): void;
  120591. }
  120592. /**
  120593. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  120594. */
  120595. export interface ICrowd {
  120596. /**
  120597. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120598. * You can attach anything to that node. The node position is updated in the scene update tick.
  120599. * @param pos world position that will be constrained by the navigation mesh
  120600. * @param parameters agent parameters
  120601. * @param transform hooked to the agent that will be update by the scene
  120602. * @returns agent index
  120603. */
  120604. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120605. /**
  120606. * Returns the agent position in world space
  120607. * @param index agent index returned by addAgent
  120608. * @returns world space position
  120609. */
  120610. getAgentPosition(index: number): Vector3;
  120611. /**
  120612. * Gets the agent velocity in world space
  120613. * @param index agent index returned by addAgent
  120614. * @returns world space velocity
  120615. */
  120616. getAgentVelocity(index: number): Vector3;
  120617. /**
  120618. * remove a particular agent previously created
  120619. * @param index agent index returned by addAgent
  120620. */
  120621. removeAgent(index: number): void;
  120622. /**
  120623. * get the list of all agents attached to this crowd
  120624. * @returns list of agent indices
  120625. */
  120626. getAgents(): number[];
  120627. /**
  120628. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120629. * @param deltaTime in seconds
  120630. */
  120631. update(deltaTime: number): void;
  120632. /**
  120633. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120634. * @param index agent index returned by addAgent
  120635. * @param destination targeted world position
  120636. */
  120637. agentGoto(index: number, destination: Vector3): void;
  120638. /**
  120639. * Release all resources
  120640. */
  120641. dispose(): void;
  120642. }
  120643. /**
  120644. * Configures an agent
  120645. */
  120646. export interface IAgentParameters {
  120647. /**
  120648. * Agent radius. [Limit: >= 0]
  120649. */
  120650. radius: number;
  120651. /**
  120652. * Agent height. [Limit: > 0]
  120653. */
  120654. height: number;
  120655. /**
  120656. * Maximum allowed acceleration. [Limit: >= 0]
  120657. */
  120658. maxAcceleration: number;
  120659. /**
  120660. * Maximum allowed speed. [Limit: >= 0]
  120661. */
  120662. maxSpeed: number;
  120663. /**
  120664. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  120665. */
  120666. collisionQueryRange: number;
  120667. /**
  120668. * The path visibility optimization range. [Limit: > 0]
  120669. */
  120670. pathOptimizationRange: number;
  120671. /**
  120672. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  120673. */
  120674. separationWeight: number;
  120675. }
  120676. /**
  120677. * Configures the navigation mesh creation
  120678. */
  120679. export interface INavMeshParameters {
  120680. /**
  120681. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  120682. */
  120683. cs: number;
  120684. /**
  120685. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  120686. */
  120687. ch: number;
  120688. /**
  120689. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  120690. */
  120691. walkableSlopeAngle: number;
  120692. /**
  120693. * Minimum floor to 'ceiling' height that will still allow the floor area to
  120694. * be considered walkable. [Limit: >= 3] [Units: vx]
  120695. */
  120696. walkableHeight: number;
  120697. /**
  120698. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  120699. */
  120700. walkableClimb: number;
  120701. /**
  120702. * The distance to erode/shrink the walkable area of the heightfield away from
  120703. * obstructions. [Limit: >=0] [Units: vx]
  120704. */
  120705. walkableRadius: number;
  120706. /**
  120707. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  120708. */
  120709. maxEdgeLen: number;
  120710. /**
  120711. * The maximum distance a simplfied contour's border edges should deviate
  120712. * the original raw contour. [Limit: >=0] [Units: vx]
  120713. */
  120714. maxSimplificationError: number;
  120715. /**
  120716. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  120717. */
  120718. minRegionArea: number;
  120719. /**
  120720. * Any regions with a span count smaller than this value will, if possible,
  120721. * be merged with larger regions. [Limit: >=0] [Units: vx]
  120722. */
  120723. mergeRegionArea: number;
  120724. /**
  120725. * The maximum number of vertices allowed for polygons generated during the
  120726. * contour to polygon conversion process. [Limit: >= 3]
  120727. */
  120728. maxVertsPerPoly: number;
  120729. /**
  120730. * Sets the sampling distance to use when generating the detail mesh.
  120731. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  120732. */
  120733. detailSampleDist: number;
  120734. /**
  120735. * The maximum distance the detail mesh surface should deviate from heightfield
  120736. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  120737. */
  120738. detailSampleMaxError: number;
  120739. }
  120740. }
  120741. declare module BABYLON {
  120742. /**
  120743. * RecastJS navigation plugin
  120744. */
  120745. export class RecastJSPlugin implements INavigationEnginePlugin {
  120746. /**
  120747. * Reference to the Recast library
  120748. */
  120749. bjsRECAST: any;
  120750. /**
  120751. * plugin name
  120752. */
  120753. name: string;
  120754. /**
  120755. * the first navmesh created. We might extend this to support multiple navmeshes
  120756. */
  120757. navMesh: any;
  120758. /**
  120759. * Initializes the recastJS plugin
  120760. * @param recastInjection can be used to inject your own recast reference
  120761. */
  120762. constructor(recastInjection?: any);
  120763. /**
  120764. * Creates a navigation mesh
  120765. * @param meshes array of all the geometry used to compute the navigatio mesh
  120766. * @param parameters bunch of parameters used to filter geometry
  120767. */
  120768. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120769. /**
  120770. * Create a navigation mesh debug mesh
  120771. * @param scene is where the mesh will be added
  120772. * @returns debug display mesh
  120773. */
  120774. createDebugNavMesh(scene: Scene): Mesh;
  120775. /**
  120776. * Get a navigation mesh constrained position, closest to the parameter position
  120777. * @param position world position
  120778. * @returns the closest point to position constrained by the navigation mesh
  120779. */
  120780. getClosestPoint(position: Vector3): Vector3;
  120781. /**
  120782. * Get a navigation mesh constrained position, within a particular radius
  120783. * @param position world position
  120784. * @param maxRadius the maximum distance to the constrained world position
  120785. * @returns the closest point to position constrained by the navigation mesh
  120786. */
  120787. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120788. /**
  120789. * Compute the final position from a segment made of destination-position
  120790. * @param position world position
  120791. * @param destination world position
  120792. * @returns the resulting point along the navmesh
  120793. */
  120794. moveAlong(position: Vector3, destination: Vector3): Vector3;
  120795. /**
  120796. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120797. * @param start world position
  120798. * @param end world position
  120799. * @returns array containing world position composing the path
  120800. */
  120801. computePath(start: Vector3, end: Vector3): Vector3[];
  120802. /**
  120803. * Create a new Crowd so you can add agents
  120804. * @param maxAgents the maximum agent count in the crowd
  120805. * @param maxAgentRadius the maximum radius an agent can have
  120806. * @param scene to attach the crowd to
  120807. * @returns the crowd you can add agents to
  120808. */
  120809. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120810. /**
  120811. * Disposes
  120812. */
  120813. dispose(): void;
  120814. /**
  120815. * If this plugin is supported
  120816. * @returns true if plugin is supported
  120817. */
  120818. isSupported(): boolean;
  120819. }
  120820. /**
  120821. * Recast detour crowd implementation
  120822. */
  120823. export class RecastJSCrowd implements ICrowd {
  120824. /**
  120825. * Recast/detour plugin
  120826. */
  120827. bjsRECASTPlugin: RecastJSPlugin;
  120828. /**
  120829. * Link to the detour crowd
  120830. */
  120831. recastCrowd: any;
  120832. /**
  120833. * One transform per agent
  120834. */
  120835. transforms: TransformNode[];
  120836. /**
  120837. * All agents created
  120838. */
  120839. agents: number[];
  120840. /**
  120841. * Link to the scene is kept to unregister the crowd from the scene
  120842. */
  120843. private _scene;
  120844. /**
  120845. * Observer for crowd updates
  120846. */
  120847. private _onBeforeAnimationsObserver;
  120848. /**
  120849. * Constructor
  120850. * @param plugin recastJS plugin
  120851. * @param maxAgents the maximum agent count in the crowd
  120852. * @param maxAgentRadius the maximum radius an agent can have
  120853. * @param scene to attach the crowd to
  120854. * @returns the crowd you can add agents to
  120855. */
  120856. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  120857. /**
  120858. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120859. * You can attach anything to that node. The node position is updated in the scene update tick.
  120860. * @param pos world position that will be constrained by the navigation mesh
  120861. * @param parameters agent parameters
  120862. * @param transform hooked to the agent that will be update by the scene
  120863. * @returns agent index
  120864. */
  120865. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120866. /**
  120867. * Returns the agent position in world space
  120868. * @param index agent index returned by addAgent
  120869. * @returns world space position
  120870. */
  120871. getAgentPosition(index: number): Vector3;
  120872. /**
  120873. * Returns the agent velocity in world space
  120874. * @param index agent index returned by addAgent
  120875. * @returns world space velocity
  120876. */
  120877. getAgentVelocity(index: number): Vector3;
  120878. /**
  120879. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120880. * @param index agent index returned by addAgent
  120881. * @param destination targeted world position
  120882. */
  120883. agentGoto(index: number, destination: Vector3): void;
  120884. /**
  120885. * remove a particular agent previously created
  120886. * @param index agent index returned by addAgent
  120887. */
  120888. removeAgent(index: number): void;
  120889. /**
  120890. * get the list of all agents attached to this crowd
  120891. * @returns list of agent indices
  120892. */
  120893. getAgents(): number[];
  120894. /**
  120895. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120896. * @param deltaTime in seconds
  120897. */
  120898. update(deltaTime: number): void;
  120899. /**
  120900. * Release all resources
  120901. */
  120902. dispose(): void;
  120903. }
  120904. }
  120905. declare module BABYLON {
  120906. /**
  120907. * Class used to enable access to IndexedDB
  120908. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120909. */
  120910. export class Database implements IOfflineProvider {
  120911. private _callbackManifestChecked;
  120912. private _currentSceneUrl;
  120913. private _db;
  120914. private _enableSceneOffline;
  120915. private _enableTexturesOffline;
  120916. private _manifestVersionFound;
  120917. private _mustUpdateRessources;
  120918. private _hasReachedQuota;
  120919. private _isSupported;
  120920. private _idbFactory;
  120921. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  120922. private static IsUASupportingBlobStorage;
  120923. /**
  120924. * Gets a boolean indicating if Database storate is enabled (off by default)
  120925. */
  120926. static IDBStorageEnabled: boolean;
  120927. /**
  120928. * Gets a boolean indicating if scene must be saved in the database
  120929. */
  120930. readonly enableSceneOffline: boolean;
  120931. /**
  120932. * Gets a boolean indicating if textures must be saved in the database
  120933. */
  120934. readonly enableTexturesOffline: boolean;
  120935. /**
  120936. * Creates a new Database
  120937. * @param urlToScene defines the url to load the scene
  120938. * @param callbackManifestChecked defines the callback to use when manifest is checked
  120939. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  120940. */
  120941. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  120942. private static _ParseURL;
  120943. private static _ReturnFullUrlLocation;
  120944. private _checkManifestFile;
  120945. /**
  120946. * Open the database and make it available
  120947. * @param successCallback defines the callback to call on success
  120948. * @param errorCallback defines the callback to call on error
  120949. */
  120950. open(successCallback: () => void, errorCallback: () => void): void;
  120951. /**
  120952. * Loads an image from the database
  120953. * @param url defines the url to load from
  120954. * @param image defines the target DOM image
  120955. */
  120956. loadImage(url: string, image: HTMLImageElement): void;
  120957. private _loadImageFromDBAsync;
  120958. private _saveImageIntoDBAsync;
  120959. private _checkVersionFromDB;
  120960. private _loadVersionFromDBAsync;
  120961. private _saveVersionIntoDBAsync;
  120962. /**
  120963. * Loads a file from database
  120964. * @param url defines the URL to load from
  120965. * @param sceneLoaded defines a callback to call on success
  120966. * @param progressCallBack defines a callback to call when progress changed
  120967. * @param errorCallback defines a callback to call on error
  120968. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  120969. */
  120970. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  120971. private _loadFileAsync;
  120972. private _saveFileAsync;
  120973. /**
  120974. * Validates if xhr data is correct
  120975. * @param xhr defines the request to validate
  120976. * @param dataType defines the expected data type
  120977. * @returns true if data is correct
  120978. */
  120979. private static _ValidateXHRData;
  120980. }
  120981. }
  120982. declare module BABYLON {
  120983. /** @hidden */
  120984. export var gpuUpdateParticlesPixelShader: {
  120985. name: string;
  120986. shader: string;
  120987. };
  120988. }
  120989. declare module BABYLON {
  120990. /** @hidden */
  120991. export var gpuUpdateParticlesVertexShader: {
  120992. name: string;
  120993. shader: string;
  120994. };
  120995. }
  120996. declare module BABYLON {
  120997. /** @hidden */
  120998. export var clipPlaneFragmentDeclaration2: {
  120999. name: string;
  121000. shader: string;
  121001. };
  121002. }
  121003. declare module BABYLON {
  121004. /** @hidden */
  121005. export var gpuRenderParticlesPixelShader: {
  121006. name: string;
  121007. shader: string;
  121008. };
  121009. }
  121010. declare module BABYLON {
  121011. /** @hidden */
  121012. export var clipPlaneVertexDeclaration2: {
  121013. name: string;
  121014. shader: string;
  121015. };
  121016. }
  121017. declare module BABYLON {
  121018. /** @hidden */
  121019. export var gpuRenderParticlesVertexShader: {
  121020. name: string;
  121021. shader: string;
  121022. };
  121023. }
  121024. declare module BABYLON {
  121025. /**
  121026. * This represents a GPU particle system in Babylon
  121027. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  121028. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  121029. */
  121030. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  121031. /**
  121032. * The layer mask we are rendering the particles through.
  121033. */
  121034. layerMask: number;
  121035. private _capacity;
  121036. private _activeCount;
  121037. private _currentActiveCount;
  121038. private _accumulatedCount;
  121039. private _renderEffect;
  121040. private _updateEffect;
  121041. private _buffer0;
  121042. private _buffer1;
  121043. private _spriteBuffer;
  121044. private _updateVAO;
  121045. private _renderVAO;
  121046. private _targetIndex;
  121047. private _sourceBuffer;
  121048. private _targetBuffer;
  121049. private _engine;
  121050. private _currentRenderId;
  121051. private _started;
  121052. private _stopped;
  121053. private _timeDelta;
  121054. private _randomTexture;
  121055. private _randomTexture2;
  121056. private _attributesStrideSize;
  121057. private _updateEffectOptions;
  121058. private _randomTextureSize;
  121059. private _actualFrame;
  121060. private readonly _rawTextureWidth;
  121061. /**
  121062. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  121063. */
  121064. static readonly IsSupported: boolean;
  121065. /**
  121066. * An event triggered when the system is disposed.
  121067. */
  121068. onDisposeObservable: Observable<GPUParticleSystem>;
  121069. /**
  121070. * Gets the maximum number of particles active at the same time.
  121071. * @returns The max number of active particles.
  121072. */
  121073. getCapacity(): number;
  121074. /**
  121075. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  121076. * to override the particles.
  121077. */
  121078. forceDepthWrite: boolean;
  121079. /**
  121080. * Gets or set the number of active particles
  121081. */
  121082. activeParticleCount: number;
  121083. private _preWarmDone;
  121084. /**
  121085. * Is this system ready to be used/rendered
  121086. * @return true if the system is ready
  121087. */
  121088. isReady(): boolean;
  121089. /**
  121090. * Gets if the system has been started. (Note: this will still be true after stop is called)
  121091. * @returns True if it has been started, otherwise false.
  121092. */
  121093. isStarted(): boolean;
  121094. /**
  121095. * Starts the particle system and begins to emit
  121096. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  121097. */
  121098. start(delay?: number): void;
  121099. /**
  121100. * Stops the particle system.
  121101. */
  121102. stop(): void;
  121103. /**
  121104. * Remove all active particles
  121105. */
  121106. reset(): void;
  121107. /**
  121108. * Returns the string "GPUParticleSystem"
  121109. * @returns a string containing the class name
  121110. */
  121111. getClassName(): string;
  121112. private _colorGradientsTexture;
  121113. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  121114. /**
  121115. * Adds a new color gradient
  121116. * @param gradient defines the gradient to use (between 0 and 1)
  121117. * @param color1 defines the color to affect to the specified gradient
  121118. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  121119. * @returns the current particle system
  121120. */
  121121. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  121122. /**
  121123. * Remove a specific color gradient
  121124. * @param gradient defines the gradient to remove
  121125. * @returns the current particle system
  121126. */
  121127. removeColorGradient(gradient: number): GPUParticleSystem;
  121128. private _angularSpeedGradientsTexture;
  121129. private _sizeGradientsTexture;
  121130. private _velocityGradientsTexture;
  121131. private _limitVelocityGradientsTexture;
  121132. private _dragGradientsTexture;
  121133. private _addFactorGradient;
  121134. /**
  121135. * Adds a new size gradient
  121136. * @param gradient defines the gradient to use (between 0 and 1)
  121137. * @param factor defines the size factor to affect to the specified gradient
  121138. * @returns the current particle system
  121139. */
  121140. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  121141. /**
  121142. * Remove a specific size gradient
  121143. * @param gradient defines the gradient to remove
  121144. * @returns the current particle system
  121145. */
  121146. removeSizeGradient(gradient: number): GPUParticleSystem;
  121147. /**
  121148. * Adds a new angular speed gradient
  121149. * @param gradient defines the gradient to use (between 0 and 1)
  121150. * @param factor defines the angular speed to affect to the specified gradient
  121151. * @returns the current particle system
  121152. */
  121153. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  121154. /**
  121155. * Remove a specific angular speed gradient
  121156. * @param gradient defines the gradient to remove
  121157. * @returns the current particle system
  121158. */
  121159. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  121160. /**
  121161. * Adds a new velocity gradient
  121162. * @param gradient defines the gradient to use (between 0 and 1)
  121163. * @param factor defines the velocity to affect to the specified gradient
  121164. * @returns the current particle system
  121165. */
  121166. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  121167. /**
  121168. * Remove a specific velocity gradient
  121169. * @param gradient defines the gradient to remove
  121170. * @returns the current particle system
  121171. */
  121172. removeVelocityGradient(gradient: number): GPUParticleSystem;
  121173. /**
  121174. * Adds a new limit velocity gradient
  121175. * @param gradient defines the gradient to use (between 0 and 1)
  121176. * @param factor defines the limit velocity value to affect to the specified gradient
  121177. * @returns the current particle system
  121178. */
  121179. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  121180. /**
  121181. * Remove a specific limit velocity gradient
  121182. * @param gradient defines the gradient to remove
  121183. * @returns the current particle system
  121184. */
  121185. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  121186. /**
  121187. * Adds a new drag gradient
  121188. * @param gradient defines the gradient to use (between 0 and 1)
  121189. * @param factor defines the drag value to affect to the specified gradient
  121190. * @returns the current particle system
  121191. */
  121192. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  121193. /**
  121194. * Remove a specific drag gradient
  121195. * @param gradient defines the gradient to remove
  121196. * @returns the current particle system
  121197. */
  121198. removeDragGradient(gradient: number): GPUParticleSystem;
  121199. /**
  121200. * Not supported by GPUParticleSystem
  121201. * @param gradient defines the gradient to use (between 0 and 1)
  121202. * @param factor defines the emit rate value to affect to the specified gradient
  121203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121204. * @returns the current particle system
  121205. */
  121206. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121207. /**
  121208. * Not supported by GPUParticleSystem
  121209. * @param gradient defines the gradient to remove
  121210. * @returns the current particle system
  121211. */
  121212. removeEmitRateGradient(gradient: number): IParticleSystem;
  121213. /**
  121214. * Not supported by GPUParticleSystem
  121215. * @param gradient defines the gradient to use (between 0 and 1)
  121216. * @param factor defines the start size value to affect to the specified gradient
  121217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121218. * @returns the current particle system
  121219. */
  121220. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121221. /**
  121222. * Not supported by GPUParticleSystem
  121223. * @param gradient defines the gradient to remove
  121224. * @returns the current particle system
  121225. */
  121226. removeStartSizeGradient(gradient: number): IParticleSystem;
  121227. /**
  121228. * Not supported by GPUParticleSystem
  121229. * @param gradient defines the gradient to use (between 0 and 1)
  121230. * @param min defines the color remap minimal range
  121231. * @param max defines the color remap maximal range
  121232. * @returns the current particle system
  121233. */
  121234. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  121235. /**
  121236. * Not supported by GPUParticleSystem
  121237. * @param gradient defines the gradient to remove
  121238. * @returns the current particle system
  121239. */
  121240. removeColorRemapGradient(): IParticleSystem;
  121241. /**
  121242. * Not supported by GPUParticleSystem
  121243. * @param gradient defines the gradient to use (between 0 and 1)
  121244. * @param min defines the alpha remap minimal range
  121245. * @param max defines the alpha remap maximal range
  121246. * @returns the current particle system
  121247. */
  121248. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  121249. /**
  121250. * Not supported by GPUParticleSystem
  121251. * @param gradient defines the gradient to remove
  121252. * @returns the current particle system
  121253. */
  121254. removeAlphaRemapGradient(): IParticleSystem;
  121255. /**
  121256. * Not supported by GPUParticleSystem
  121257. * @param gradient defines the gradient to use (between 0 and 1)
  121258. * @param color defines the color to affect to the specified gradient
  121259. * @returns the current particle system
  121260. */
  121261. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  121262. /**
  121263. * Not supported by GPUParticleSystem
  121264. * @param gradient defines the gradient to remove
  121265. * @returns the current particle system
  121266. */
  121267. removeRampGradient(): IParticleSystem;
  121268. /**
  121269. * Not supported by GPUParticleSystem
  121270. * @returns the list of ramp gradients
  121271. */
  121272. getRampGradients(): Nullable<Array<Color3Gradient>>;
  121273. /**
  121274. * Not supported by GPUParticleSystem
  121275. * Gets or sets a boolean indicating that ramp gradients must be used
  121276. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  121277. */
  121278. useRampGradients: boolean;
  121279. /**
  121280. * Not supported by GPUParticleSystem
  121281. * @param gradient defines the gradient to use (between 0 and 1)
  121282. * @param factor defines the life time factor to affect to the specified gradient
  121283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121284. * @returns the current particle system
  121285. */
  121286. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121287. /**
  121288. * Not supported by GPUParticleSystem
  121289. * @param gradient defines the gradient to remove
  121290. * @returns the current particle system
  121291. */
  121292. removeLifeTimeGradient(gradient: number): IParticleSystem;
  121293. /**
  121294. * Instantiates a GPU particle system.
  121295. * 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.
  121296. * @param name The name of the particle system
  121297. * @param options The options used to create the system
  121298. * @param scene The scene the particle system belongs to
  121299. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  121300. */
  121301. constructor(name: string, options: Partial<{
  121302. capacity: number;
  121303. randomTextureSize: number;
  121304. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  121305. protected _reset(): void;
  121306. private _createUpdateVAO;
  121307. private _createRenderVAO;
  121308. private _initialize;
  121309. /** @hidden */
  121310. _recreateUpdateEffect(): void;
  121311. /** @hidden */
  121312. _recreateRenderEffect(): void;
  121313. /**
  121314. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  121315. * @param preWarm defines if we are in the pre-warmimg phase
  121316. */
  121317. animate(preWarm?: boolean): void;
  121318. private _createFactorGradientTexture;
  121319. private _createSizeGradientTexture;
  121320. private _createAngularSpeedGradientTexture;
  121321. private _createVelocityGradientTexture;
  121322. private _createLimitVelocityGradientTexture;
  121323. private _createDragGradientTexture;
  121324. private _createColorGradientTexture;
  121325. /**
  121326. * Renders the particle system in its current state
  121327. * @param preWarm defines if the system should only update the particles but not render them
  121328. * @returns the current number of particles
  121329. */
  121330. render(preWarm?: boolean): number;
  121331. /**
  121332. * Rebuilds the particle system
  121333. */
  121334. rebuild(): void;
  121335. private _releaseBuffers;
  121336. private _releaseVAOs;
  121337. /**
  121338. * Disposes the particle system and free the associated resources
  121339. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  121340. */
  121341. dispose(disposeTexture?: boolean): void;
  121342. /**
  121343. * Clones the particle system.
  121344. * @param name The name of the cloned object
  121345. * @param newEmitter The new emitter to use
  121346. * @returns the cloned particle system
  121347. */
  121348. clone(name: string, newEmitter: any): GPUParticleSystem;
  121349. /**
  121350. * Serializes the particle system to a JSON object.
  121351. * @returns the JSON object
  121352. */
  121353. serialize(): any;
  121354. /**
  121355. * Parses a JSON object to create a GPU particle system.
  121356. * @param parsedParticleSystem The JSON object to parse
  121357. * @param scene The scene to create the particle system in
  121358. * @param rootUrl The root url to use to load external dependencies like texture
  121359. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  121360. * @returns the parsed GPU particle system
  121361. */
  121362. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  121363. }
  121364. }
  121365. declare module BABYLON {
  121366. /**
  121367. * Represents a set of particle systems working together to create a specific effect
  121368. */
  121369. export class ParticleSystemSet implements IDisposable {
  121370. private _emitterCreationOptions;
  121371. private _emitterNode;
  121372. /**
  121373. * Gets the particle system list
  121374. */
  121375. systems: IParticleSystem[];
  121376. /**
  121377. * Gets the emitter node used with this set
  121378. */
  121379. readonly emitterNode: Nullable<TransformNode>;
  121380. /**
  121381. * Creates a new emitter mesh as a sphere
  121382. * @param options defines the options used to create the sphere
  121383. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  121384. * @param scene defines the hosting scene
  121385. */
  121386. setEmitterAsSphere(options: {
  121387. diameter: number;
  121388. segments: number;
  121389. color: Color3;
  121390. }, renderingGroupId: number, scene: Scene): void;
  121391. /**
  121392. * Starts all particle systems of the set
  121393. * @param emitter defines an optional mesh to use as emitter for the particle systems
  121394. */
  121395. start(emitter?: AbstractMesh): void;
  121396. /**
  121397. * Release all associated resources
  121398. */
  121399. dispose(): void;
  121400. /**
  121401. * Serialize the set into a JSON compatible object
  121402. * @returns a JSON compatible representation of the set
  121403. */
  121404. serialize(): any;
  121405. /**
  121406. * Parse a new ParticleSystemSet from a serialized source
  121407. * @param data defines a JSON compatible representation of the set
  121408. * @param scene defines the hosting scene
  121409. * @param gpu defines if we want GPU particles or CPU particles
  121410. * @returns a new ParticleSystemSet
  121411. */
  121412. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  121413. }
  121414. }
  121415. declare module BABYLON {
  121416. /**
  121417. * This class is made for on one-liner static method to help creating particle system set.
  121418. */
  121419. export class ParticleHelper {
  121420. /**
  121421. * Gets or sets base Assets URL
  121422. */
  121423. static BaseAssetsUrl: string;
  121424. /**
  121425. * Create a default particle system that you can tweak
  121426. * @param emitter defines the emitter to use
  121427. * @param capacity defines the system capacity (default is 500 particles)
  121428. * @param scene defines the hosting scene
  121429. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  121430. * @returns the new Particle system
  121431. */
  121432. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  121433. /**
  121434. * This is the main static method (one-liner) of this helper to create different particle systems
  121435. * @param type This string represents the type to the particle system to create
  121436. * @param scene The scene where the particle system should live
  121437. * @param gpu If the system will use gpu
  121438. * @returns the ParticleSystemSet created
  121439. */
  121440. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  121441. /**
  121442. * Static function used to export a particle system to a ParticleSystemSet variable.
  121443. * Please note that the emitter shape is not exported
  121444. * @param systems defines the particle systems to export
  121445. * @returns the created particle system set
  121446. */
  121447. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  121448. }
  121449. }
  121450. declare module BABYLON {
  121451. interface Engine {
  121452. /**
  121453. * Create an effect to use with particle systems.
  121454. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  121455. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  121456. * @param uniformsNames defines a list of attribute names
  121457. * @param samplers defines an array of string used to represent textures
  121458. * @param defines defines the string containing the defines to use to compile the shaders
  121459. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  121460. * @param onCompiled defines a function to call when the effect creation is successful
  121461. * @param onError defines a function to call when the effect creation has failed
  121462. * @returns the new Effect
  121463. */
  121464. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  121465. }
  121466. interface Mesh {
  121467. /**
  121468. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  121469. * @returns an array of IParticleSystem
  121470. */
  121471. getEmittedParticleSystems(): IParticleSystem[];
  121472. /**
  121473. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  121474. * @returns an array of IParticleSystem
  121475. */
  121476. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  121477. }
  121478. /**
  121479. * @hidden
  121480. */
  121481. export var _IDoNeedToBeInTheBuild: number;
  121482. }
  121483. declare module BABYLON {
  121484. interface Scene {
  121485. /** @hidden (Backing field) */
  121486. _physicsEngine: Nullable<IPhysicsEngine>;
  121487. /**
  121488. * Gets the current physics engine
  121489. * @returns a IPhysicsEngine or null if none attached
  121490. */
  121491. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  121492. /**
  121493. * Enables physics to the current scene
  121494. * @param gravity defines the scene's gravity for the physics engine
  121495. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  121496. * @return a boolean indicating if the physics engine was initialized
  121497. */
  121498. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  121499. /**
  121500. * Disables and disposes the physics engine associated with the scene
  121501. */
  121502. disablePhysicsEngine(): void;
  121503. /**
  121504. * Gets a boolean indicating if there is an active physics engine
  121505. * @returns a boolean indicating if there is an active physics engine
  121506. */
  121507. isPhysicsEnabled(): boolean;
  121508. /**
  121509. * Deletes a physics compound impostor
  121510. * @param compound defines the compound to delete
  121511. */
  121512. deleteCompoundImpostor(compound: any): void;
  121513. /**
  121514. * An event triggered when physic simulation is about to be run
  121515. */
  121516. onBeforePhysicsObservable: Observable<Scene>;
  121517. /**
  121518. * An event triggered when physic simulation has been done
  121519. */
  121520. onAfterPhysicsObservable: Observable<Scene>;
  121521. }
  121522. interface AbstractMesh {
  121523. /** @hidden */
  121524. _physicsImpostor: Nullable<PhysicsImpostor>;
  121525. /**
  121526. * Gets or sets impostor used for physic simulation
  121527. * @see http://doc.babylonjs.com/features/physics_engine
  121528. */
  121529. physicsImpostor: Nullable<PhysicsImpostor>;
  121530. /**
  121531. * Gets the current physics impostor
  121532. * @see http://doc.babylonjs.com/features/physics_engine
  121533. * @returns a physics impostor or null
  121534. */
  121535. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  121536. /** Apply a physic impulse to the mesh
  121537. * @param force defines the force to apply
  121538. * @param contactPoint defines where to apply the force
  121539. * @returns the current mesh
  121540. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  121541. */
  121542. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  121543. /**
  121544. * Creates a physic joint between two meshes
  121545. * @param otherMesh defines the other mesh to use
  121546. * @param pivot1 defines the pivot to use on this mesh
  121547. * @param pivot2 defines the pivot to use on the other mesh
  121548. * @param options defines additional options (can be plugin dependent)
  121549. * @returns the current mesh
  121550. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  121551. */
  121552. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  121553. /** @hidden */
  121554. _disposePhysicsObserver: Nullable<Observer<Node>>;
  121555. }
  121556. /**
  121557. * Defines the physics engine scene component responsible to manage a physics engine
  121558. */
  121559. export class PhysicsEngineSceneComponent implements ISceneComponent {
  121560. /**
  121561. * The component name helpful to identify the component in the list of scene components.
  121562. */
  121563. readonly name: string;
  121564. /**
  121565. * The scene the component belongs to.
  121566. */
  121567. scene: Scene;
  121568. /**
  121569. * Creates a new instance of the component for the given scene
  121570. * @param scene Defines the scene to register the component in
  121571. */
  121572. constructor(scene: Scene);
  121573. /**
  121574. * Registers the component in a given scene
  121575. */
  121576. register(): void;
  121577. /**
  121578. * Rebuilds the elements related to this component in case of
  121579. * context lost for instance.
  121580. */
  121581. rebuild(): void;
  121582. /**
  121583. * Disposes the component and the associated ressources
  121584. */
  121585. dispose(): void;
  121586. }
  121587. }
  121588. declare module BABYLON {
  121589. /**
  121590. * A helper for physics simulations
  121591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121592. */
  121593. export class PhysicsHelper {
  121594. private _scene;
  121595. private _physicsEngine;
  121596. /**
  121597. * Initializes the Physics helper
  121598. * @param scene Babylon.js scene
  121599. */
  121600. constructor(scene: Scene);
  121601. /**
  121602. * Applies a radial explosion impulse
  121603. * @param origin the origin of the explosion
  121604. * @param radiusOrEventOptions the radius or the options of radial explosion
  121605. * @param strength the explosion strength
  121606. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121607. * @returns A physics radial explosion event, or null
  121608. */
  121609. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121610. /**
  121611. * Applies a radial explosion force
  121612. * @param origin the origin of the explosion
  121613. * @param radiusOrEventOptions the radius or the options of radial explosion
  121614. * @param strength the explosion strength
  121615. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121616. * @returns A physics radial explosion event, or null
  121617. */
  121618. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121619. /**
  121620. * Creates a gravitational field
  121621. * @param origin the origin of the explosion
  121622. * @param radiusOrEventOptions the radius or the options of radial explosion
  121623. * @param strength the explosion strength
  121624. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121625. * @returns A physics gravitational field event, or null
  121626. */
  121627. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  121628. /**
  121629. * Creates a physics updraft event
  121630. * @param origin the origin of the updraft
  121631. * @param radiusOrEventOptions the radius or the options of the updraft
  121632. * @param strength the strength of the updraft
  121633. * @param height the height of the updraft
  121634. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  121635. * @returns A physics updraft event, or null
  121636. */
  121637. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  121638. /**
  121639. * Creates a physics vortex event
  121640. * @param origin the of the vortex
  121641. * @param radiusOrEventOptions the radius or the options of the vortex
  121642. * @param strength the strength of the vortex
  121643. * @param height the height of the vortex
  121644. * @returns a Physics vortex event, or null
  121645. * A physics vortex event or null
  121646. */
  121647. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  121648. }
  121649. /**
  121650. * Represents a physics radial explosion event
  121651. */
  121652. class PhysicsRadialExplosionEvent {
  121653. private _scene;
  121654. private _options;
  121655. private _sphere;
  121656. private _dataFetched;
  121657. /**
  121658. * Initializes a radial explosioin event
  121659. * @param _scene BabylonJS scene
  121660. * @param _options The options for the vortex event
  121661. */
  121662. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  121663. /**
  121664. * Returns the data related to the radial explosion event (sphere).
  121665. * @returns The radial explosion event data
  121666. */
  121667. getData(): PhysicsRadialExplosionEventData;
  121668. /**
  121669. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  121670. * @param impostor A physics imposter
  121671. * @param origin the origin of the explosion
  121672. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  121673. */
  121674. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  121675. /**
  121676. * Triggers affecterd impostors callbacks
  121677. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  121678. */
  121679. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  121680. /**
  121681. * Disposes the sphere.
  121682. * @param force Specifies if the sphere should be disposed by force
  121683. */
  121684. dispose(force?: boolean): void;
  121685. /*** Helpers ***/
  121686. private _prepareSphere;
  121687. private _intersectsWithSphere;
  121688. }
  121689. /**
  121690. * Represents a gravitational field event
  121691. */
  121692. class PhysicsGravitationalFieldEvent {
  121693. private _physicsHelper;
  121694. private _scene;
  121695. private _origin;
  121696. private _options;
  121697. private _tickCallback;
  121698. private _sphere;
  121699. private _dataFetched;
  121700. /**
  121701. * Initializes the physics gravitational field event
  121702. * @param _physicsHelper A physics helper
  121703. * @param _scene BabylonJS scene
  121704. * @param _origin The origin position of the gravitational field event
  121705. * @param _options The options for the vortex event
  121706. */
  121707. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  121708. /**
  121709. * Returns the data related to the gravitational field event (sphere).
  121710. * @returns A gravitational field event
  121711. */
  121712. getData(): PhysicsGravitationalFieldEventData;
  121713. /**
  121714. * Enables the gravitational field.
  121715. */
  121716. enable(): void;
  121717. /**
  121718. * Disables the gravitational field.
  121719. */
  121720. disable(): void;
  121721. /**
  121722. * Disposes the sphere.
  121723. * @param force The force to dispose from the gravitational field event
  121724. */
  121725. dispose(force?: boolean): void;
  121726. private _tick;
  121727. }
  121728. /**
  121729. * Represents a physics updraft event
  121730. */
  121731. class PhysicsUpdraftEvent {
  121732. private _scene;
  121733. private _origin;
  121734. private _options;
  121735. private _physicsEngine;
  121736. private _originTop;
  121737. private _originDirection;
  121738. private _tickCallback;
  121739. private _cylinder;
  121740. private _cylinderPosition;
  121741. private _dataFetched;
  121742. /**
  121743. * Initializes the physics updraft event
  121744. * @param _scene BabylonJS scene
  121745. * @param _origin The origin position of the updraft
  121746. * @param _options The options for the updraft event
  121747. */
  121748. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  121749. /**
  121750. * Returns the data related to the updraft event (cylinder).
  121751. * @returns A physics updraft event
  121752. */
  121753. getData(): PhysicsUpdraftEventData;
  121754. /**
  121755. * Enables the updraft.
  121756. */
  121757. enable(): void;
  121758. /**
  121759. * Disables the updraft.
  121760. */
  121761. disable(): void;
  121762. /**
  121763. * Disposes the cylinder.
  121764. * @param force Specifies if the updraft should be disposed by force
  121765. */
  121766. dispose(force?: boolean): void;
  121767. private getImpostorHitData;
  121768. private _tick;
  121769. /*** Helpers ***/
  121770. private _prepareCylinder;
  121771. private _intersectsWithCylinder;
  121772. }
  121773. /**
  121774. * Represents a physics vortex event
  121775. */
  121776. class PhysicsVortexEvent {
  121777. private _scene;
  121778. private _origin;
  121779. private _options;
  121780. private _physicsEngine;
  121781. private _originTop;
  121782. private _tickCallback;
  121783. private _cylinder;
  121784. private _cylinderPosition;
  121785. private _dataFetched;
  121786. /**
  121787. * Initializes the physics vortex event
  121788. * @param _scene The BabylonJS scene
  121789. * @param _origin The origin position of the vortex
  121790. * @param _options The options for the vortex event
  121791. */
  121792. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  121793. /**
  121794. * Returns the data related to the vortex event (cylinder).
  121795. * @returns The physics vortex event data
  121796. */
  121797. getData(): PhysicsVortexEventData;
  121798. /**
  121799. * Enables the vortex.
  121800. */
  121801. enable(): void;
  121802. /**
  121803. * Disables the cortex.
  121804. */
  121805. disable(): void;
  121806. /**
  121807. * Disposes the sphere.
  121808. * @param force
  121809. */
  121810. dispose(force?: boolean): void;
  121811. private getImpostorHitData;
  121812. private _tick;
  121813. /*** Helpers ***/
  121814. private _prepareCylinder;
  121815. private _intersectsWithCylinder;
  121816. }
  121817. /**
  121818. * Options fot the radial explosion event
  121819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121820. */
  121821. export class PhysicsRadialExplosionEventOptions {
  121822. /**
  121823. * The radius of the sphere for the radial explosion.
  121824. */
  121825. radius: number;
  121826. /**
  121827. * The strenth of the explosion.
  121828. */
  121829. strength: number;
  121830. /**
  121831. * The strenght of the force in correspondence to the distance of the affected object
  121832. */
  121833. falloff: PhysicsRadialImpulseFalloff;
  121834. /**
  121835. * Sphere options for the radial explosion.
  121836. */
  121837. sphere: {
  121838. segments: number;
  121839. diameter: number;
  121840. };
  121841. /**
  121842. * Sphere options for the radial explosion.
  121843. */
  121844. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  121845. }
  121846. /**
  121847. * Options fot the updraft event
  121848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121849. */
  121850. export class PhysicsUpdraftEventOptions {
  121851. /**
  121852. * The radius of the cylinder for the vortex
  121853. */
  121854. radius: number;
  121855. /**
  121856. * The strenth of the updraft.
  121857. */
  121858. strength: number;
  121859. /**
  121860. * The height of the cylinder for the updraft.
  121861. */
  121862. height: number;
  121863. /**
  121864. * The mode for the the updraft.
  121865. */
  121866. updraftMode: PhysicsUpdraftMode;
  121867. }
  121868. /**
  121869. * Options fot the vortex event
  121870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121871. */
  121872. export class PhysicsVortexEventOptions {
  121873. /**
  121874. * The radius of the cylinder for the vortex
  121875. */
  121876. radius: number;
  121877. /**
  121878. * The strenth of the vortex.
  121879. */
  121880. strength: number;
  121881. /**
  121882. * The height of the cylinder for the vortex.
  121883. */
  121884. height: number;
  121885. /**
  121886. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  121887. */
  121888. centripetalForceThreshold: number;
  121889. /**
  121890. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  121891. */
  121892. centripetalForceMultiplier: number;
  121893. /**
  121894. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  121895. */
  121896. centrifugalForceMultiplier: number;
  121897. /**
  121898. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  121899. */
  121900. updraftForceMultiplier: number;
  121901. }
  121902. /**
  121903. * The strenght of the force in correspondence to the distance of the affected object
  121904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121905. */
  121906. export enum PhysicsRadialImpulseFalloff {
  121907. /** Defines that impulse is constant in strength across it's whole radius */
  121908. Constant = 0,
  121909. /** Defines that impulse gets weaker if it's further from the origin */
  121910. Linear = 1
  121911. }
  121912. /**
  121913. * The strength of the force in correspondence to the distance of the affected object
  121914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121915. */
  121916. export enum PhysicsUpdraftMode {
  121917. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  121918. Center = 0,
  121919. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  121920. Perpendicular = 1
  121921. }
  121922. /**
  121923. * Interface for a physics hit data
  121924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121925. */
  121926. export interface PhysicsHitData {
  121927. /**
  121928. * The force applied at the contact point
  121929. */
  121930. force: Vector3;
  121931. /**
  121932. * The contact point
  121933. */
  121934. contactPoint: Vector3;
  121935. /**
  121936. * The distance from the origin to the contact point
  121937. */
  121938. distanceFromOrigin: number;
  121939. }
  121940. /**
  121941. * Interface for radial explosion event data
  121942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121943. */
  121944. export interface PhysicsRadialExplosionEventData {
  121945. /**
  121946. * A sphere used for the radial explosion event
  121947. */
  121948. sphere: Mesh;
  121949. }
  121950. /**
  121951. * Interface for gravitational field event data
  121952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121953. */
  121954. export interface PhysicsGravitationalFieldEventData {
  121955. /**
  121956. * A sphere mesh used for the gravitational field event
  121957. */
  121958. sphere: Mesh;
  121959. }
  121960. /**
  121961. * Interface for updraft event data
  121962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121963. */
  121964. export interface PhysicsUpdraftEventData {
  121965. /**
  121966. * A cylinder used for the updraft event
  121967. */
  121968. cylinder: Mesh;
  121969. }
  121970. /**
  121971. * Interface for vortex event data
  121972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121973. */
  121974. export interface PhysicsVortexEventData {
  121975. /**
  121976. * A cylinder used for the vortex event
  121977. */
  121978. cylinder: Mesh;
  121979. }
  121980. /**
  121981. * Interface for an affected physics impostor
  121982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121983. */
  121984. export interface PhysicsAffectedImpostorWithData {
  121985. /**
  121986. * The impostor affected by the effect
  121987. */
  121988. impostor: PhysicsImpostor;
  121989. /**
  121990. * The data about the hit/horce from the explosion
  121991. */
  121992. hitData: PhysicsHitData;
  121993. }
  121994. }
  121995. declare module BABYLON {
  121996. /** @hidden */
  121997. export var blackAndWhitePixelShader: {
  121998. name: string;
  121999. shader: string;
  122000. };
  122001. }
  122002. declare module BABYLON {
  122003. /**
  122004. * Post process used to render in black and white
  122005. */
  122006. export class BlackAndWhitePostProcess extends PostProcess {
  122007. /**
  122008. * Linear about to convert he result to black and white (default: 1)
  122009. */
  122010. degree: number;
  122011. /**
  122012. * Creates a black and white post process
  122013. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  122014. * @param name The name of the effect.
  122015. * @param options The required width/height ratio to downsize to before computing the render pass.
  122016. * @param camera The camera to apply the render pass to.
  122017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122018. * @param engine The engine which the post process will be applied. (default: current engine)
  122019. * @param reusable If the post process can be reused on the same frame. (default: false)
  122020. */
  122021. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122022. }
  122023. }
  122024. declare module BABYLON {
  122025. /**
  122026. * This represents a set of one or more post processes in Babylon.
  122027. * A post process can be used to apply a shader to a texture after it is rendered.
  122028. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122029. */
  122030. export class PostProcessRenderEffect {
  122031. private _postProcesses;
  122032. private _getPostProcesses;
  122033. private _singleInstance;
  122034. private _cameras;
  122035. private _indicesForCamera;
  122036. /**
  122037. * Name of the effect
  122038. * @hidden
  122039. */
  122040. _name: string;
  122041. /**
  122042. * Instantiates a post process render effect.
  122043. * A post process can be used to apply a shader to a texture after it is rendered.
  122044. * @param engine The engine the effect is tied to
  122045. * @param name The name of the effect
  122046. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  122047. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  122048. */
  122049. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  122050. /**
  122051. * Checks if all the post processes in the effect are supported.
  122052. */
  122053. readonly isSupported: boolean;
  122054. /**
  122055. * Updates the current state of the effect
  122056. * @hidden
  122057. */
  122058. _update(): void;
  122059. /**
  122060. * Attaches the effect on cameras
  122061. * @param cameras The camera to attach to.
  122062. * @hidden
  122063. */
  122064. _attachCameras(cameras: Camera): void;
  122065. /**
  122066. * Attaches the effect on cameras
  122067. * @param cameras The camera to attach to.
  122068. * @hidden
  122069. */
  122070. _attachCameras(cameras: Camera[]): void;
  122071. /**
  122072. * Detaches the effect on cameras
  122073. * @param cameras The camera to detatch from.
  122074. * @hidden
  122075. */
  122076. _detachCameras(cameras: Camera): void;
  122077. /**
  122078. * Detatches the effect on cameras
  122079. * @param cameras The camera to detatch from.
  122080. * @hidden
  122081. */
  122082. _detachCameras(cameras: Camera[]): void;
  122083. /**
  122084. * Enables the effect on given cameras
  122085. * @param cameras The camera to enable.
  122086. * @hidden
  122087. */
  122088. _enable(cameras: Camera): void;
  122089. /**
  122090. * Enables the effect on given cameras
  122091. * @param cameras The camera to enable.
  122092. * @hidden
  122093. */
  122094. _enable(cameras: Nullable<Camera[]>): void;
  122095. /**
  122096. * Disables the effect on the given cameras
  122097. * @param cameras The camera to disable.
  122098. * @hidden
  122099. */
  122100. _disable(cameras: Camera): void;
  122101. /**
  122102. * Disables the effect on the given cameras
  122103. * @param cameras The camera to disable.
  122104. * @hidden
  122105. */
  122106. _disable(cameras: Nullable<Camera[]>): void;
  122107. /**
  122108. * Gets a list of the post processes contained in the effect.
  122109. * @param camera The camera to get the post processes on.
  122110. * @returns The list of the post processes in the effect.
  122111. */
  122112. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  122113. }
  122114. }
  122115. declare module BABYLON {
  122116. /** @hidden */
  122117. export var extractHighlightsPixelShader: {
  122118. name: string;
  122119. shader: string;
  122120. };
  122121. }
  122122. declare module BABYLON {
  122123. /**
  122124. * 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.
  122125. */
  122126. export class ExtractHighlightsPostProcess extends PostProcess {
  122127. /**
  122128. * The luminance threshold, pixels below this value will be set to black.
  122129. */
  122130. threshold: number;
  122131. /** @hidden */
  122132. _exposure: number;
  122133. /**
  122134. * Post process which has the input texture to be used when performing highlight extraction
  122135. * @hidden
  122136. */
  122137. _inputPostProcess: Nullable<PostProcess>;
  122138. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122139. }
  122140. }
  122141. declare module BABYLON {
  122142. /** @hidden */
  122143. export var bloomMergePixelShader: {
  122144. name: string;
  122145. shader: string;
  122146. };
  122147. }
  122148. declare module BABYLON {
  122149. /**
  122150. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122151. */
  122152. export class BloomMergePostProcess extends PostProcess {
  122153. /** Weight of the bloom to be added to the original input. */
  122154. weight: number;
  122155. /**
  122156. * Creates a new instance of @see BloomMergePostProcess
  122157. * @param name The name of the effect.
  122158. * @param originalFromInput Post process which's input will be used for the merge.
  122159. * @param blurred Blurred highlights post process which's output will be used.
  122160. * @param weight Weight of the bloom to be added to the original input.
  122161. * @param options The required width/height ratio to downsize to before computing the render pass.
  122162. * @param camera The camera to apply the render pass to.
  122163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122164. * @param engine The engine which the post process will be applied. (default: current engine)
  122165. * @param reusable If the post process can be reused on the same frame. (default: false)
  122166. * @param textureType Type of textures used when performing the post process. (default: 0)
  122167. * @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)
  122168. */
  122169. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  122170. /** Weight of the bloom to be added to the original input. */
  122171. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122172. }
  122173. }
  122174. declare module BABYLON {
  122175. /**
  122176. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  122177. */
  122178. export class BloomEffect extends PostProcessRenderEffect {
  122179. private bloomScale;
  122180. /**
  122181. * @hidden Internal
  122182. */
  122183. _effects: Array<PostProcess>;
  122184. /**
  122185. * @hidden Internal
  122186. */
  122187. _downscale: ExtractHighlightsPostProcess;
  122188. private _blurX;
  122189. private _blurY;
  122190. private _merge;
  122191. /**
  122192. * The luminance threshold to find bright areas of the image to bloom.
  122193. */
  122194. threshold: number;
  122195. /**
  122196. * The strength of the bloom.
  122197. */
  122198. weight: number;
  122199. /**
  122200. * Specifies the size of the bloom blur kernel, relative to the final output size
  122201. */
  122202. kernel: number;
  122203. /**
  122204. * Creates a new instance of @see BloomEffect
  122205. * @param scene The scene the effect belongs to.
  122206. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  122207. * @param bloomKernel The size of the kernel to be used when applying the blur.
  122208. * @param bloomWeight The the strength of bloom.
  122209. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122210. * @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)
  122211. */
  122212. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  122213. /**
  122214. * Disposes each of the internal effects for a given camera.
  122215. * @param camera The camera to dispose the effect on.
  122216. */
  122217. disposeEffects(camera: Camera): void;
  122218. /**
  122219. * @hidden Internal
  122220. */
  122221. _updateEffects(): void;
  122222. /**
  122223. * Internal
  122224. * @returns if all the contained post processes are ready.
  122225. * @hidden
  122226. */
  122227. _isReady(): boolean;
  122228. }
  122229. }
  122230. declare module BABYLON {
  122231. /** @hidden */
  122232. export var chromaticAberrationPixelShader: {
  122233. name: string;
  122234. shader: string;
  122235. };
  122236. }
  122237. declare module BABYLON {
  122238. /**
  122239. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  122240. */
  122241. export class ChromaticAberrationPostProcess extends PostProcess {
  122242. /**
  122243. * The amount of seperation of rgb channels (default: 30)
  122244. */
  122245. aberrationAmount: number;
  122246. /**
  122247. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  122248. */
  122249. radialIntensity: number;
  122250. /**
  122251. * 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))
  122252. */
  122253. direction: Vector2;
  122254. /**
  122255. * 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))
  122256. */
  122257. centerPosition: Vector2;
  122258. /**
  122259. * Creates a new instance ChromaticAberrationPostProcess
  122260. * @param name The name of the effect.
  122261. * @param screenWidth The width of the screen to apply the effect on.
  122262. * @param screenHeight The height of the screen to apply the effect on.
  122263. * @param options The required width/height ratio to downsize to before computing the render pass.
  122264. * @param camera The camera to apply the render pass to.
  122265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122266. * @param engine The engine which the post process will be applied. (default: current engine)
  122267. * @param reusable If the post process can be reused on the same frame. (default: false)
  122268. * @param textureType Type of textures used when performing the post process. (default: 0)
  122269. * @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)
  122270. */
  122271. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122272. }
  122273. }
  122274. declare module BABYLON {
  122275. /** @hidden */
  122276. export var circleOfConfusionPixelShader: {
  122277. name: string;
  122278. shader: string;
  122279. };
  122280. }
  122281. declare module BABYLON {
  122282. /**
  122283. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  122284. */
  122285. export class CircleOfConfusionPostProcess extends PostProcess {
  122286. /**
  122287. * 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.
  122288. */
  122289. lensSize: number;
  122290. /**
  122291. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122292. */
  122293. fStop: number;
  122294. /**
  122295. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122296. */
  122297. focusDistance: number;
  122298. /**
  122299. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  122300. */
  122301. focalLength: number;
  122302. private _depthTexture;
  122303. /**
  122304. * Creates a new instance CircleOfConfusionPostProcess
  122305. * @param name The name of the effect.
  122306. * @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.
  122307. * @param options The required width/height ratio to downsize to before computing the render pass.
  122308. * @param camera The camera to apply the render pass to.
  122309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122310. * @param engine The engine which the post process will be applied. (default: current engine)
  122311. * @param reusable If the post process can be reused on the same frame. (default: false)
  122312. * @param textureType Type of textures used when performing the post process. (default: 0)
  122313. * @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)
  122314. */
  122315. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122316. /**
  122317. * 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.
  122318. */
  122319. depthTexture: RenderTargetTexture;
  122320. }
  122321. }
  122322. declare module BABYLON {
  122323. /** @hidden */
  122324. export var colorCorrectionPixelShader: {
  122325. name: string;
  122326. shader: string;
  122327. };
  122328. }
  122329. declare module BABYLON {
  122330. /**
  122331. *
  122332. * This post-process allows the modification of rendered colors by using
  122333. * a 'look-up table' (LUT). This effect is also called Color Grading.
  122334. *
  122335. * The object needs to be provided an url to a texture containing the color
  122336. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  122337. * Use an image editing software to tweak the LUT to match your needs.
  122338. *
  122339. * For an example of a color LUT, see here:
  122340. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  122341. * For explanations on color grading, see here:
  122342. * @see http://udn.epicgames.com/Three/ColorGrading.html
  122343. *
  122344. */
  122345. export class ColorCorrectionPostProcess extends PostProcess {
  122346. private _colorTableTexture;
  122347. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122348. }
  122349. }
  122350. declare module BABYLON {
  122351. /** @hidden */
  122352. export var convolutionPixelShader: {
  122353. name: string;
  122354. shader: string;
  122355. };
  122356. }
  122357. declare module BABYLON {
  122358. /**
  122359. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  122360. * input texture to perform effects such as edge detection or sharpening
  122361. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  122362. */
  122363. export class ConvolutionPostProcess extends PostProcess {
  122364. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  122365. kernel: number[];
  122366. /**
  122367. * Creates a new instance ConvolutionPostProcess
  122368. * @param name The name of the effect.
  122369. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  122370. * @param options The required width/height ratio to downsize to before computing the render pass.
  122371. * @param camera The camera to apply the render pass to.
  122372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122373. * @param engine The engine which the post process will be applied. (default: current engine)
  122374. * @param reusable If the post process can be reused on the same frame. (default: false)
  122375. * @param textureType Type of textures used when performing the post process. (default: 0)
  122376. */
  122377. constructor(name: string,
  122378. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  122379. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122380. /**
  122381. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122382. */
  122383. static EdgeDetect0Kernel: number[];
  122384. /**
  122385. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122386. */
  122387. static EdgeDetect1Kernel: number[];
  122388. /**
  122389. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122390. */
  122391. static EdgeDetect2Kernel: number[];
  122392. /**
  122393. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122394. */
  122395. static SharpenKernel: number[];
  122396. /**
  122397. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122398. */
  122399. static EmbossKernel: number[];
  122400. /**
  122401. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122402. */
  122403. static GaussianKernel: number[];
  122404. }
  122405. }
  122406. declare module BABYLON {
  122407. /**
  122408. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  122409. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  122410. * based on samples that have a large difference in distance than the center pixel.
  122411. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  122412. */
  122413. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  122414. direction: Vector2;
  122415. /**
  122416. * Creates a new instance CircleOfConfusionPostProcess
  122417. * @param name The name of the effect.
  122418. * @param scene The scene the effect belongs to.
  122419. * @param direction The direction the blur should be applied.
  122420. * @param kernel The size of the kernel used to blur.
  122421. * @param options The required width/height ratio to downsize to before computing the render pass.
  122422. * @param camera The camera to apply the render pass to.
  122423. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  122424. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  122425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122426. * @param engine The engine which the post process will be applied. (default: current engine)
  122427. * @param reusable If the post process can be reused on the same frame. (default: false)
  122428. * @param textureType Type of textures used when performing the post process. (default: 0)
  122429. * @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)
  122430. */
  122431. 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);
  122432. }
  122433. }
  122434. declare module BABYLON {
  122435. /** @hidden */
  122436. export var depthOfFieldMergePixelShader: {
  122437. name: string;
  122438. shader: string;
  122439. };
  122440. }
  122441. declare module BABYLON {
  122442. /**
  122443. * Options to be set when merging outputs from the default pipeline.
  122444. */
  122445. export class DepthOfFieldMergePostProcessOptions {
  122446. /**
  122447. * The original image to merge on top of
  122448. */
  122449. originalFromInput: PostProcess;
  122450. /**
  122451. * Parameters to perform the merge of the depth of field effect
  122452. */
  122453. depthOfField?: {
  122454. circleOfConfusion: PostProcess;
  122455. blurSteps: Array<PostProcess>;
  122456. };
  122457. /**
  122458. * Parameters to perform the merge of bloom effect
  122459. */
  122460. bloom?: {
  122461. blurred: PostProcess;
  122462. weight: number;
  122463. };
  122464. }
  122465. /**
  122466. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122467. */
  122468. export class DepthOfFieldMergePostProcess extends PostProcess {
  122469. private blurSteps;
  122470. /**
  122471. * Creates a new instance of DepthOfFieldMergePostProcess
  122472. * @param name The name of the effect.
  122473. * @param originalFromInput Post process which's input will be used for the merge.
  122474. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  122475. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  122476. * @param options The required width/height ratio to downsize to before computing the render pass.
  122477. * @param camera The camera to apply the render pass to.
  122478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122479. * @param engine The engine which the post process will be applied. (default: current engine)
  122480. * @param reusable If the post process can be reused on the same frame. (default: false)
  122481. * @param textureType Type of textures used when performing the post process. (default: 0)
  122482. * @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)
  122483. */
  122484. 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);
  122485. /**
  122486. * Updates the effect with the current post process compile time values and recompiles the shader.
  122487. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  122488. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  122489. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  122490. * @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
  122491. * @param onCompiled Called when the shader has been compiled.
  122492. * @param onError Called if there is an error when compiling a shader.
  122493. */
  122494. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  122495. }
  122496. }
  122497. declare module BABYLON {
  122498. /**
  122499. * Specifies the level of max blur that should be applied when using the depth of field effect
  122500. */
  122501. export enum DepthOfFieldEffectBlurLevel {
  122502. /**
  122503. * Subtle blur
  122504. */
  122505. Low = 0,
  122506. /**
  122507. * Medium blur
  122508. */
  122509. Medium = 1,
  122510. /**
  122511. * Large blur
  122512. */
  122513. High = 2
  122514. }
  122515. /**
  122516. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  122517. */
  122518. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  122519. private _circleOfConfusion;
  122520. /**
  122521. * @hidden Internal, blurs from high to low
  122522. */
  122523. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  122524. private _depthOfFieldBlurY;
  122525. private _dofMerge;
  122526. /**
  122527. * @hidden Internal post processes in depth of field effect
  122528. */
  122529. _effects: Array<PostProcess>;
  122530. /**
  122531. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  122532. */
  122533. focalLength: number;
  122534. /**
  122535. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122536. */
  122537. fStop: number;
  122538. /**
  122539. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122540. */
  122541. focusDistance: number;
  122542. /**
  122543. * 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.
  122544. */
  122545. lensSize: number;
  122546. /**
  122547. * Creates a new instance DepthOfFieldEffect
  122548. * @param scene The scene the effect belongs to.
  122549. * @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.
  122550. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122551. * @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)
  122552. */
  122553. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  122554. /**
  122555. * Get the current class name of the current effet
  122556. * @returns "DepthOfFieldEffect"
  122557. */
  122558. getClassName(): string;
  122559. /**
  122560. * 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.
  122561. */
  122562. depthTexture: RenderTargetTexture;
  122563. /**
  122564. * Disposes each of the internal effects for a given camera.
  122565. * @param camera The camera to dispose the effect on.
  122566. */
  122567. disposeEffects(camera: Camera): void;
  122568. /**
  122569. * @hidden Internal
  122570. */
  122571. _updateEffects(): void;
  122572. /**
  122573. * Internal
  122574. * @returns if all the contained post processes are ready.
  122575. * @hidden
  122576. */
  122577. _isReady(): boolean;
  122578. }
  122579. }
  122580. declare module BABYLON {
  122581. /** @hidden */
  122582. export var displayPassPixelShader: {
  122583. name: string;
  122584. shader: string;
  122585. };
  122586. }
  122587. declare module BABYLON {
  122588. /**
  122589. * DisplayPassPostProcess which produces an output the same as it's input
  122590. */
  122591. export class DisplayPassPostProcess extends PostProcess {
  122592. /**
  122593. * Creates the DisplayPassPostProcess
  122594. * @param name The name of the effect.
  122595. * @param options The required width/height ratio to downsize to before computing the render pass.
  122596. * @param camera The camera to apply the render pass to.
  122597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122598. * @param engine The engine which the post process will be applied. (default: current engine)
  122599. * @param reusable If the post process can be reused on the same frame. (default: false)
  122600. */
  122601. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122602. }
  122603. }
  122604. declare module BABYLON {
  122605. /** @hidden */
  122606. export var filterPixelShader: {
  122607. name: string;
  122608. shader: string;
  122609. };
  122610. }
  122611. declare module BABYLON {
  122612. /**
  122613. * Applies a kernel filter to the image
  122614. */
  122615. export class FilterPostProcess extends PostProcess {
  122616. /** The matrix to be applied to the image */
  122617. kernelMatrix: Matrix;
  122618. /**
  122619. *
  122620. * @param name The name of the effect.
  122621. * @param kernelMatrix The matrix to be applied to the image
  122622. * @param options The required width/height ratio to downsize to before computing the render pass.
  122623. * @param camera The camera to apply the render pass to.
  122624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122625. * @param engine The engine which the post process will be applied. (default: current engine)
  122626. * @param reusable If the post process can be reused on the same frame. (default: false)
  122627. */
  122628. constructor(name: string,
  122629. /** The matrix to be applied to the image */
  122630. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122631. }
  122632. }
  122633. declare module BABYLON {
  122634. /** @hidden */
  122635. export var fxaaPixelShader: {
  122636. name: string;
  122637. shader: string;
  122638. };
  122639. }
  122640. declare module BABYLON {
  122641. /** @hidden */
  122642. export var fxaaVertexShader: {
  122643. name: string;
  122644. shader: string;
  122645. };
  122646. }
  122647. declare module BABYLON {
  122648. /**
  122649. * Fxaa post process
  122650. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  122651. */
  122652. export class FxaaPostProcess extends PostProcess {
  122653. /** @hidden */
  122654. texelWidth: number;
  122655. /** @hidden */
  122656. texelHeight: number;
  122657. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122658. private _getDefines;
  122659. }
  122660. }
  122661. declare module BABYLON {
  122662. /** @hidden */
  122663. export var grainPixelShader: {
  122664. name: string;
  122665. shader: string;
  122666. };
  122667. }
  122668. declare module BABYLON {
  122669. /**
  122670. * The GrainPostProcess adds noise to the image at mid luminance levels
  122671. */
  122672. export class GrainPostProcess extends PostProcess {
  122673. /**
  122674. * The intensity of the grain added (default: 30)
  122675. */
  122676. intensity: number;
  122677. /**
  122678. * If the grain should be randomized on every frame
  122679. */
  122680. animated: boolean;
  122681. /**
  122682. * Creates a new instance of @see GrainPostProcess
  122683. * @param name The name of the effect.
  122684. * @param options The required width/height ratio to downsize to before computing the render pass.
  122685. * @param camera The camera to apply the render pass to.
  122686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122687. * @param engine The engine which the post process will be applied. (default: current engine)
  122688. * @param reusable If the post process can be reused on the same frame. (default: false)
  122689. * @param textureType Type of textures used when performing the post process. (default: 0)
  122690. * @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)
  122691. */
  122692. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122693. }
  122694. }
  122695. declare module BABYLON {
  122696. /** @hidden */
  122697. export var highlightsPixelShader: {
  122698. name: string;
  122699. shader: string;
  122700. };
  122701. }
  122702. declare module BABYLON {
  122703. /**
  122704. * Extracts highlights from the image
  122705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122706. */
  122707. export class HighlightsPostProcess extends PostProcess {
  122708. /**
  122709. * Extracts highlights from the image
  122710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122711. * @param name The name of the effect.
  122712. * @param options The required width/height ratio to downsize to before computing the render pass.
  122713. * @param camera The camera to apply the render pass to.
  122714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122715. * @param engine The engine which the post process will be applied. (default: current engine)
  122716. * @param reusable If the post process can be reused on the same frame. (default: false)
  122717. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  122718. */
  122719. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122720. }
  122721. }
  122722. declare module BABYLON {
  122723. /** @hidden */
  122724. export var mrtFragmentDeclaration: {
  122725. name: string;
  122726. shader: string;
  122727. };
  122728. }
  122729. declare module BABYLON {
  122730. /** @hidden */
  122731. export var geometryPixelShader: {
  122732. name: string;
  122733. shader: string;
  122734. };
  122735. }
  122736. declare module BABYLON {
  122737. /** @hidden */
  122738. export var geometryVertexShader: {
  122739. name: string;
  122740. shader: string;
  122741. };
  122742. }
  122743. declare module BABYLON {
  122744. /** @hidden */
  122745. interface ISavedTransformationMatrix {
  122746. world: Matrix;
  122747. viewProjection: Matrix;
  122748. }
  122749. /**
  122750. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  122751. */
  122752. export class GeometryBufferRenderer {
  122753. /**
  122754. * Constant used to retrieve the position texture index in the G-Buffer textures array
  122755. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  122756. */
  122757. static readonly POSITION_TEXTURE_TYPE: number;
  122758. /**
  122759. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  122760. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  122761. */
  122762. static readonly VELOCITY_TEXTURE_TYPE: number;
  122763. /**
  122764. * Dictionary used to store the previous transformation matrices of each rendered mesh
  122765. * in order to compute objects velocities when enableVelocity is set to "true"
  122766. * @hidden
  122767. */
  122768. _previousTransformationMatrices: {
  122769. [index: number]: ISavedTransformationMatrix;
  122770. };
  122771. /**
  122772. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  122773. * in order to compute objects velocities when enableVelocity is set to "true"
  122774. * @hidden
  122775. */
  122776. _previousBonesTransformationMatrices: {
  122777. [index: number]: Float32Array;
  122778. };
  122779. /**
  122780. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  122781. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  122782. */
  122783. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  122784. private _scene;
  122785. private _multiRenderTarget;
  122786. private _ratio;
  122787. private _enablePosition;
  122788. private _enableVelocity;
  122789. private _positionIndex;
  122790. private _velocityIndex;
  122791. protected _effect: Effect;
  122792. protected _cachedDefines: string;
  122793. /**
  122794. * Set the render list (meshes to be rendered) used in the G buffer.
  122795. */
  122796. renderList: Mesh[];
  122797. /**
  122798. * Gets wether or not G buffer are supported by the running hardware.
  122799. * This requires draw buffer supports
  122800. */
  122801. readonly isSupported: boolean;
  122802. /**
  122803. * Returns the index of the given texture type in the G-Buffer textures array
  122804. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  122805. * @returns the index of the given texture type in the G-Buffer textures array
  122806. */
  122807. getTextureIndex(textureType: number): number;
  122808. /**
  122809. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  122810. */
  122811. /**
  122812. * Sets whether or not objects positions are enabled for the G buffer.
  122813. */
  122814. enablePosition: boolean;
  122815. /**
  122816. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  122817. */
  122818. /**
  122819. * Sets wether or not objects velocities are enabled for the G buffer.
  122820. */
  122821. enableVelocity: boolean;
  122822. /**
  122823. * Gets the scene associated with the buffer.
  122824. */
  122825. readonly scene: Scene;
  122826. /**
  122827. * Gets the ratio used by the buffer during its creation.
  122828. * How big is the buffer related to the main canvas.
  122829. */
  122830. readonly ratio: number;
  122831. /** @hidden */
  122832. static _SceneComponentInitialization: (scene: Scene) => void;
  122833. /**
  122834. * Creates a new G Buffer for the scene
  122835. * @param scene The scene the buffer belongs to
  122836. * @param ratio How big is the buffer related to the main canvas.
  122837. */
  122838. constructor(scene: Scene, ratio?: number);
  122839. /**
  122840. * Checks wether everything is ready to render a submesh to the G buffer.
  122841. * @param subMesh the submesh to check readiness for
  122842. * @param useInstances is the mesh drawn using instance or not
  122843. * @returns true if ready otherwise false
  122844. */
  122845. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122846. /**
  122847. * Gets the current underlying G Buffer.
  122848. * @returns the buffer
  122849. */
  122850. getGBuffer(): MultiRenderTarget;
  122851. /**
  122852. * Gets the number of samples used to render the buffer (anti aliasing).
  122853. */
  122854. /**
  122855. * Sets the number of samples used to render the buffer (anti aliasing).
  122856. */
  122857. samples: number;
  122858. /**
  122859. * Disposes the renderer and frees up associated resources.
  122860. */
  122861. dispose(): void;
  122862. protected _createRenderTargets(): void;
  122863. private _copyBonesTransformationMatrices;
  122864. }
  122865. }
  122866. declare module BABYLON {
  122867. interface Scene {
  122868. /** @hidden (Backing field) */
  122869. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122870. /**
  122871. * Gets or Sets the current geometry buffer associated to the scene.
  122872. */
  122873. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122874. /**
  122875. * Enables a GeometryBufferRender and associates it with the scene
  122876. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  122877. * @returns the GeometryBufferRenderer
  122878. */
  122879. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  122880. /**
  122881. * Disables the GeometryBufferRender associated with the scene
  122882. */
  122883. disableGeometryBufferRenderer(): void;
  122884. }
  122885. /**
  122886. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  122887. * in several rendering techniques.
  122888. */
  122889. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  122890. /**
  122891. * The component name helpful to identify the component in the list of scene components.
  122892. */
  122893. readonly name: string;
  122894. /**
  122895. * The scene the component belongs to.
  122896. */
  122897. scene: Scene;
  122898. /**
  122899. * Creates a new instance of the component for the given scene
  122900. * @param scene Defines the scene to register the component in
  122901. */
  122902. constructor(scene: Scene);
  122903. /**
  122904. * Registers the component in a given scene
  122905. */
  122906. register(): void;
  122907. /**
  122908. * Rebuilds the elements related to this component in case of
  122909. * context lost for instance.
  122910. */
  122911. rebuild(): void;
  122912. /**
  122913. * Disposes the component and the associated ressources
  122914. */
  122915. dispose(): void;
  122916. private _gatherRenderTargets;
  122917. }
  122918. }
  122919. declare module BABYLON {
  122920. /** @hidden */
  122921. export var motionBlurPixelShader: {
  122922. name: string;
  122923. shader: string;
  122924. };
  122925. }
  122926. declare module BABYLON {
  122927. /**
  122928. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  122929. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  122930. * As an example, all you have to do is to create the post-process:
  122931. * var mb = new BABYLON.MotionBlurPostProcess(
  122932. * 'mb', // The name of the effect.
  122933. * scene, // The scene containing the objects to blur according to their velocity.
  122934. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  122935. * camera // The camera to apply the render pass to.
  122936. * );
  122937. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  122938. */
  122939. export class MotionBlurPostProcess extends PostProcess {
  122940. /**
  122941. * Defines how much the image is blurred by the movement. Default value is equal to 1
  122942. */
  122943. motionStrength: number;
  122944. /**
  122945. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  122946. */
  122947. /**
  122948. * Sets the number of iterations to be used for motion blur quality
  122949. */
  122950. motionBlurSamples: number;
  122951. private _motionBlurSamples;
  122952. private _geometryBufferRenderer;
  122953. /**
  122954. * Creates a new instance MotionBlurPostProcess
  122955. * @param name The name of the effect.
  122956. * @param scene The scene containing the objects to blur according to their velocity.
  122957. * @param options The required width/height ratio to downsize to before computing the render pass.
  122958. * @param camera The camera to apply the render pass to.
  122959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122960. * @param engine The engine which the post process will be applied. (default: current engine)
  122961. * @param reusable If the post process can be reused on the same frame. (default: false)
  122962. * @param textureType Type of textures used when performing the post process. (default: 0)
  122963. * @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)
  122964. */
  122965. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122966. /**
  122967. * Excludes the given skinned mesh from computing bones velocities.
  122968. * 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.
  122969. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  122970. */
  122971. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122972. /**
  122973. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  122974. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  122975. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  122976. */
  122977. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122978. /**
  122979. * Disposes the post process.
  122980. * @param camera The camera to dispose the post process on.
  122981. */
  122982. dispose(camera?: Camera): void;
  122983. }
  122984. }
  122985. declare module BABYLON {
  122986. /** @hidden */
  122987. export var refractionPixelShader: {
  122988. name: string;
  122989. shader: string;
  122990. };
  122991. }
  122992. declare module BABYLON {
  122993. /**
  122994. * Post process which applies a refractin texture
  122995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  122996. */
  122997. export class RefractionPostProcess extends PostProcess {
  122998. /** the base color of the refraction (used to taint the rendering) */
  122999. color: Color3;
  123000. /** simulated refraction depth */
  123001. depth: number;
  123002. /** the coefficient of the base color (0 to remove base color tainting) */
  123003. colorLevel: number;
  123004. private _refTexture;
  123005. private _ownRefractionTexture;
  123006. /**
  123007. * Gets or sets the refraction texture
  123008. * Please note that you are responsible for disposing the texture if you set it manually
  123009. */
  123010. refractionTexture: Texture;
  123011. /**
  123012. * Initializes the RefractionPostProcess
  123013. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123014. * @param name The name of the effect.
  123015. * @param refractionTextureUrl Url of the refraction texture to use
  123016. * @param color the base color of the refraction (used to taint the rendering)
  123017. * @param depth simulated refraction depth
  123018. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  123019. * @param camera The camera to apply the render pass to.
  123020. * @param options The required width/height ratio to downsize to before computing the render pass.
  123021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123022. * @param engine The engine which the post process will be applied. (default: current engine)
  123023. * @param reusable If the post process can be reused on the same frame. (default: false)
  123024. */
  123025. constructor(name: string, refractionTextureUrl: string,
  123026. /** the base color of the refraction (used to taint the rendering) */
  123027. color: Color3,
  123028. /** simulated refraction depth */
  123029. depth: number,
  123030. /** the coefficient of the base color (0 to remove base color tainting) */
  123031. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123032. /**
  123033. * Disposes of the post process
  123034. * @param camera Camera to dispose post process on
  123035. */
  123036. dispose(camera: Camera): void;
  123037. }
  123038. }
  123039. declare module BABYLON {
  123040. /** @hidden */
  123041. export var sharpenPixelShader: {
  123042. name: string;
  123043. shader: string;
  123044. };
  123045. }
  123046. declare module BABYLON {
  123047. /**
  123048. * The SharpenPostProcess applies a sharpen kernel to every pixel
  123049. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123050. */
  123051. export class SharpenPostProcess extends PostProcess {
  123052. /**
  123053. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  123054. */
  123055. colorAmount: number;
  123056. /**
  123057. * How much sharpness should be applied (default: 0.3)
  123058. */
  123059. edgeAmount: number;
  123060. /**
  123061. * Creates a new instance ConvolutionPostProcess
  123062. * @param name The name of the effect.
  123063. * @param options The required width/height ratio to downsize to before computing the render pass.
  123064. * @param camera The camera to apply the render pass to.
  123065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123066. * @param engine The engine which the post process will be applied. (default: current engine)
  123067. * @param reusable If the post process can be reused on the same frame. (default: false)
  123068. * @param textureType Type of textures used when performing the post process. (default: 0)
  123069. * @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)
  123070. */
  123071. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123072. }
  123073. }
  123074. declare module BABYLON {
  123075. /**
  123076. * PostProcessRenderPipeline
  123077. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123078. */
  123079. export class PostProcessRenderPipeline {
  123080. private engine;
  123081. private _renderEffects;
  123082. private _renderEffectsForIsolatedPass;
  123083. /**
  123084. * List of inspectable custom properties (used by the Inspector)
  123085. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  123086. */
  123087. inspectableCustomProperties: IInspectable[];
  123088. /**
  123089. * @hidden
  123090. */
  123091. protected _cameras: Camera[];
  123092. /** @hidden */
  123093. _name: string;
  123094. /**
  123095. * Gets pipeline name
  123096. */
  123097. readonly name: string;
  123098. /**
  123099. * Initializes a PostProcessRenderPipeline
  123100. * @param engine engine to add the pipeline to
  123101. * @param name name of the pipeline
  123102. */
  123103. constructor(engine: Engine, name: string);
  123104. /**
  123105. * Gets the class name
  123106. * @returns "PostProcessRenderPipeline"
  123107. */
  123108. getClassName(): string;
  123109. /**
  123110. * If all the render effects in the pipeline are supported
  123111. */
  123112. readonly isSupported: boolean;
  123113. /**
  123114. * Adds an effect to the pipeline
  123115. * @param renderEffect the effect to add
  123116. */
  123117. addEffect(renderEffect: PostProcessRenderEffect): void;
  123118. /** @hidden */
  123119. _rebuild(): void;
  123120. /** @hidden */
  123121. _enableEffect(renderEffectName: string, cameras: Camera): void;
  123122. /** @hidden */
  123123. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  123124. /** @hidden */
  123125. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  123126. /** @hidden */
  123127. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  123128. /** @hidden */
  123129. _attachCameras(cameras: Camera, unique: boolean): void;
  123130. /** @hidden */
  123131. _attachCameras(cameras: Camera[], unique: boolean): void;
  123132. /** @hidden */
  123133. _detachCameras(cameras: Camera): void;
  123134. /** @hidden */
  123135. _detachCameras(cameras: Nullable<Camera[]>): void;
  123136. /** @hidden */
  123137. _update(): void;
  123138. /** @hidden */
  123139. _reset(): void;
  123140. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  123141. /**
  123142. * Disposes of the pipeline
  123143. */
  123144. dispose(): void;
  123145. }
  123146. }
  123147. declare module BABYLON {
  123148. /**
  123149. * PostProcessRenderPipelineManager class
  123150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123151. */
  123152. export class PostProcessRenderPipelineManager {
  123153. private _renderPipelines;
  123154. /**
  123155. * Initializes a PostProcessRenderPipelineManager
  123156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123157. */
  123158. constructor();
  123159. /**
  123160. * Gets the list of supported render pipelines
  123161. */
  123162. readonly supportedPipelines: PostProcessRenderPipeline[];
  123163. /**
  123164. * Adds a pipeline to the manager
  123165. * @param renderPipeline The pipeline to add
  123166. */
  123167. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  123168. /**
  123169. * Attaches a camera to the pipeline
  123170. * @param renderPipelineName The name of the pipeline to attach to
  123171. * @param cameras the camera to attach
  123172. * @param unique if the camera can be attached multiple times to the pipeline
  123173. */
  123174. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  123175. /**
  123176. * Detaches a camera from the pipeline
  123177. * @param renderPipelineName The name of the pipeline to detach from
  123178. * @param cameras the camera to detach
  123179. */
  123180. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  123181. /**
  123182. * Enables an effect by name on a pipeline
  123183. * @param renderPipelineName the name of the pipeline to enable the effect in
  123184. * @param renderEffectName the name of the effect to enable
  123185. * @param cameras the cameras that the effect should be enabled on
  123186. */
  123187. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  123188. /**
  123189. * Disables an effect by name on a pipeline
  123190. * @param renderPipelineName the name of the pipeline to disable the effect in
  123191. * @param renderEffectName the name of the effect to disable
  123192. * @param cameras the cameras that the effect should be disabled on
  123193. */
  123194. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  123195. /**
  123196. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  123197. */
  123198. update(): void;
  123199. /** @hidden */
  123200. _rebuild(): void;
  123201. /**
  123202. * Disposes of the manager and pipelines
  123203. */
  123204. dispose(): void;
  123205. }
  123206. }
  123207. declare module BABYLON {
  123208. interface Scene {
  123209. /** @hidden (Backing field) */
  123210. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  123211. /**
  123212. * Gets the postprocess render pipeline manager
  123213. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123214. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  123215. */
  123216. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  123217. }
  123218. /**
  123219. * Defines the Render Pipeline scene component responsible to rendering pipelines
  123220. */
  123221. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  123222. /**
  123223. * The component name helpfull to identify the component in the list of scene components.
  123224. */
  123225. readonly name: string;
  123226. /**
  123227. * The scene the component belongs to.
  123228. */
  123229. scene: Scene;
  123230. /**
  123231. * Creates a new instance of the component for the given scene
  123232. * @param scene Defines the scene to register the component in
  123233. */
  123234. constructor(scene: Scene);
  123235. /**
  123236. * Registers the component in a given scene
  123237. */
  123238. register(): void;
  123239. /**
  123240. * Rebuilds the elements related to this component in case of
  123241. * context lost for instance.
  123242. */
  123243. rebuild(): void;
  123244. /**
  123245. * Disposes the component and the associated ressources
  123246. */
  123247. dispose(): void;
  123248. private _gatherRenderTargets;
  123249. }
  123250. }
  123251. declare module BABYLON {
  123252. /**
  123253. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  123254. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  123255. */
  123256. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  123257. private _scene;
  123258. private _camerasToBeAttached;
  123259. /**
  123260. * ID of the sharpen post process,
  123261. */
  123262. private readonly SharpenPostProcessId;
  123263. /**
  123264. * @ignore
  123265. * ID of the image processing post process;
  123266. */
  123267. readonly ImageProcessingPostProcessId: string;
  123268. /**
  123269. * @ignore
  123270. * ID of the Fast Approximate Anti-Aliasing post process;
  123271. */
  123272. readonly FxaaPostProcessId: string;
  123273. /**
  123274. * ID of the chromatic aberration post process,
  123275. */
  123276. private readonly ChromaticAberrationPostProcessId;
  123277. /**
  123278. * ID of the grain post process
  123279. */
  123280. private readonly GrainPostProcessId;
  123281. /**
  123282. * Sharpen post process which will apply a sharpen convolution to enhance edges
  123283. */
  123284. sharpen: SharpenPostProcess;
  123285. private _sharpenEffect;
  123286. private bloom;
  123287. /**
  123288. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  123289. */
  123290. depthOfField: DepthOfFieldEffect;
  123291. /**
  123292. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  123293. */
  123294. fxaa: FxaaPostProcess;
  123295. /**
  123296. * Image post processing pass used to perform operations such as tone mapping or color grading.
  123297. */
  123298. imageProcessing: ImageProcessingPostProcess;
  123299. /**
  123300. * Chromatic aberration post process which will shift rgb colors in the image
  123301. */
  123302. chromaticAberration: ChromaticAberrationPostProcess;
  123303. private _chromaticAberrationEffect;
  123304. /**
  123305. * Grain post process which add noise to the image
  123306. */
  123307. grain: GrainPostProcess;
  123308. private _grainEffect;
  123309. /**
  123310. * Glow post process which adds a glow to emissive areas of the image
  123311. */
  123312. private _glowLayer;
  123313. /**
  123314. * Animations which can be used to tweak settings over a period of time
  123315. */
  123316. animations: Animation[];
  123317. private _imageProcessingConfigurationObserver;
  123318. private _sharpenEnabled;
  123319. private _bloomEnabled;
  123320. private _depthOfFieldEnabled;
  123321. private _depthOfFieldBlurLevel;
  123322. private _fxaaEnabled;
  123323. private _imageProcessingEnabled;
  123324. private _defaultPipelineTextureType;
  123325. private _bloomScale;
  123326. private _chromaticAberrationEnabled;
  123327. private _grainEnabled;
  123328. private _buildAllowed;
  123329. /**
  123330. * Gets active scene
  123331. */
  123332. readonly scene: Scene;
  123333. /**
  123334. * Enable or disable the sharpen process from the pipeline
  123335. */
  123336. sharpenEnabled: boolean;
  123337. private _resizeObserver;
  123338. private _hardwareScaleLevel;
  123339. private _bloomKernel;
  123340. /**
  123341. * Specifies the size of the bloom blur kernel, relative to the final output size
  123342. */
  123343. bloomKernel: number;
  123344. /**
  123345. * Specifies the weight of the bloom in the final rendering
  123346. */
  123347. private _bloomWeight;
  123348. /**
  123349. * Specifies the luma threshold for the area that will be blurred by the bloom
  123350. */
  123351. private _bloomThreshold;
  123352. private _hdr;
  123353. /**
  123354. * The strength of the bloom.
  123355. */
  123356. bloomWeight: number;
  123357. /**
  123358. * The strength of the bloom.
  123359. */
  123360. bloomThreshold: number;
  123361. /**
  123362. * The scale of the bloom, lower value will provide better performance.
  123363. */
  123364. bloomScale: number;
  123365. /**
  123366. * Enable or disable the bloom from the pipeline
  123367. */
  123368. bloomEnabled: boolean;
  123369. private _rebuildBloom;
  123370. /**
  123371. * If the depth of field is enabled.
  123372. */
  123373. depthOfFieldEnabled: boolean;
  123374. /**
  123375. * Blur level of the depth of field effect. (Higher blur will effect performance)
  123376. */
  123377. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  123378. /**
  123379. * If the anti aliasing is enabled.
  123380. */
  123381. fxaaEnabled: boolean;
  123382. private _samples;
  123383. /**
  123384. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  123385. */
  123386. samples: number;
  123387. /**
  123388. * If image processing is enabled.
  123389. */
  123390. imageProcessingEnabled: boolean;
  123391. /**
  123392. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  123393. */
  123394. glowLayerEnabled: boolean;
  123395. /**
  123396. * Gets the glow layer (or null if not defined)
  123397. */
  123398. readonly glowLayer: Nullable<GlowLayer>;
  123399. /**
  123400. * Enable or disable the chromaticAberration process from the pipeline
  123401. */
  123402. chromaticAberrationEnabled: boolean;
  123403. /**
  123404. * Enable or disable the grain process from the pipeline
  123405. */
  123406. grainEnabled: boolean;
  123407. /**
  123408. * @constructor
  123409. * @param name - The rendering pipeline name (default: "")
  123410. * @param hdr - If high dynamic range textures should be used (default: true)
  123411. * @param scene - The scene linked to this pipeline (default: the last created scene)
  123412. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  123413. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  123414. */
  123415. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  123416. /**
  123417. * Get the class name
  123418. * @returns "DefaultRenderingPipeline"
  123419. */
  123420. getClassName(): string;
  123421. /**
  123422. * Force the compilation of the entire pipeline.
  123423. */
  123424. prepare(): void;
  123425. private _hasCleared;
  123426. private _prevPostProcess;
  123427. private _prevPrevPostProcess;
  123428. private _setAutoClearAndTextureSharing;
  123429. private _depthOfFieldSceneObserver;
  123430. private _buildPipeline;
  123431. private _disposePostProcesses;
  123432. /**
  123433. * Adds a camera to the pipeline
  123434. * @param camera the camera to be added
  123435. */
  123436. addCamera(camera: Camera): void;
  123437. /**
  123438. * Removes a camera from the pipeline
  123439. * @param camera the camera to remove
  123440. */
  123441. removeCamera(camera: Camera): void;
  123442. /**
  123443. * Dispose of the pipeline and stop all post processes
  123444. */
  123445. dispose(): void;
  123446. /**
  123447. * Serialize the rendering pipeline (Used when exporting)
  123448. * @returns the serialized object
  123449. */
  123450. serialize(): any;
  123451. /**
  123452. * Parse the serialized pipeline
  123453. * @param source Source pipeline.
  123454. * @param scene The scene to load the pipeline to.
  123455. * @param rootUrl The URL of the serialized pipeline.
  123456. * @returns An instantiated pipeline from the serialized object.
  123457. */
  123458. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  123459. }
  123460. }
  123461. declare module BABYLON {
  123462. /** @hidden */
  123463. export var lensHighlightsPixelShader: {
  123464. name: string;
  123465. shader: string;
  123466. };
  123467. }
  123468. declare module BABYLON {
  123469. /** @hidden */
  123470. export var depthOfFieldPixelShader: {
  123471. name: string;
  123472. shader: string;
  123473. };
  123474. }
  123475. declare module BABYLON {
  123476. /**
  123477. * BABYLON.JS Chromatic Aberration GLSL Shader
  123478. * Author: Olivier Guyot
  123479. * Separates very slightly R, G and B colors on the edges of the screen
  123480. * Inspired by Francois Tarlier & Martins Upitis
  123481. */
  123482. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  123483. /**
  123484. * @ignore
  123485. * The chromatic aberration PostProcess id in the pipeline
  123486. */
  123487. LensChromaticAberrationEffect: string;
  123488. /**
  123489. * @ignore
  123490. * The highlights enhancing PostProcess id in the pipeline
  123491. */
  123492. HighlightsEnhancingEffect: string;
  123493. /**
  123494. * @ignore
  123495. * The depth-of-field PostProcess id in the pipeline
  123496. */
  123497. LensDepthOfFieldEffect: string;
  123498. private _scene;
  123499. private _depthTexture;
  123500. private _grainTexture;
  123501. private _chromaticAberrationPostProcess;
  123502. private _highlightsPostProcess;
  123503. private _depthOfFieldPostProcess;
  123504. private _edgeBlur;
  123505. private _grainAmount;
  123506. private _chromaticAberration;
  123507. private _distortion;
  123508. private _highlightsGain;
  123509. private _highlightsThreshold;
  123510. private _dofDistance;
  123511. private _dofAperture;
  123512. private _dofDarken;
  123513. private _dofPentagon;
  123514. private _blurNoise;
  123515. /**
  123516. * @constructor
  123517. *
  123518. * Effect parameters are as follow:
  123519. * {
  123520. * chromatic_aberration: number; // from 0 to x (1 for realism)
  123521. * edge_blur: number; // from 0 to x (1 for realism)
  123522. * distortion: number; // from 0 to x (1 for realism)
  123523. * grain_amount: number; // from 0 to 1
  123524. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  123525. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  123526. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  123527. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  123528. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  123529. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  123530. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  123531. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  123532. * }
  123533. * Note: if an effect parameter is unset, effect is disabled
  123534. *
  123535. * @param name The rendering pipeline name
  123536. * @param parameters - An object containing all parameters (see above)
  123537. * @param scene The scene linked to this pipeline
  123538. * @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)
  123539. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123540. */
  123541. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  123542. /**
  123543. * Get the class name
  123544. * @returns "LensRenderingPipeline"
  123545. */
  123546. getClassName(): string;
  123547. /**
  123548. * Gets associated scene
  123549. */
  123550. readonly scene: Scene;
  123551. /**
  123552. * Gets or sets the edge blur
  123553. */
  123554. edgeBlur: number;
  123555. /**
  123556. * Gets or sets the grain amount
  123557. */
  123558. grainAmount: number;
  123559. /**
  123560. * Gets or sets the chromatic aberration amount
  123561. */
  123562. chromaticAberration: number;
  123563. /**
  123564. * Gets or sets the depth of field aperture
  123565. */
  123566. dofAperture: number;
  123567. /**
  123568. * Gets or sets the edge distortion
  123569. */
  123570. edgeDistortion: number;
  123571. /**
  123572. * Gets or sets the depth of field distortion
  123573. */
  123574. dofDistortion: number;
  123575. /**
  123576. * Gets or sets the darken out of focus amount
  123577. */
  123578. darkenOutOfFocus: number;
  123579. /**
  123580. * Gets or sets a boolean indicating if blur noise is enabled
  123581. */
  123582. blurNoise: boolean;
  123583. /**
  123584. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  123585. */
  123586. pentagonBokeh: boolean;
  123587. /**
  123588. * Gets or sets the highlight grain amount
  123589. */
  123590. highlightsGain: number;
  123591. /**
  123592. * Gets or sets the highlight threshold
  123593. */
  123594. highlightsThreshold: number;
  123595. /**
  123596. * Sets the amount of blur at the edges
  123597. * @param amount blur amount
  123598. */
  123599. setEdgeBlur(amount: number): void;
  123600. /**
  123601. * Sets edge blur to 0
  123602. */
  123603. disableEdgeBlur(): void;
  123604. /**
  123605. * Sets the amout of grain
  123606. * @param amount Amount of grain
  123607. */
  123608. setGrainAmount(amount: number): void;
  123609. /**
  123610. * Set grain amount to 0
  123611. */
  123612. disableGrain(): void;
  123613. /**
  123614. * Sets the chromatic aberration amount
  123615. * @param amount amount of chromatic aberration
  123616. */
  123617. setChromaticAberration(amount: number): void;
  123618. /**
  123619. * Sets chromatic aberration amount to 0
  123620. */
  123621. disableChromaticAberration(): void;
  123622. /**
  123623. * Sets the EdgeDistortion amount
  123624. * @param amount amount of EdgeDistortion
  123625. */
  123626. setEdgeDistortion(amount: number): void;
  123627. /**
  123628. * Sets edge distortion to 0
  123629. */
  123630. disableEdgeDistortion(): void;
  123631. /**
  123632. * Sets the FocusDistance amount
  123633. * @param amount amount of FocusDistance
  123634. */
  123635. setFocusDistance(amount: number): void;
  123636. /**
  123637. * Disables depth of field
  123638. */
  123639. disableDepthOfField(): void;
  123640. /**
  123641. * Sets the Aperture amount
  123642. * @param amount amount of Aperture
  123643. */
  123644. setAperture(amount: number): void;
  123645. /**
  123646. * Sets the DarkenOutOfFocus amount
  123647. * @param amount amount of DarkenOutOfFocus
  123648. */
  123649. setDarkenOutOfFocus(amount: number): void;
  123650. private _pentagonBokehIsEnabled;
  123651. /**
  123652. * Creates a pentagon bokeh effect
  123653. */
  123654. enablePentagonBokeh(): void;
  123655. /**
  123656. * Disables the pentagon bokeh effect
  123657. */
  123658. disablePentagonBokeh(): void;
  123659. /**
  123660. * Enables noise blur
  123661. */
  123662. enableNoiseBlur(): void;
  123663. /**
  123664. * Disables noise blur
  123665. */
  123666. disableNoiseBlur(): void;
  123667. /**
  123668. * Sets the HighlightsGain amount
  123669. * @param amount amount of HighlightsGain
  123670. */
  123671. setHighlightsGain(amount: number): void;
  123672. /**
  123673. * Sets the HighlightsThreshold amount
  123674. * @param amount amount of HighlightsThreshold
  123675. */
  123676. setHighlightsThreshold(amount: number): void;
  123677. /**
  123678. * Disables highlights
  123679. */
  123680. disableHighlights(): void;
  123681. /**
  123682. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  123683. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  123684. */
  123685. dispose(disableDepthRender?: boolean): void;
  123686. private _createChromaticAberrationPostProcess;
  123687. private _createHighlightsPostProcess;
  123688. private _createDepthOfFieldPostProcess;
  123689. private _createGrainTexture;
  123690. }
  123691. }
  123692. declare module BABYLON {
  123693. /** @hidden */
  123694. export var ssao2PixelShader: {
  123695. name: string;
  123696. shader: string;
  123697. };
  123698. }
  123699. declare module BABYLON {
  123700. /** @hidden */
  123701. export var ssaoCombinePixelShader: {
  123702. name: string;
  123703. shader: string;
  123704. };
  123705. }
  123706. declare module BABYLON {
  123707. /**
  123708. * Render pipeline to produce ssao effect
  123709. */
  123710. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  123711. /**
  123712. * @ignore
  123713. * The PassPostProcess id in the pipeline that contains the original scene color
  123714. */
  123715. SSAOOriginalSceneColorEffect: string;
  123716. /**
  123717. * @ignore
  123718. * The SSAO PostProcess id in the pipeline
  123719. */
  123720. SSAORenderEffect: string;
  123721. /**
  123722. * @ignore
  123723. * The horizontal blur PostProcess id in the pipeline
  123724. */
  123725. SSAOBlurHRenderEffect: string;
  123726. /**
  123727. * @ignore
  123728. * The vertical blur PostProcess id in the pipeline
  123729. */
  123730. SSAOBlurVRenderEffect: string;
  123731. /**
  123732. * @ignore
  123733. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123734. */
  123735. SSAOCombineRenderEffect: string;
  123736. /**
  123737. * The output strength of the SSAO post-process. Default value is 1.0.
  123738. */
  123739. totalStrength: number;
  123740. /**
  123741. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  123742. */
  123743. maxZ: number;
  123744. /**
  123745. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  123746. */
  123747. minZAspect: number;
  123748. private _samples;
  123749. /**
  123750. * Number of samples used for the SSAO calculations. Default value is 8
  123751. */
  123752. samples: number;
  123753. private _textureSamples;
  123754. /**
  123755. * Number of samples to use for antialiasing
  123756. */
  123757. textureSamples: number;
  123758. /**
  123759. * Ratio object used for SSAO ratio and blur ratio
  123760. */
  123761. private _ratio;
  123762. /**
  123763. * Dynamically generated sphere sampler.
  123764. */
  123765. private _sampleSphere;
  123766. /**
  123767. * Blur filter offsets
  123768. */
  123769. private _samplerOffsets;
  123770. private _expensiveBlur;
  123771. /**
  123772. * If bilateral blur should be used
  123773. */
  123774. expensiveBlur: boolean;
  123775. /**
  123776. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  123777. */
  123778. radius: number;
  123779. /**
  123780. * The base color of the SSAO post-process
  123781. * The final result is "base + ssao" between [0, 1]
  123782. */
  123783. base: number;
  123784. /**
  123785. * Support test.
  123786. */
  123787. static readonly IsSupported: boolean;
  123788. private _scene;
  123789. private _depthTexture;
  123790. private _normalTexture;
  123791. private _randomTexture;
  123792. private _originalColorPostProcess;
  123793. private _ssaoPostProcess;
  123794. private _blurHPostProcess;
  123795. private _blurVPostProcess;
  123796. private _ssaoCombinePostProcess;
  123797. private _firstUpdate;
  123798. /**
  123799. * Gets active scene
  123800. */
  123801. readonly scene: Scene;
  123802. /**
  123803. * @constructor
  123804. * @param name The rendering pipeline name
  123805. * @param scene The scene linked to this pipeline
  123806. * @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 }
  123807. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123808. */
  123809. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123810. /**
  123811. * Get the class name
  123812. * @returns "SSAO2RenderingPipeline"
  123813. */
  123814. getClassName(): string;
  123815. /**
  123816. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123817. */
  123818. dispose(disableGeometryBufferRenderer?: boolean): void;
  123819. private _createBlurPostProcess;
  123820. /** @hidden */
  123821. _rebuild(): void;
  123822. private _bits;
  123823. private _radicalInverse_VdC;
  123824. private _hammersley;
  123825. private _hemisphereSample_uniform;
  123826. private _generateHemisphere;
  123827. private _createSSAOPostProcess;
  123828. private _createSSAOCombinePostProcess;
  123829. private _createRandomTexture;
  123830. /**
  123831. * Serialize the rendering pipeline (Used when exporting)
  123832. * @returns the serialized object
  123833. */
  123834. serialize(): any;
  123835. /**
  123836. * Parse the serialized pipeline
  123837. * @param source Source pipeline.
  123838. * @param scene The scene to load the pipeline to.
  123839. * @param rootUrl The URL of the serialized pipeline.
  123840. * @returns An instantiated pipeline from the serialized object.
  123841. */
  123842. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  123843. }
  123844. }
  123845. declare module BABYLON {
  123846. /** @hidden */
  123847. export var ssaoPixelShader: {
  123848. name: string;
  123849. shader: string;
  123850. };
  123851. }
  123852. declare module BABYLON {
  123853. /**
  123854. * Render pipeline to produce ssao effect
  123855. */
  123856. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  123857. /**
  123858. * @ignore
  123859. * The PassPostProcess id in the pipeline that contains the original scene color
  123860. */
  123861. SSAOOriginalSceneColorEffect: string;
  123862. /**
  123863. * @ignore
  123864. * The SSAO PostProcess id in the pipeline
  123865. */
  123866. SSAORenderEffect: string;
  123867. /**
  123868. * @ignore
  123869. * The horizontal blur PostProcess id in the pipeline
  123870. */
  123871. SSAOBlurHRenderEffect: string;
  123872. /**
  123873. * @ignore
  123874. * The vertical blur PostProcess id in the pipeline
  123875. */
  123876. SSAOBlurVRenderEffect: string;
  123877. /**
  123878. * @ignore
  123879. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123880. */
  123881. SSAOCombineRenderEffect: string;
  123882. /**
  123883. * The output strength of the SSAO post-process. Default value is 1.0.
  123884. */
  123885. totalStrength: number;
  123886. /**
  123887. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  123888. */
  123889. radius: number;
  123890. /**
  123891. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  123892. * Must not be equal to fallOff and superior to fallOff.
  123893. * Default value is 0.0075
  123894. */
  123895. area: number;
  123896. /**
  123897. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  123898. * Must not be equal to area and inferior to area.
  123899. * Default value is 0.000001
  123900. */
  123901. fallOff: number;
  123902. /**
  123903. * The base color of the SSAO post-process
  123904. * The final result is "base + ssao" between [0, 1]
  123905. */
  123906. base: number;
  123907. private _scene;
  123908. private _depthTexture;
  123909. private _randomTexture;
  123910. private _originalColorPostProcess;
  123911. private _ssaoPostProcess;
  123912. private _blurHPostProcess;
  123913. private _blurVPostProcess;
  123914. private _ssaoCombinePostProcess;
  123915. private _firstUpdate;
  123916. /**
  123917. * Gets active scene
  123918. */
  123919. readonly scene: Scene;
  123920. /**
  123921. * @constructor
  123922. * @param name - The rendering pipeline name
  123923. * @param scene - The scene linked to this pipeline
  123924. * @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 }
  123925. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  123926. */
  123927. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123928. /**
  123929. * Get the class name
  123930. * @returns "SSAORenderingPipeline"
  123931. */
  123932. getClassName(): string;
  123933. /**
  123934. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123935. */
  123936. dispose(disableDepthRender?: boolean): void;
  123937. private _createBlurPostProcess;
  123938. /** @hidden */
  123939. _rebuild(): void;
  123940. private _createSSAOPostProcess;
  123941. private _createSSAOCombinePostProcess;
  123942. private _createRandomTexture;
  123943. }
  123944. }
  123945. declare module BABYLON {
  123946. /** @hidden */
  123947. export var standardPixelShader: {
  123948. name: string;
  123949. shader: string;
  123950. };
  123951. }
  123952. declare module BABYLON {
  123953. /**
  123954. * Standard rendering pipeline
  123955. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  123956. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  123957. */
  123958. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  123959. /**
  123960. * Public members
  123961. */
  123962. /**
  123963. * Post-process which contains the original scene color before the pipeline applies all the effects
  123964. */
  123965. originalPostProcess: Nullable<PostProcess>;
  123966. /**
  123967. * Post-process used to down scale an image x4
  123968. */
  123969. downSampleX4PostProcess: Nullable<PostProcess>;
  123970. /**
  123971. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  123972. */
  123973. brightPassPostProcess: Nullable<PostProcess>;
  123974. /**
  123975. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  123976. */
  123977. blurHPostProcesses: PostProcess[];
  123978. /**
  123979. * Post-process array storing all the vertical blur post-processes used by the pipeline
  123980. */
  123981. blurVPostProcesses: PostProcess[];
  123982. /**
  123983. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  123984. */
  123985. textureAdderPostProcess: Nullable<PostProcess>;
  123986. /**
  123987. * Post-process used to create volumetric lighting effect
  123988. */
  123989. volumetricLightPostProcess: Nullable<PostProcess>;
  123990. /**
  123991. * Post-process used to smooth the previous volumetric light post-process on the X axis
  123992. */
  123993. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  123994. /**
  123995. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  123996. */
  123997. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  123998. /**
  123999. * Post-process used to merge the volumetric light effect and the real scene color
  124000. */
  124001. volumetricLightMergePostProces: Nullable<PostProcess>;
  124002. /**
  124003. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  124004. */
  124005. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  124006. /**
  124007. * Base post-process used to calculate the average luminance of the final image for HDR
  124008. */
  124009. luminancePostProcess: Nullable<PostProcess>;
  124010. /**
  124011. * Post-processes used to create down sample post-processes in order to get
  124012. * the average luminance of the final image for HDR
  124013. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  124014. */
  124015. luminanceDownSamplePostProcesses: PostProcess[];
  124016. /**
  124017. * Post-process used to create a HDR effect (light adaptation)
  124018. */
  124019. hdrPostProcess: Nullable<PostProcess>;
  124020. /**
  124021. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  124022. */
  124023. textureAdderFinalPostProcess: Nullable<PostProcess>;
  124024. /**
  124025. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  124026. */
  124027. lensFlareFinalPostProcess: Nullable<PostProcess>;
  124028. /**
  124029. * Post-process used to merge the final HDR post-process and the real scene color
  124030. */
  124031. hdrFinalPostProcess: Nullable<PostProcess>;
  124032. /**
  124033. * Post-process used to create a lens flare effect
  124034. */
  124035. lensFlarePostProcess: Nullable<PostProcess>;
  124036. /**
  124037. * Post-process that merges the result of the lens flare post-process and the real scene color
  124038. */
  124039. lensFlareComposePostProcess: Nullable<PostProcess>;
  124040. /**
  124041. * Post-process used to create a motion blur effect
  124042. */
  124043. motionBlurPostProcess: Nullable<PostProcess>;
  124044. /**
  124045. * Post-process used to create a depth of field effect
  124046. */
  124047. depthOfFieldPostProcess: Nullable<PostProcess>;
  124048. /**
  124049. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124050. */
  124051. fxaaPostProcess: Nullable<FxaaPostProcess>;
  124052. /**
  124053. * Represents the brightness threshold in order to configure the illuminated surfaces
  124054. */
  124055. brightThreshold: number;
  124056. /**
  124057. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  124058. */
  124059. blurWidth: number;
  124060. /**
  124061. * Sets if the blur for highlighted surfaces must be only horizontal
  124062. */
  124063. horizontalBlur: boolean;
  124064. /**
  124065. * Gets the overall exposure used by the pipeline
  124066. */
  124067. /**
  124068. * Sets the overall exposure used by the pipeline
  124069. */
  124070. exposure: number;
  124071. /**
  124072. * Texture used typically to simulate "dirty" on camera lens
  124073. */
  124074. lensTexture: Nullable<Texture>;
  124075. /**
  124076. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  124077. */
  124078. volumetricLightCoefficient: number;
  124079. /**
  124080. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  124081. */
  124082. volumetricLightPower: number;
  124083. /**
  124084. * Used the set the blur intensity to smooth the volumetric lights
  124085. */
  124086. volumetricLightBlurScale: number;
  124087. /**
  124088. * Light (spot or directional) used to generate the volumetric lights rays
  124089. * The source light must have a shadow generate so the pipeline can get its
  124090. * depth map
  124091. */
  124092. sourceLight: Nullable<SpotLight | DirectionalLight>;
  124093. /**
  124094. * For eye adaptation, represents the minimum luminance the eye can see
  124095. */
  124096. hdrMinimumLuminance: number;
  124097. /**
  124098. * For eye adaptation, represents the decrease luminance speed
  124099. */
  124100. hdrDecreaseRate: number;
  124101. /**
  124102. * For eye adaptation, represents the increase luminance speed
  124103. */
  124104. hdrIncreaseRate: number;
  124105. /**
  124106. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  124107. */
  124108. /**
  124109. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  124110. */
  124111. hdrAutoExposure: boolean;
  124112. /**
  124113. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  124114. */
  124115. lensColorTexture: Nullable<Texture>;
  124116. /**
  124117. * The overall strengh for the lens flare effect
  124118. */
  124119. lensFlareStrength: number;
  124120. /**
  124121. * Dispersion coefficient for lens flare ghosts
  124122. */
  124123. lensFlareGhostDispersal: number;
  124124. /**
  124125. * Main lens flare halo width
  124126. */
  124127. lensFlareHaloWidth: number;
  124128. /**
  124129. * Based on the lens distortion effect, defines how much the lens flare result
  124130. * is distorted
  124131. */
  124132. lensFlareDistortionStrength: number;
  124133. /**
  124134. * Configures the blur intensity used for for lens flare (halo)
  124135. */
  124136. lensFlareBlurWidth: number;
  124137. /**
  124138. * Lens star texture must be used to simulate rays on the flares and is available
  124139. * in the documentation
  124140. */
  124141. lensStarTexture: Nullable<Texture>;
  124142. /**
  124143. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  124144. * flare effect by taking account of the dirt texture
  124145. */
  124146. lensFlareDirtTexture: Nullable<Texture>;
  124147. /**
  124148. * Represents the focal length for the depth of field effect
  124149. */
  124150. depthOfFieldDistance: number;
  124151. /**
  124152. * Represents the blur intensity for the blurred part of the depth of field effect
  124153. */
  124154. depthOfFieldBlurWidth: number;
  124155. /**
  124156. * Gets how much the image is blurred by the movement while using the motion blur post-process
  124157. */
  124158. /**
  124159. * Sets how much the image is blurred by the movement while using the motion blur post-process
  124160. */
  124161. motionStrength: number;
  124162. /**
  124163. * Gets wether or not the motion blur post-process is object based or screen based.
  124164. */
  124165. /**
  124166. * Sets wether or not the motion blur post-process should be object based or screen based
  124167. */
  124168. objectBasedMotionBlur: boolean;
  124169. /**
  124170. * List of animations for the pipeline (IAnimatable implementation)
  124171. */
  124172. animations: Animation[];
  124173. /**
  124174. * Private members
  124175. */
  124176. private _scene;
  124177. private _currentDepthOfFieldSource;
  124178. private _basePostProcess;
  124179. private _fixedExposure;
  124180. private _currentExposure;
  124181. private _hdrAutoExposure;
  124182. private _hdrCurrentLuminance;
  124183. private _motionStrength;
  124184. private _isObjectBasedMotionBlur;
  124185. private _floatTextureType;
  124186. private _camerasToBeAttached;
  124187. private _ratio;
  124188. private _bloomEnabled;
  124189. private _depthOfFieldEnabled;
  124190. private _vlsEnabled;
  124191. private _lensFlareEnabled;
  124192. private _hdrEnabled;
  124193. private _motionBlurEnabled;
  124194. private _fxaaEnabled;
  124195. private _motionBlurSamples;
  124196. private _volumetricLightStepsCount;
  124197. private _samples;
  124198. /**
  124199. * @ignore
  124200. * Specifies if the bloom pipeline is enabled
  124201. */
  124202. BloomEnabled: boolean;
  124203. /**
  124204. * @ignore
  124205. * Specifies if the depth of field pipeline is enabed
  124206. */
  124207. DepthOfFieldEnabled: boolean;
  124208. /**
  124209. * @ignore
  124210. * Specifies if the lens flare pipeline is enabed
  124211. */
  124212. LensFlareEnabled: boolean;
  124213. /**
  124214. * @ignore
  124215. * Specifies if the HDR pipeline is enabled
  124216. */
  124217. HDREnabled: boolean;
  124218. /**
  124219. * @ignore
  124220. * Specifies if the volumetric lights scattering effect is enabled
  124221. */
  124222. VLSEnabled: boolean;
  124223. /**
  124224. * @ignore
  124225. * Specifies if the motion blur effect is enabled
  124226. */
  124227. MotionBlurEnabled: boolean;
  124228. /**
  124229. * Specifies if anti-aliasing is enabled
  124230. */
  124231. fxaaEnabled: boolean;
  124232. /**
  124233. * Specifies the number of steps used to calculate the volumetric lights
  124234. * Typically in interval [50, 200]
  124235. */
  124236. volumetricLightStepsCount: number;
  124237. /**
  124238. * Specifies the number of samples used for the motion blur effect
  124239. * Typically in interval [16, 64]
  124240. */
  124241. motionBlurSamples: number;
  124242. /**
  124243. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  124244. */
  124245. samples: number;
  124246. /**
  124247. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  124248. * @constructor
  124249. * @param name The rendering pipeline name
  124250. * @param scene The scene linked to this pipeline
  124251. * @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)
  124252. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  124253. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124254. */
  124255. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  124256. private _buildPipeline;
  124257. private _createDownSampleX4PostProcess;
  124258. private _createBrightPassPostProcess;
  124259. private _createBlurPostProcesses;
  124260. private _createTextureAdderPostProcess;
  124261. private _createVolumetricLightPostProcess;
  124262. private _createLuminancePostProcesses;
  124263. private _createHdrPostProcess;
  124264. private _createLensFlarePostProcess;
  124265. private _createDepthOfFieldPostProcess;
  124266. private _createMotionBlurPostProcess;
  124267. private _getDepthTexture;
  124268. private _disposePostProcesses;
  124269. /**
  124270. * Dispose of the pipeline and stop all post processes
  124271. */
  124272. dispose(): void;
  124273. /**
  124274. * Serialize the rendering pipeline (Used when exporting)
  124275. * @returns the serialized object
  124276. */
  124277. serialize(): any;
  124278. /**
  124279. * Parse the serialized pipeline
  124280. * @param source Source pipeline.
  124281. * @param scene The scene to load the pipeline to.
  124282. * @param rootUrl The URL of the serialized pipeline.
  124283. * @returns An instantiated pipeline from the serialized object.
  124284. */
  124285. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  124286. /**
  124287. * Luminance steps
  124288. */
  124289. static LuminanceSteps: number;
  124290. }
  124291. }
  124292. declare module BABYLON {
  124293. /** @hidden */
  124294. export var tonemapPixelShader: {
  124295. name: string;
  124296. shader: string;
  124297. };
  124298. }
  124299. declare module BABYLON {
  124300. /** Defines operator used for tonemapping */
  124301. export enum TonemappingOperator {
  124302. /** Hable */
  124303. Hable = 0,
  124304. /** Reinhard */
  124305. Reinhard = 1,
  124306. /** HejiDawson */
  124307. HejiDawson = 2,
  124308. /** Photographic */
  124309. Photographic = 3
  124310. }
  124311. /**
  124312. * Defines a post process to apply tone mapping
  124313. */
  124314. export class TonemapPostProcess extends PostProcess {
  124315. private _operator;
  124316. /** Defines the required exposure adjustement */
  124317. exposureAdjustment: number;
  124318. /**
  124319. * Creates a new TonemapPostProcess
  124320. * @param name defines the name of the postprocess
  124321. * @param _operator defines the operator to use
  124322. * @param exposureAdjustment defines the required exposure adjustement
  124323. * @param camera defines the camera to use (can be null)
  124324. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  124325. * @param engine defines the hosting engine (can be ignore if camera is set)
  124326. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  124327. */
  124328. constructor(name: string, _operator: TonemappingOperator,
  124329. /** Defines the required exposure adjustement */
  124330. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  124331. }
  124332. }
  124333. declare module BABYLON {
  124334. /** @hidden */
  124335. export var depthVertexShader: {
  124336. name: string;
  124337. shader: string;
  124338. };
  124339. }
  124340. declare module BABYLON {
  124341. /** @hidden */
  124342. export var volumetricLightScatteringPixelShader: {
  124343. name: string;
  124344. shader: string;
  124345. };
  124346. }
  124347. declare module BABYLON {
  124348. /** @hidden */
  124349. export var volumetricLightScatteringPassVertexShader: {
  124350. name: string;
  124351. shader: string;
  124352. };
  124353. }
  124354. declare module BABYLON {
  124355. /** @hidden */
  124356. export var volumetricLightScatteringPassPixelShader: {
  124357. name: string;
  124358. shader: string;
  124359. };
  124360. }
  124361. declare module BABYLON {
  124362. /**
  124363. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  124364. */
  124365. export class VolumetricLightScatteringPostProcess extends PostProcess {
  124366. private _volumetricLightScatteringPass;
  124367. private _volumetricLightScatteringRTT;
  124368. private _viewPort;
  124369. private _screenCoordinates;
  124370. private _cachedDefines;
  124371. /**
  124372. * If not undefined, the mesh position is computed from the attached node position
  124373. */
  124374. attachedNode: {
  124375. position: Vector3;
  124376. };
  124377. /**
  124378. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  124379. */
  124380. customMeshPosition: Vector3;
  124381. /**
  124382. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  124383. */
  124384. useCustomMeshPosition: boolean;
  124385. /**
  124386. * If the post-process should inverse the light scattering direction
  124387. */
  124388. invert: boolean;
  124389. /**
  124390. * The internal mesh used by the post-process
  124391. */
  124392. mesh: Mesh;
  124393. /**
  124394. * @hidden
  124395. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  124396. */
  124397. useDiffuseColor: boolean;
  124398. /**
  124399. * Array containing the excluded meshes not rendered in the internal pass
  124400. */
  124401. excludedMeshes: AbstractMesh[];
  124402. /**
  124403. * Controls the overall intensity of the post-process
  124404. */
  124405. exposure: number;
  124406. /**
  124407. * Dissipates each sample's contribution in range [0, 1]
  124408. */
  124409. decay: number;
  124410. /**
  124411. * Controls the overall intensity of each sample
  124412. */
  124413. weight: number;
  124414. /**
  124415. * Controls the density of each sample
  124416. */
  124417. density: number;
  124418. /**
  124419. * @constructor
  124420. * @param name The post-process name
  124421. * @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)
  124422. * @param camera The camera that the post-process will be attached to
  124423. * @param mesh The mesh used to create the light scattering
  124424. * @param samples The post-process quality, default 100
  124425. * @param samplingModeThe post-process filtering mode
  124426. * @param engine The babylon engine
  124427. * @param reusable If the post-process is reusable
  124428. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  124429. */
  124430. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  124431. /**
  124432. * Returns the string "VolumetricLightScatteringPostProcess"
  124433. * @returns "VolumetricLightScatteringPostProcess"
  124434. */
  124435. getClassName(): string;
  124436. private _isReady;
  124437. /**
  124438. * Sets the new light position for light scattering effect
  124439. * @param position The new custom light position
  124440. */
  124441. setCustomMeshPosition(position: Vector3): void;
  124442. /**
  124443. * Returns the light position for light scattering effect
  124444. * @return Vector3 The custom light position
  124445. */
  124446. getCustomMeshPosition(): Vector3;
  124447. /**
  124448. * Disposes the internal assets and detaches the post-process from the camera
  124449. */
  124450. dispose(camera: Camera): void;
  124451. /**
  124452. * Returns the render target texture used by the post-process
  124453. * @return the render target texture used by the post-process
  124454. */
  124455. getPass(): RenderTargetTexture;
  124456. private _meshExcluded;
  124457. private _createPass;
  124458. private _updateMeshScreenCoordinates;
  124459. /**
  124460. * Creates a default mesh for the Volumeric Light Scattering post-process
  124461. * @param name The mesh name
  124462. * @param scene The scene where to create the mesh
  124463. * @return the default mesh
  124464. */
  124465. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  124466. }
  124467. }
  124468. declare module BABYLON {
  124469. interface Scene {
  124470. /** @hidden (Backing field) */
  124471. _boundingBoxRenderer: BoundingBoxRenderer;
  124472. /** @hidden (Backing field) */
  124473. _forceShowBoundingBoxes: boolean;
  124474. /**
  124475. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  124476. */
  124477. forceShowBoundingBoxes: boolean;
  124478. /**
  124479. * Gets the bounding box renderer associated with the scene
  124480. * @returns a BoundingBoxRenderer
  124481. */
  124482. getBoundingBoxRenderer(): BoundingBoxRenderer;
  124483. }
  124484. interface AbstractMesh {
  124485. /** @hidden (Backing field) */
  124486. _showBoundingBox: boolean;
  124487. /**
  124488. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  124489. */
  124490. showBoundingBox: boolean;
  124491. }
  124492. /**
  124493. * Component responsible of rendering the bounding box of the meshes in a scene.
  124494. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  124495. */
  124496. export class BoundingBoxRenderer implements ISceneComponent {
  124497. /**
  124498. * The component name helpfull to identify the component in the list of scene components.
  124499. */
  124500. readonly name: string;
  124501. /**
  124502. * The scene the component belongs to.
  124503. */
  124504. scene: Scene;
  124505. /**
  124506. * Color of the bounding box lines placed in front of an object
  124507. */
  124508. frontColor: Color3;
  124509. /**
  124510. * Color of the bounding box lines placed behind an object
  124511. */
  124512. backColor: Color3;
  124513. /**
  124514. * Defines if the renderer should show the back lines or not
  124515. */
  124516. showBackLines: boolean;
  124517. /**
  124518. * @hidden
  124519. */
  124520. renderList: SmartArray<BoundingBox>;
  124521. private _colorShader;
  124522. private _vertexBuffers;
  124523. private _indexBuffer;
  124524. private _fillIndexBuffer;
  124525. private _fillIndexData;
  124526. /**
  124527. * Instantiates a new bounding box renderer in a scene.
  124528. * @param scene the scene the renderer renders in
  124529. */
  124530. constructor(scene: Scene);
  124531. /**
  124532. * Registers the component in a given scene
  124533. */
  124534. register(): void;
  124535. private _evaluateSubMesh;
  124536. private _activeMesh;
  124537. private _prepareRessources;
  124538. private _createIndexBuffer;
  124539. /**
  124540. * Rebuilds the elements related to this component in case of
  124541. * context lost for instance.
  124542. */
  124543. rebuild(): void;
  124544. /**
  124545. * @hidden
  124546. */
  124547. reset(): void;
  124548. /**
  124549. * Render the bounding boxes of a specific rendering group
  124550. * @param renderingGroupId defines the rendering group to render
  124551. */
  124552. render(renderingGroupId: number): void;
  124553. /**
  124554. * In case of occlusion queries, we can render the occlusion bounding box through this method
  124555. * @param mesh Define the mesh to render the occlusion bounding box for
  124556. */
  124557. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  124558. /**
  124559. * Dispose and release the resources attached to this renderer.
  124560. */
  124561. dispose(): void;
  124562. }
  124563. }
  124564. declare module BABYLON {
  124565. /** @hidden */
  124566. export var depthPixelShader: {
  124567. name: string;
  124568. shader: string;
  124569. };
  124570. }
  124571. declare module BABYLON {
  124572. /**
  124573. * This represents a depth renderer in Babylon.
  124574. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  124575. */
  124576. export class DepthRenderer {
  124577. private _scene;
  124578. private _depthMap;
  124579. private _effect;
  124580. private readonly _storeNonLinearDepth;
  124581. private readonly _clearColor;
  124582. /** Get if the depth renderer is using packed depth or not */
  124583. readonly isPacked: boolean;
  124584. private _cachedDefines;
  124585. private _camera;
  124586. /**
  124587. * Specifiess that the depth renderer will only be used within
  124588. * the camera it is created for.
  124589. * This can help forcing its rendering during the camera processing.
  124590. */
  124591. useOnlyInActiveCamera: boolean;
  124592. /** @hidden */
  124593. static _SceneComponentInitialization: (scene: Scene) => void;
  124594. /**
  124595. * Instantiates a depth renderer
  124596. * @param scene The scene the renderer belongs to
  124597. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  124598. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  124599. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124600. */
  124601. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  124602. /**
  124603. * Creates the depth rendering effect and checks if the effect is ready.
  124604. * @param subMesh The submesh to be used to render the depth map of
  124605. * @param useInstances If multiple world instances should be used
  124606. * @returns if the depth renderer is ready to render the depth map
  124607. */
  124608. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124609. /**
  124610. * Gets the texture which the depth map will be written to.
  124611. * @returns The depth map texture
  124612. */
  124613. getDepthMap(): RenderTargetTexture;
  124614. /**
  124615. * Disposes of the depth renderer.
  124616. */
  124617. dispose(): void;
  124618. }
  124619. }
  124620. declare module BABYLON {
  124621. interface Scene {
  124622. /** @hidden (Backing field) */
  124623. _depthRenderer: {
  124624. [id: string]: DepthRenderer;
  124625. };
  124626. /**
  124627. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  124628. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  124629. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124630. * @returns the created depth renderer
  124631. */
  124632. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  124633. /**
  124634. * Disables a depth renderer for a given camera
  124635. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  124636. */
  124637. disableDepthRenderer(camera?: Nullable<Camera>): void;
  124638. }
  124639. /**
  124640. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  124641. * in several rendering techniques.
  124642. */
  124643. export class DepthRendererSceneComponent implements ISceneComponent {
  124644. /**
  124645. * The component name helpfull to identify the component in the list of scene components.
  124646. */
  124647. readonly name: string;
  124648. /**
  124649. * The scene the component belongs to.
  124650. */
  124651. scene: Scene;
  124652. /**
  124653. * Creates a new instance of the component for the given scene
  124654. * @param scene Defines the scene to register the component in
  124655. */
  124656. constructor(scene: Scene);
  124657. /**
  124658. * Registers the component in a given scene
  124659. */
  124660. register(): void;
  124661. /**
  124662. * Rebuilds the elements related to this component in case of
  124663. * context lost for instance.
  124664. */
  124665. rebuild(): void;
  124666. /**
  124667. * Disposes the component and the associated ressources
  124668. */
  124669. dispose(): void;
  124670. private _gatherRenderTargets;
  124671. private _gatherActiveCameraRenderTargets;
  124672. }
  124673. }
  124674. declare module BABYLON {
  124675. /** @hidden */
  124676. export var outlinePixelShader: {
  124677. name: string;
  124678. shader: string;
  124679. };
  124680. }
  124681. declare module BABYLON {
  124682. /** @hidden */
  124683. export var outlineVertexShader: {
  124684. name: string;
  124685. shader: string;
  124686. };
  124687. }
  124688. declare module BABYLON {
  124689. interface Scene {
  124690. /** @hidden */
  124691. _outlineRenderer: OutlineRenderer;
  124692. /**
  124693. * Gets the outline renderer associated with the scene
  124694. * @returns a OutlineRenderer
  124695. */
  124696. getOutlineRenderer(): OutlineRenderer;
  124697. }
  124698. interface AbstractMesh {
  124699. /** @hidden (Backing field) */
  124700. _renderOutline: boolean;
  124701. /**
  124702. * Gets or sets a boolean indicating if the outline must be rendered as well
  124703. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  124704. */
  124705. renderOutline: boolean;
  124706. /** @hidden (Backing field) */
  124707. _renderOverlay: boolean;
  124708. /**
  124709. * Gets or sets a boolean indicating if the overlay must be rendered as well
  124710. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  124711. */
  124712. renderOverlay: boolean;
  124713. }
  124714. /**
  124715. * This class is responsible to draw bothe outline/overlay of meshes.
  124716. * It should not be used directly but through the available method on mesh.
  124717. */
  124718. export class OutlineRenderer implements ISceneComponent {
  124719. /**
  124720. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  124721. */
  124722. private static _StencilReference;
  124723. /**
  124724. * The name of the component. Each component must have a unique name.
  124725. */
  124726. name: string;
  124727. /**
  124728. * The scene the component belongs to.
  124729. */
  124730. scene: Scene;
  124731. /**
  124732. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  124733. */
  124734. zOffset: number;
  124735. private _engine;
  124736. private _effect;
  124737. private _cachedDefines;
  124738. private _savedDepthWrite;
  124739. /**
  124740. * Instantiates a new outline renderer. (There could be only one per scene).
  124741. * @param scene Defines the scene it belongs to
  124742. */
  124743. constructor(scene: Scene);
  124744. /**
  124745. * Register the component to one instance of a scene.
  124746. */
  124747. register(): void;
  124748. /**
  124749. * Rebuilds the elements related to this component in case of
  124750. * context lost for instance.
  124751. */
  124752. rebuild(): void;
  124753. /**
  124754. * Disposes the component and the associated ressources.
  124755. */
  124756. dispose(): void;
  124757. /**
  124758. * Renders the outline in the canvas.
  124759. * @param subMesh Defines the sumesh to render
  124760. * @param batch Defines the batch of meshes in case of instances
  124761. * @param useOverlay Defines if the rendering is for the overlay or the outline
  124762. */
  124763. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  124764. /**
  124765. * Returns whether or not the outline renderer is ready for a given submesh.
  124766. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  124767. * @param subMesh Defines the submesh to check readyness for
  124768. * @param useInstances Defines wheter wee are trying to render instances or not
  124769. * @returns true if ready otherwise false
  124770. */
  124771. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124772. private _beforeRenderingMesh;
  124773. private _afterRenderingMesh;
  124774. }
  124775. }
  124776. declare module BABYLON {
  124777. /**
  124778. * Class used to manage multiple sprites of different sizes on the same spritesheet
  124779. * @see http://doc.babylonjs.com/babylon101/sprites
  124780. */
  124781. export class SpritePackedManager extends SpriteManager {
  124782. /** defines the packed manager's name */
  124783. name: string;
  124784. /**
  124785. * Creates a new sprite manager from a packed sprite sheet
  124786. * @param name defines the manager's name
  124787. * @param imgUrl defines the sprite sheet url
  124788. * @param capacity defines the maximum allowed number of sprites
  124789. * @param scene defines the hosting scene
  124790. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  124791. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  124792. * @param samplingMode defines the smapling mode to use with spritesheet
  124793. * @param fromPacked set to true; do not alter
  124794. */
  124795. constructor(
  124796. /** defines the packed manager's name */
  124797. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  124798. }
  124799. }
  124800. declare module BABYLON {
  124801. /**
  124802. * Defines the list of states available for a task inside a AssetsManager
  124803. */
  124804. export enum AssetTaskState {
  124805. /**
  124806. * Initialization
  124807. */
  124808. INIT = 0,
  124809. /**
  124810. * Running
  124811. */
  124812. RUNNING = 1,
  124813. /**
  124814. * Done
  124815. */
  124816. DONE = 2,
  124817. /**
  124818. * Error
  124819. */
  124820. ERROR = 3
  124821. }
  124822. /**
  124823. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  124824. */
  124825. export abstract class AbstractAssetTask {
  124826. /**
  124827. * Task name
  124828. */ name: string;
  124829. /**
  124830. * Callback called when the task is successful
  124831. */
  124832. onSuccess: (task: any) => void;
  124833. /**
  124834. * Callback called when the task is not successful
  124835. */
  124836. onError: (task: any, message?: string, exception?: any) => void;
  124837. /**
  124838. * Creates a new AssetsManager
  124839. * @param name defines the name of the task
  124840. */
  124841. constructor(
  124842. /**
  124843. * Task name
  124844. */ name: string);
  124845. private _isCompleted;
  124846. private _taskState;
  124847. private _errorObject;
  124848. /**
  124849. * Get if the task is completed
  124850. */
  124851. readonly isCompleted: boolean;
  124852. /**
  124853. * Gets the current state of the task
  124854. */
  124855. readonly taskState: AssetTaskState;
  124856. /**
  124857. * Gets the current error object (if task is in error)
  124858. */
  124859. readonly errorObject: {
  124860. message?: string;
  124861. exception?: any;
  124862. };
  124863. /**
  124864. * Internal only
  124865. * @hidden
  124866. */
  124867. _setErrorObject(message?: string, exception?: any): void;
  124868. /**
  124869. * Execute the current task
  124870. * @param scene defines the scene where you want your assets to be loaded
  124871. * @param onSuccess is a callback called when the task is successfully executed
  124872. * @param onError is a callback called if an error occurs
  124873. */
  124874. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124875. /**
  124876. * Execute the current task
  124877. * @param scene defines the scene where you want your assets to be loaded
  124878. * @param onSuccess is a callback called when the task is successfully executed
  124879. * @param onError is a callback called if an error occurs
  124880. */
  124881. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124882. /**
  124883. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  124884. * This can be used with failed tasks that have the reason for failure fixed.
  124885. */
  124886. reset(): void;
  124887. private onErrorCallback;
  124888. private onDoneCallback;
  124889. }
  124890. /**
  124891. * Define the interface used by progress events raised during assets loading
  124892. */
  124893. export interface IAssetsProgressEvent {
  124894. /**
  124895. * Defines the number of remaining tasks to process
  124896. */
  124897. remainingCount: number;
  124898. /**
  124899. * Defines the total number of tasks
  124900. */
  124901. totalCount: number;
  124902. /**
  124903. * Defines the task that was just processed
  124904. */
  124905. task: AbstractAssetTask;
  124906. }
  124907. /**
  124908. * Class used to share progress information about assets loading
  124909. */
  124910. export class AssetsProgressEvent implements IAssetsProgressEvent {
  124911. /**
  124912. * Defines the number of remaining tasks to process
  124913. */
  124914. remainingCount: number;
  124915. /**
  124916. * Defines the total number of tasks
  124917. */
  124918. totalCount: number;
  124919. /**
  124920. * Defines the task that was just processed
  124921. */
  124922. task: AbstractAssetTask;
  124923. /**
  124924. * Creates a AssetsProgressEvent
  124925. * @param remainingCount defines the number of remaining tasks to process
  124926. * @param totalCount defines the total number of tasks
  124927. * @param task defines the task that was just processed
  124928. */
  124929. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  124930. }
  124931. /**
  124932. * Define a task used by AssetsManager to load meshes
  124933. */
  124934. export class MeshAssetTask extends AbstractAssetTask {
  124935. /**
  124936. * Defines the name of the task
  124937. */
  124938. name: string;
  124939. /**
  124940. * Defines the list of mesh's names you want to load
  124941. */
  124942. meshesNames: any;
  124943. /**
  124944. * Defines the root url to use as a base to load your meshes and associated resources
  124945. */
  124946. rootUrl: string;
  124947. /**
  124948. * Defines the filename of the scene to load from
  124949. */
  124950. sceneFilename: string;
  124951. /**
  124952. * Gets the list of loaded meshes
  124953. */
  124954. loadedMeshes: Array<AbstractMesh>;
  124955. /**
  124956. * Gets the list of loaded particle systems
  124957. */
  124958. loadedParticleSystems: Array<IParticleSystem>;
  124959. /**
  124960. * Gets the list of loaded skeletons
  124961. */
  124962. loadedSkeletons: Array<Skeleton>;
  124963. /**
  124964. * Gets the list of loaded animation groups
  124965. */
  124966. loadedAnimationGroups: Array<AnimationGroup>;
  124967. /**
  124968. * Callback called when the task is successful
  124969. */
  124970. onSuccess: (task: MeshAssetTask) => void;
  124971. /**
  124972. * Callback called when the task is successful
  124973. */
  124974. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  124975. /**
  124976. * Creates a new MeshAssetTask
  124977. * @param name defines the name of the task
  124978. * @param meshesNames defines the list of mesh's names you want to load
  124979. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  124980. * @param sceneFilename defines the filename of the scene to load from
  124981. */
  124982. constructor(
  124983. /**
  124984. * Defines the name of the task
  124985. */
  124986. name: string,
  124987. /**
  124988. * Defines the list of mesh's names you want to load
  124989. */
  124990. meshesNames: any,
  124991. /**
  124992. * Defines the root url to use as a base to load your meshes and associated resources
  124993. */
  124994. rootUrl: string,
  124995. /**
  124996. * Defines the filename of the scene to load from
  124997. */
  124998. sceneFilename: string);
  124999. /**
  125000. * Execute the current task
  125001. * @param scene defines the scene where you want your assets to be loaded
  125002. * @param onSuccess is a callback called when the task is successfully executed
  125003. * @param onError is a callback called if an error occurs
  125004. */
  125005. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125006. }
  125007. /**
  125008. * Define a task used by AssetsManager to load text content
  125009. */
  125010. export class TextFileAssetTask extends AbstractAssetTask {
  125011. /**
  125012. * Defines the name of the task
  125013. */
  125014. name: string;
  125015. /**
  125016. * Defines the location of the file to load
  125017. */
  125018. url: string;
  125019. /**
  125020. * Gets the loaded text string
  125021. */
  125022. text: string;
  125023. /**
  125024. * Callback called when the task is successful
  125025. */
  125026. onSuccess: (task: TextFileAssetTask) => void;
  125027. /**
  125028. * Callback called when the task is successful
  125029. */
  125030. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  125031. /**
  125032. * Creates a new TextFileAssetTask object
  125033. * @param name defines the name of the task
  125034. * @param url defines the location of the file to load
  125035. */
  125036. constructor(
  125037. /**
  125038. * Defines the name of the task
  125039. */
  125040. name: string,
  125041. /**
  125042. * Defines the location of the file to load
  125043. */
  125044. url: string);
  125045. /**
  125046. * Execute the current task
  125047. * @param scene defines the scene where you want your assets to be loaded
  125048. * @param onSuccess is a callback called when the task is successfully executed
  125049. * @param onError is a callback called if an error occurs
  125050. */
  125051. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125052. }
  125053. /**
  125054. * Define a task used by AssetsManager to load binary data
  125055. */
  125056. export class BinaryFileAssetTask extends AbstractAssetTask {
  125057. /**
  125058. * Defines the name of the task
  125059. */
  125060. name: string;
  125061. /**
  125062. * Defines the location of the file to load
  125063. */
  125064. url: string;
  125065. /**
  125066. * Gets the lodaded data (as an array buffer)
  125067. */
  125068. data: ArrayBuffer;
  125069. /**
  125070. * Callback called when the task is successful
  125071. */
  125072. onSuccess: (task: BinaryFileAssetTask) => void;
  125073. /**
  125074. * Callback called when the task is successful
  125075. */
  125076. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  125077. /**
  125078. * Creates a new BinaryFileAssetTask object
  125079. * @param name defines the name of the new task
  125080. * @param url defines the location of the file to load
  125081. */
  125082. constructor(
  125083. /**
  125084. * Defines the name of the task
  125085. */
  125086. name: string,
  125087. /**
  125088. * Defines the location of the file to load
  125089. */
  125090. url: string);
  125091. /**
  125092. * Execute the current task
  125093. * @param scene defines the scene where you want your assets to be loaded
  125094. * @param onSuccess is a callback called when the task is successfully executed
  125095. * @param onError is a callback called if an error occurs
  125096. */
  125097. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125098. }
  125099. /**
  125100. * Define a task used by AssetsManager to load images
  125101. */
  125102. export class ImageAssetTask extends AbstractAssetTask {
  125103. /**
  125104. * Defines the name of the task
  125105. */
  125106. name: string;
  125107. /**
  125108. * Defines the location of the image to load
  125109. */
  125110. url: string;
  125111. /**
  125112. * Gets the loaded images
  125113. */
  125114. image: HTMLImageElement;
  125115. /**
  125116. * Callback called when the task is successful
  125117. */
  125118. onSuccess: (task: ImageAssetTask) => void;
  125119. /**
  125120. * Callback called when the task is successful
  125121. */
  125122. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  125123. /**
  125124. * Creates a new ImageAssetTask
  125125. * @param name defines the name of the task
  125126. * @param url defines the location of the image to load
  125127. */
  125128. constructor(
  125129. /**
  125130. * Defines the name of the task
  125131. */
  125132. name: string,
  125133. /**
  125134. * Defines the location of the image to load
  125135. */
  125136. url: string);
  125137. /**
  125138. * Execute the current task
  125139. * @param scene defines the scene where you want your assets to be loaded
  125140. * @param onSuccess is a callback called when the task is successfully executed
  125141. * @param onError is a callback called if an error occurs
  125142. */
  125143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125144. }
  125145. /**
  125146. * Defines the interface used by texture loading tasks
  125147. */
  125148. export interface ITextureAssetTask<TEX extends BaseTexture> {
  125149. /**
  125150. * Gets the loaded texture
  125151. */
  125152. texture: TEX;
  125153. }
  125154. /**
  125155. * Define a task used by AssetsManager to load 2D textures
  125156. */
  125157. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  125158. /**
  125159. * Defines the name of the task
  125160. */
  125161. name: string;
  125162. /**
  125163. * Defines the location of the file to load
  125164. */
  125165. url: string;
  125166. /**
  125167. * Defines if mipmap should not be generated (default is false)
  125168. */
  125169. noMipmap?: boolean | undefined;
  125170. /**
  125171. * Defines if texture must be inverted on Y axis (default is false)
  125172. */
  125173. invertY?: boolean | undefined;
  125174. /**
  125175. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125176. */
  125177. samplingMode: number;
  125178. /**
  125179. * Gets the loaded texture
  125180. */
  125181. texture: Texture;
  125182. /**
  125183. * Callback called when the task is successful
  125184. */
  125185. onSuccess: (task: TextureAssetTask) => void;
  125186. /**
  125187. * Callback called when the task is successful
  125188. */
  125189. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  125190. /**
  125191. * Creates a new TextureAssetTask object
  125192. * @param name defines the name of the task
  125193. * @param url defines the location of the file to load
  125194. * @param noMipmap defines if mipmap should not be generated (default is false)
  125195. * @param invertY defines if texture must be inverted on Y axis (default is false)
  125196. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125197. */
  125198. constructor(
  125199. /**
  125200. * Defines the name of the task
  125201. */
  125202. name: string,
  125203. /**
  125204. * Defines the location of the file to load
  125205. */
  125206. url: string,
  125207. /**
  125208. * Defines if mipmap should not be generated (default is false)
  125209. */
  125210. noMipmap?: boolean | undefined,
  125211. /**
  125212. * Defines if texture must be inverted on Y axis (default is false)
  125213. */
  125214. invertY?: boolean | undefined,
  125215. /**
  125216. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125217. */
  125218. samplingMode?: number);
  125219. /**
  125220. * Execute the current task
  125221. * @param scene defines the scene where you want your assets to be loaded
  125222. * @param onSuccess is a callback called when the task is successfully executed
  125223. * @param onError is a callback called if an error occurs
  125224. */
  125225. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125226. }
  125227. /**
  125228. * Define a task used by AssetsManager to load cube textures
  125229. */
  125230. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  125231. /**
  125232. * Defines the name of the task
  125233. */
  125234. name: string;
  125235. /**
  125236. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125237. */
  125238. url: string;
  125239. /**
  125240. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125241. */
  125242. extensions?: string[] | undefined;
  125243. /**
  125244. * Defines if mipmaps should not be generated (default is false)
  125245. */
  125246. noMipmap?: boolean | undefined;
  125247. /**
  125248. * Defines the explicit list of files (undefined by default)
  125249. */
  125250. files?: string[] | undefined;
  125251. /**
  125252. * Gets the loaded texture
  125253. */
  125254. texture: CubeTexture;
  125255. /**
  125256. * Callback called when the task is successful
  125257. */
  125258. onSuccess: (task: CubeTextureAssetTask) => void;
  125259. /**
  125260. * Callback called when the task is successful
  125261. */
  125262. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  125263. /**
  125264. * Creates a new CubeTextureAssetTask
  125265. * @param name defines the name of the task
  125266. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125267. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125268. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125269. * @param files defines the explicit list of files (undefined by default)
  125270. */
  125271. constructor(
  125272. /**
  125273. * Defines the name of the task
  125274. */
  125275. name: string,
  125276. /**
  125277. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125278. */
  125279. url: string,
  125280. /**
  125281. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125282. */
  125283. extensions?: string[] | undefined,
  125284. /**
  125285. * Defines if mipmaps should not be generated (default is false)
  125286. */
  125287. noMipmap?: boolean | undefined,
  125288. /**
  125289. * Defines the explicit list of files (undefined by default)
  125290. */
  125291. files?: string[] | undefined);
  125292. /**
  125293. * Execute the current task
  125294. * @param scene defines the scene where you want your assets to be loaded
  125295. * @param onSuccess is a callback called when the task is successfully executed
  125296. * @param onError is a callback called if an error occurs
  125297. */
  125298. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125299. }
  125300. /**
  125301. * Define a task used by AssetsManager to load HDR cube textures
  125302. */
  125303. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  125304. /**
  125305. * Defines the name of the task
  125306. */
  125307. name: string;
  125308. /**
  125309. * Defines the location of the file to load
  125310. */
  125311. url: string;
  125312. /**
  125313. * Defines the desired size (the more it increases the longer the generation will be)
  125314. */
  125315. size: number;
  125316. /**
  125317. * Defines if mipmaps should not be generated (default is false)
  125318. */
  125319. noMipmap: boolean;
  125320. /**
  125321. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125322. */
  125323. generateHarmonics: boolean;
  125324. /**
  125325. * 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)
  125326. */
  125327. gammaSpace: boolean;
  125328. /**
  125329. * Internal Use Only
  125330. */
  125331. reserved: boolean;
  125332. /**
  125333. * Gets the loaded texture
  125334. */
  125335. texture: HDRCubeTexture;
  125336. /**
  125337. * Callback called when the task is successful
  125338. */
  125339. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  125340. /**
  125341. * Callback called when the task is successful
  125342. */
  125343. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  125344. /**
  125345. * Creates a new HDRCubeTextureAssetTask object
  125346. * @param name defines the name of the task
  125347. * @param url defines the location of the file to load
  125348. * @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.
  125349. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125350. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125351. * @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)
  125352. * @param reserved Internal use only
  125353. */
  125354. constructor(
  125355. /**
  125356. * Defines the name of the task
  125357. */
  125358. name: string,
  125359. /**
  125360. * Defines the location of the file to load
  125361. */
  125362. url: string,
  125363. /**
  125364. * Defines the desired size (the more it increases the longer the generation will be)
  125365. */
  125366. size: number,
  125367. /**
  125368. * Defines if mipmaps should not be generated (default is false)
  125369. */
  125370. noMipmap?: boolean,
  125371. /**
  125372. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125373. */
  125374. generateHarmonics?: boolean,
  125375. /**
  125376. * 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)
  125377. */
  125378. gammaSpace?: boolean,
  125379. /**
  125380. * Internal Use Only
  125381. */
  125382. reserved?: boolean);
  125383. /**
  125384. * Execute the current task
  125385. * @param scene defines the scene where you want your assets to be loaded
  125386. * @param onSuccess is a callback called when the task is successfully executed
  125387. * @param onError is a callback called if an error occurs
  125388. */
  125389. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125390. }
  125391. /**
  125392. * Define a task used by AssetsManager to load Equirectangular cube textures
  125393. */
  125394. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  125395. /**
  125396. * Defines the name of the task
  125397. */
  125398. name: string;
  125399. /**
  125400. * Defines the location of the file to load
  125401. */
  125402. url: string;
  125403. /**
  125404. * Defines the desired size (the more it increases the longer the generation will be)
  125405. */
  125406. size: number;
  125407. /**
  125408. * Defines if mipmaps should not be generated (default is false)
  125409. */
  125410. noMipmap: boolean;
  125411. /**
  125412. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  125413. * but the standard material would require them in Gamma space) (default is true)
  125414. */
  125415. gammaSpace: boolean;
  125416. /**
  125417. * Gets the loaded texture
  125418. */
  125419. texture: EquiRectangularCubeTexture;
  125420. /**
  125421. * Callback called when the task is successful
  125422. */
  125423. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  125424. /**
  125425. * Callback called when the task is successful
  125426. */
  125427. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  125428. /**
  125429. * Creates a new EquiRectangularCubeTextureAssetTask object
  125430. * @param name defines the name of the task
  125431. * @param url defines the location of the file to load
  125432. * @param size defines the desired size (the more it increases the longer the generation will be)
  125433. * If the size is omitted this implies you are using a preprocessed cubemap.
  125434. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125435. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  125436. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  125437. * (default is true)
  125438. */
  125439. constructor(
  125440. /**
  125441. * Defines the name of the task
  125442. */
  125443. name: string,
  125444. /**
  125445. * Defines the location of the file to load
  125446. */
  125447. url: string,
  125448. /**
  125449. * Defines the desired size (the more it increases the longer the generation will be)
  125450. */
  125451. size: number,
  125452. /**
  125453. * Defines if mipmaps should not be generated (default is false)
  125454. */
  125455. noMipmap?: boolean,
  125456. /**
  125457. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  125458. * but the standard material would require them in Gamma space) (default is true)
  125459. */
  125460. gammaSpace?: boolean);
  125461. /**
  125462. * Execute the current task
  125463. * @param scene defines the scene where you want your assets to be loaded
  125464. * @param onSuccess is a callback called when the task is successfully executed
  125465. * @param onError is a callback called if an error occurs
  125466. */
  125467. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125468. }
  125469. /**
  125470. * This class can be used to easily import assets into a scene
  125471. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  125472. */
  125473. export class AssetsManager {
  125474. private _scene;
  125475. private _isLoading;
  125476. protected _tasks: AbstractAssetTask[];
  125477. protected _waitingTasksCount: number;
  125478. protected _totalTasksCount: number;
  125479. /**
  125480. * Callback called when all tasks are processed
  125481. */
  125482. onFinish: (tasks: AbstractAssetTask[]) => void;
  125483. /**
  125484. * Callback called when a task is successful
  125485. */
  125486. onTaskSuccess: (task: AbstractAssetTask) => void;
  125487. /**
  125488. * Callback called when a task had an error
  125489. */
  125490. onTaskError: (task: AbstractAssetTask) => void;
  125491. /**
  125492. * Callback called when a task is done (whatever the result is)
  125493. */
  125494. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  125495. /**
  125496. * Observable called when all tasks are processed
  125497. */
  125498. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  125499. /**
  125500. * Observable called when a task had an error
  125501. */
  125502. onTaskErrorObservable: Observable<AbstractAssetTask>;
  125503. /**
  125504. * Observable called when all tasks were executed
  125505. */
  125506. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  125507. /**
  125508. * Observable called when a task is done (whatever the result is)
  125509. */
  125510. onProgressObservable: Observable<IAssetsProgressEvent>;
  125511. /**
  125512. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  125513. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  125514. */
  125515. useDefaultLoadingScreen: boolean;
  125516. /**
  125517. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  125518. * when all assets have been downloaded.
  125519. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  125520. */
  125521. autoHideLoadingUI: boolean;
  125522. /**
  125523. * Creates a new AssetsManager
  125524. * @param scene defines the scene to work on
  125525. */
  125526. constructor(scene: Scene);
  125527. /**
  125528. * Add a MeshAssetTask to the list of active tasks
  125529. * @param taskName defines the name of the new task
  125530. * @param meshesNames defines the name of meshes to load
  125531. * @param rootUrl defines the root url to use to locate files
  125532. * @param sceneFilename defines the filename of the scene file
  125533. * @returns a new MeshAssetTask object
  125534. */
  125535. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  125536. /**
  125537. * Add a TextFileAssetTask to the list of active tasks
  125538. * @param taskName defines the name of the new task
  125539. * @param url defines the url of the file to load
  125540. * @returns a new TextFileAssetTask object
  125541. */
  125542. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  125543. /**
  125544. * Add a BinaryFileAssetTask to the list of active tasks
  125545. * @param taskName defines the name of the new task
  125546. * @param url defines the url of the file to load
  125547. * @returns a new BinaryFileAssetTask object
  125548. */
  125549. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  125550. /**
  125551. * Add a ImageAssetTask to the list of active tasks
  125552. * @param taskName defines the name of the new task
  125553. * @param url defines the url of the file to load
  125554. * @returns a new ImageAssetTask object
  125555. */
  125556. addImageTask(taskName: string, url: string): ImageAssetTask;
  125557. /**
  125558. * Add a TextureAssetTask to the list of active tasks
  125559. * @param taskName defines the name of the new task
  125560. * @param url defines the url of the file to load
  125561. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125562. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  125563. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125564. * @returns a new TextureAssetTask object
  125565. */
  125566. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  125567. /**
  125568. * Add a CubeTextureAssetTask to the list of active tasks
  125569. * @param taskName defines the name of the new task
  125570. * @param url defines the url of the file to load
  125571. * @param extensions defines the extension to use to load the cube map (can be null)
  125572. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125573. * @param files defines the list of files to load (can be null)
  125574. * @returns a new CubeTextureAssetTask object
  125575. */
  125576. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  125577. /**
  125578. *
  125579. * Add a HDRCubeTextureAssetTask to the list of active tasks
  125580. * @param taskName defines the name of the new task
  125581. * @param url defines the url of the file to load
  125582. * @param size defines the size you want for the cubemap (can be null)
  125583. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125584. * @param generateHarmonics defines if you want to automatically generate (true by default)
  125585. * @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)
  125586. * @param reserved Internal use only
  125587. * @returns a new HDRCubeTextureAssetTask object
  125588. */
  125589. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  125590. /**
  125591. *
  125592. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  125593. * @param taskName defines the name of the new task
  125594. * @param url defines the url of the file to load
  125595. * @param size defines the size you want for the cubemap (can be null)
  125596. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125597. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  125598. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  125599. * @returns a new EquiRectangularCubeTextureAssetTask object
  125600. */
  125601. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  125602. /**
  125603. * Remove a task from the assets manager.
  125604. * @param task the task to remove
  125605. */
  125606. removeTask(task: AbstractAssetTask): void;
  125607. private _decreaseWaitingTasksCount;
  125608. private _runTask;
  125609. /**
  125610. * Reset the AssetsManager and remove all tasks
  125611. * @return the current instance of the AssetsManager
  125612. */
  125613. reset(): AssetsManager;
  125614. /**
  125615. * Start the loading process
  125616. * @return the current instance of the AssetsManager
  125617. */
  125618. load(): AssetsManager;
  125619. /**
  125620. * Start the loading process as an async operation
  125621. * @return a promise returning the list of failed tasks
  125622. */
  125623. loadAsync(): Promise<void>;
  125624. }
  125625. }
  125626. declare module BABYLON {
  125627. /**
  125628. * Wrapper class for promise with external resolve and reject.
  125629. */
  125630. export class Deferred<T> {
  125631. /**
  125632. * The promise associated with this deferred object.
  125633. */
  125634. readonly promise: Promise<T>;
  125635. private _resolve;
  125636. private _reject;
  125637. /**
  125638. * The resolve method of the promise associated with this deferred object.
  125639. */
  125640. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  125641. /**
  125642. * The reject method of the promise associated with this deferred object.
  125643. */
  125644. readonly reject: (reason?: any) => void;
  125645. /**
  125646. * Constructor for this deferred object.
  125647. */
  125648. constructor();
  125649. }
  125650. }
  125651. declare module BABYLON {
  125652. /**
  125653. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  125654. */
  125655. export class MeshExploder {
  125656. private _centerMesh;
  125657. private _meshes;
  125658. private _meshesOrigins;
  125659. private _toCenterVectors;
  125660. private _scaledDirection;
  125661. private _newPosition;
  125662. private _centerPosition;
  125663. /**
  125664. * Explodes meshes from a center mesh.
  125665. * @param meshes The meshes to explode.
  125666. * @param centerMesh The mesh to be center of explosion.
  125667. */
  125668. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  125669. private _setCenterMesh;
  125670. /**
  125671. * Get class name
  125672. * @returns "MeshExploder"
  125673. */
  125674. getClassName(): string;
  125675. /**
  125676. * "Exploded meshes"
  125677. * @returns Array of meshes with the centerMesh at index 0.
  125678. */
  125679. getMeshes(): Array<Mesh>;
  125680. /**
  125681. * Explodes meshes giving a specific direction
  125682. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  125683. */
  125684. explode(direction?: number): void;
  125685. }
  125686. }
  125687. declare module BABYLON {
  125688. /**
  125689. * Class used to help managing file picking and drag'n'drop
  125690. */
  125691. export class FilesInput {
  125692. /**
  125693. * List of files ready to be loaded
  125694. */
  125695. static readonly FilesToLoad: {
  125696. [key: string]: File;
  125697. };
  125698. /**
  125699. * Callback called when a file is processed
  125700. */
  125701. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  125702. private _engine;
  125703. private _currentScene;
  125704. private _sceneLoadedCallback;
  125705. private _progressCallback;
  125706. private _additionalRenderLoopLogicCallback;
  125707. private _textureLoadingCallback;
  125708. private _startingProcessingFilesCallback;
  125709. private _onReloadCallback;
  125710. private _errorCallback;
  125711. private _elementToMonitor;
  125712. private _sceneFileToLoad;
  125713. private _filesToLoad;
  125714. /**
  125715. * Creates a new FilesInput
  125716. * @param engine defines the rendering engine
  125717. * @param scene defines the hosting scene
  125718. * @param sceneLoadedCallback callback called when scene is loaded
  125719. * @param progressCallback callback called to track progress
  125720. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  125721. * @param textureLoadingCallback callback called when a texture is loading
  125722. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  125723. * @param onReloadCallback callback called when a reload is requested
  125724. * @param errorCallback callback call if an error occurs
  125725. */
  125726. 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);
  125727. private _dragEnterHandler;
  125728. private _dragOverHandler;
  125729. private _dropHandler;
  125730. /**
  125731. * Calls this function to listen to drag'n'drop events on a specific DOM element
  125732. * @param elementToMonitor defines the DOM element to track
  125733. */
  125734. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  125735. /**
  125736. * Release all associated resources
  125737. */
  125738. dispose(): void;
  125739. private renderFunction;
  125740. private drag;
  125741. private drop;
  125742. private _traverseFolder;
  125743. private _processFiles;
  125744. /**
  125745. * Load files from a drop event
  125746. * @param event defines the drop event to use as source
  125747. */
  125748. loadFiles(event: any): void;
  125749. private _processReload;
  125750. /**
  125751. * Reload the current scene from the loaded files
  125752. */
  125753. reload(): void;
  125754. }
  125755. }
  125756. declare module BABYLON {
  125757. /**
  125758. * Defines the root class used to create scene optimization to use with SceneOptimizer
  125759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125760. */
  125761. export class SceneOptimization {
  125762. /**
  125763. * Defines the priority of this optimization (0 by default which means first in the list)
  125764. */
  125765. priority: number;
  125766. /**
  125767. * Gets a string describing the action executed by the current optimization
  125768. * @returns description string
  125769. */
  125770. getDescription(): string;
  125771. /**
  125772. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125773. * @param scene defines the current scene where to apply this optimization
  125774. * @param optimizer defines the current optimizer
  125775. * @returns true if everything that can be done was applied
  125776. */
  125777. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125778. /**
  125779. * Creates the SceneOptimization object
  125780. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125781. * @param desc defines the description associated with the optimization
  125782. */
  125783. constructor(
  125784. /**
  125785. * Defines the priority of this optimization (0 by default which means first in the list)
  125786. */
  125787. priority?: number);
  125788. }
  125789. /**
  125790. * Defines an optimization used to reduce the size of render target textures
  125791. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125792. */
  125793. export class TextureOptimization extends SceneOptimization {
  125794. /**
  125795. * Defines the priority of this optimization (0 by default which means first in the list)
  125796. */
  125797. priority: number;
  125798. /**
  125799. * 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
  125800. */
  125801. maximumSize: number;
  125802. /**
  125803. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125804. */
  125805. step: number;
  125806. /**
  125807. * Gets a string describing the action executed by the current optimization
  125808. * @returns description string
  125809. */
  125810. getDescription(): string;
  125811. /**
  125812. * Creates the TextureOptimization object
  125813. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125814. * @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
  125815. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125816. */
  125817. constructor(
  125818. /**
  125819. * Defines the priority of this optimization (0 by default which means first in the list)
  125820. */
  125821. priority?: number,
  125822. /**
  125823. * 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
  125824. */
  125825. maximumSize?: number,
  125826. /**
  125827. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125828. */
  125829. step?: number);
  125830. /**
  125831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125832. * @param scene defines the current scene where to apply this optimization
  125833. * @param optimizer defines the current optimizer
  125834. * @returns true if everything that can be done was applied
  125835. */
  125836. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125837. }
  125838. /**
  125839. * Defines an optimization used to increase or decrease the rendering resolution
  125840. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125841. */
  125842. export class HardwareScalingOptimization extends SceneOptimization {
  125843. /**
  125844. * Defines the priority of this optimization (0 by default which means first in the list)
  125845. */
  125846. priority: number;
  125847. /**
  125848. * Defines the maximum scale to use (2 by default)
  125849. */
  125850. maximumScale: number;
  125851. /**
  125852. * Defines the step to use between two passes (0.5 by default)
  125853. */
  125854. step: number;
  125855. private _currentScale;
  125856. private _directionOffset;
  125857. /**
  125858. * Gets a string describing the action executed by the current optimization
  125859. * @return description string
  125860. */
  125861. getDescription(): string;
  125862. /**
  125863. * Creates the HardwareScalingOptimization object
  125864. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125865. * @param maximumScale defines the maximum scale to use (2 by default)
  125866. * @param step defines the step to use between two passes (0.5 by default)
  125867. */
  125868. constructor(
  125869. /**
  125870. * Defines the priority of this optimization (0 by default which means first in the list)
  125871. */
  125872. priority?: number,
  125873. /**
  125874. * Defines the maximum scale to use (2 by default)
  125875. */
  125876. maximumScale?: number,
  125877. /**
  125878. * Defines the step to use between two passes (0.5 by default)
  125879. */
  125880. step?: number);
  125881. /**
  125882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125883. * @param scene defines the current scene where to apply this optimization
  125884. * @param optimizer defines the current optimizer
  125885. * @returns true if everything that can be done was applied
  125886. */
  125887. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125888. }
  125889. /**
  125890. * Defines an optimization used to remove shadows
  125891. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125892. */
  125893. export class ShadowsOptimization extends SceneOptimization {
  125894. /**
  125895. * Gets a string describing the action executed by the current optimization
  125896. * @return description string
  125897. */
  125898. getDescription(): string;
  125899. /**
  125900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125901. * @param scene defines the current scene where to apply this optimization
  125902. * @param optimizer defines the current optimizer
  125903. * @returns true if everything that can be done was applied
  125904. */
  125905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125906. }
  125907. /**
  125908. * Defines an optimization used to turn post-processes off
  125909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125910. */
  125911. export class PostProcessesOptimization extends SceneOptimization {
  125912. /**
  125913. * Gets a string describing the action executed by the current optimization
  125914. * @return description string
  125915. */
  125916. getDescription(): string;
  125917. /**
  125918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125919. * @param scene defines the current scene where to apply this optimization
  125920. * @param optimizer defines the current optimizer
  125921. * @returns true if everything that can be done was applied
  125922. */
  125923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125924. }
  125925. /**
  125926. * Defines an optimization used to turn lens flares off
  125927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125928. */
  125929. export class LensFlaresOptimization extends SceneOptimization {
  125930. /**
  125931. * Gets a string describing the action executed by the current optimization
  125932. * @return description string
  125933. */
  125934. getDescription(): string;
  125935. /**
  125936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125937. * @param scene defines the current scene where to apply this optimization
  125938. * @param optimizer defines the current optimizer
  125939. * @returns true if everything that can be done was applied
  125940. */
  125941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125942. }
  125943. /**
  125944. * Defines an optimization based on user defined callback.
  125945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125946. */
  125947. export class CustomOptimization extends SceneOptimization {
  125948. /**
  125949. * Callback called to apply the custom optimization.
  125950. */
  125951. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  125952. /**
  125953. * Callback called to get custom description
  125954. */
  125955. onGetDescription: () => string;
  125956. /**
  125957. * Gets a string describing the action executed by the current optimization
  125958. * @returns description string
  125959. */
  125960. getDescription(): string;
  125961. /**
  125962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125963. * @param scene defines the current scene where to apply this optimization
  125964. * @param optimizer defines the current optimizer
  125965. * @returns true if everything that can be done was applied
  125966. */
  125967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125968. }
  125969. /**
  125970. * Defines an optimization used to turn particles off
  125971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125972. */
  125973. export class ParticlesOptimization extends SceneOptimization {
  125974. /**
  125975. * Gets a string describing the action executed by the current optimization
  125976. * @return description string
  125977. */
  125978. getDescription(): string;
  125979. /**
  125980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125981. * @param scene defines the current scene where to apply this optimization
  125982. * @param optimizer defines the current optimizer
  125983. * @returns true if everything that can be done was applied
  125984. */
  125985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125986. }
  125987. /**
  125988. * Defines an optimization used to turn render targets off
  125989. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125990. */
  125991. export class RenderTargetsOptimization extends SceneOptimization {
  125992. /**
  125993. * Gets a string describing the action executed by the current optimization
  125994. * @return description string
  125995. */
  125996. getDescription(): string;
  125997. /**
  125998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125999. * @param scene defines the current scene where to apply this optimization
  126000. * @param optimizer defines the current optimizer
  126001. * @returns true if everything that can be done was applied
  126002. */
  126003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126004. }
  126005. /**
  126006. * Defines an optimization used to merge meshes with compatible materials
  126007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126008. */
  126009. export class MergeMeshesOptimization extends SceneOptimization {
  126010. private static _UpdateSelectionTree;
  126011. /**
  126012. * Gets or sets a boolean which defines if optimization octree has to be updated
  126013. */
  126014. /**
  126015. * Gets or sets a boolean which defines if optimization octree has to be updated
  126016. */
  126017. static UpdateSelectionTree: boolean;
  126018. /**
  126019. * Gets a string describing the action executed by the current optimization
  126020. * @return description string
  126021. */
  126022. getDescription(): string;
  126023. private _canBeMerged;
  126024. /**
  126025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126026. * @param scene defines the current scene where to apply this optimization
  126027. * @param optimizer defines the current optimizer
  126028. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  126029. * @returns true if everything that can be done was applied
  126030. */
  126031. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  126032. }
  126033. /**
  126034. * Defines a list of options used by SceneOptimizer
  126035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126036. */
  126037. export class SceneOptimizerOptions {
  126038. /**
  126039. * Defines the target frame rate to reach (60 by default)
  126040. */
  126041. targetFrameRate: number;
  126042. /**
  126043. * Defines the interval between two checkes (2000ms by default)
  126044. */
  126045. trackerDuration: number;
  126046. /**
  126047. * Gets the list of optimizations to apply
  126048. */
  126049. optimizations: SceneOptimization[];
  126050. /**
  126051. * Creates a new list of options used by SceneOptimizer
  126052. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  126053. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  126054. */
  126055. constructor(
  126056. /**
  126057. * Defines the target frame rate to reach (60 by default)
  126058. */
  126059. targetFrameRate?: number,
  126060. /**
  126061. * Defines the interval between two checkes (2000ms by default)
  126062. */
  126063. trackerDuration?: number);
  126064. /**
  126065. * Add a new optimization
  126066. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  126067. * @returns the current SceneOptimizerOptions
  126068. */
  126069. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  126070. /**
  126071. * Add a new custom optimization
  126072. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  126073. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  126074. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126075. * @returns the current SceneOptimizerOptions
  126076. */
  126077. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  126078. /**
  126079. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  126080. * @param targetFrameRate defines the target frame rate (60 by default)
  126081. * @returns a SceneOptimizerOptions object
  126082. */
  126083. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126084. /**
  126085. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  126086. * @param targetFrameRate defines the target frame rate (60 by default)
  126087. * @returns a SceneOptimizerOptions object
  126088. */
  126089. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126090. /**
  126091. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  126092. * @param targetFrameRate defines the target frame rate (60 by default)
  126093. * @returns a SceneOptimizerOptions object
  126094. */
  126095. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126096. }
  126097. /**
  126098. * Class used to run optimizations in order to reach a target frame rate
  126099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126100. */
  126101. export class SceneOptimizer implements IDisposable {
  126102. private _isRunning;
  126103. private _options;
  126104. private _scene;
  126105. private _currentPriorityLevel;
  126106. private _targetFrameRate;
  126107. private _trackerDuration;
  126108. private _currentFrameRate;
  126109. private _sceneDisposeObserver;
  126110. private _improvementMode;
  126111. /**
  126112. * Defines an observable called when the optimizer reaches the target frame rate
  126113. */
  126114. onSuccessObservable: Observable<SceneOptimizer>;
  126115. /**
  126116. * Defines an observable called when the optimizer enables an optimization
  126117. */
  126118. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  126119. /**
  126120. * Defines an observable called when the optimizer is not able to reach the target frame rate
  126121. */
  126122. onFailureObservable: Observable<SceneOptimizer>;
  126123. /**
  126124. * Gets a boolean indicating if the optimizer is in improvement mode
  126125. */
  126126. readonly isInImprovementMode: boolean;
  126127. /**
  126128. * Gets the current priority level (0 at start)
  126129. */
  126130. readonly currentPriorityLevel: number;
  126131. /**
  126132. * Gets the current frame rate checked by the SceneOptimizer
  126133. */
  126134. readonly currentFrameRate: number;
  126135. /**
  126136. * Gets or sets the current target frame rate (60 by default)
  126137. */
  126138. /**
  126139. * Gets or sets the current target frame rate (60 by default)
  126140. */
  126141. targetFrameRate: number;
  126142. /**
  126143. * Gets or sets the current interval between two checks (every 2000ms by default)
  126144. */
  126145. /**
  126146. * Gets or sets the current interval between two checks (every 2000ms by default)
  126147. */
  126148. trackerDuration: number;
  126149. /**
  126150. * Gets the list of active optimizations
  126151. */
  126152. readonly optimizations: SceneOptimization[];
  126153. /**
  126154. * Creates a new SceneOptimizer
  126155. * @param scene defines the scene to work on
  126156. * @param options defines the options to use with the SceneOptimizer
  126157. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  126158. * @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)
  126159. */
  126160. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  126161. /**
  126162. * Stops the current optimizer
  126163. */
  126164. stop(): void;
  126165. /**
  126166. * Reset the optimizer to initial step (current priority level = 0)
  126167. */
  126168. reset(): void;
  126169. /**
  126170. * Start the optimizer. By default it will try to reach a specific framerate
  126171. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  126172. */
  126173. start(): void;
  126174. private _checkCurrentState;
  126175. /**
  126176. * Release all resources
  126177. */
  126178. dispose(): void;
  126179. /**
  126180. * Helper function to create a SceneOptimizer with one single line of code
  126181. * @param scene defines the scene to work on
  126182. * @param options defines the options to use with the SceneOptimizer
  126183. * @param onSuccess defines a callback to call on success
  126184. * @param onFailure defines a callback to call on failure
  126185. * @returns the new SceneOptimizer object
  126186. */
  126187. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  126188. }
  126189. }
  126190. declare module BABYLON {
  126191. /**
  126192. * Class used to serialize a scene into a string
  126193. */
  126194. export class SceneSerializer {
  126195. /**
  126196. * Clear cache used by a previous serialization
  126197. */
  126198. static ClearCache(): void;
  126199. /**
  126200. * Serialize a scene into a JSON compatible object
  126201. * @param scene defines the scene to serialize
  126202. * @returns a JSON compatible object
  126203. */
  126204. static Serialize(scene: Scene): any;
  126205. /**
  126206. * Serialize a mesh into a JSON compatible object
  126207. * @param toSerialize defines the mesh to serialize
  126208. * @param withParents defines if parents must be serialized as well
  126209. * @param withChildren defines if children must be serialized as well
  126210. * @returns a JSON compatible object
  126211. */
  126212. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  126213. }
  126214. }
  126215. declare module BABYLON {
  126216. /**
  126217. * Class used to host texture specific utilities
  126218. */
  126219. export class TextureTools {
  126220. /**
  126221. * Uses the GPU to create a copy texture rescaled at a given size
  126222. * @param texture Texture to copy from
  126223. * @param width defines the desired width
  126224. * @param height defines the desired height
  126225. * @param useBilinearMode defines if bilinear mode has to be used
  126226. * @return the generated texture
  126227. */
  126228. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  126229. }
  126230. }
  126231. declare module BABYLON {
  126232. /**
  126233. * This represents the different options available for the video capture.
  126234. */
  126235. export interface VideoRecorderOptions {
  126236. /** Defines the mime type of the video. */
  126237. mimeType: string;
  126238. /** Defines the FPS the video should be recorded at. */
  126239. fps: number;
  126240. /** Defines the chunk size for the recording data. */
  126241. recordChunckSize: number;
  126242. /** The audio tracks to attach to the recording. */
  126243. audioTracks?: MediaStreamTrack[];
  126244. }
  126245. /**
  126246. * This can help with recording videos from BabylonJS.
  126247. * This is based on the available WebRTC functionalities of the browser.
  126248. *
  126249. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  126250. */
  126251. export class VideoRecorder {
  126252. private static readonly _defaultOptions;
  126253. /**
  126254. * Returns whether or not the VideoRecorder is available in your browser.
  126255. * @param engine Defines the Babylon Engine.
  126256. * @returns true if supported otherwise false.
  126257. */
  126258. static IsSupported(engine: Engine): boolean;
  126259. private readonly _options;
  126260. private _canvas;
  126261. private _mediaRecorder;
  126262. private _recordedChunks;
  126263. private _fileName;
  126264. private _resolve;
  126265. private _reject;
  126266. /**
  126267. * True when a recording is already in progress.
  126268. */
  126269. readonly isRecording: boolean;
  126270. /**
  126271. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  126272. * @param engine Defines the BabylonJS Engine you wish to record.
  126273. * @param options Defines options that can be used to customize the capture.
  126274. */
  126275. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  126276. /**
  126277. * Stops the current recording before the default capture timeout passed in the startRecording function.
  126278. */
  126279. stopRecording(): void;
  126280. /**
  126281. * Starts recording the canvas for a max duration specified in parameters.
  126282. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  126283. * If null no automatic download will start and you can rely on the promise to get the data back.
  126284. * @param maxDuration Defines the maximum recording time in seconds.
  126285. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  126286. * @return A promise callback at the end of the recording with the video data in Blob.
  126287. */
  126288. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  126289. /**
  126290. * Releases internal resources used during the recording.
  126291. */
  126292. dispose(): void;
  126293. private _handleDataAvailable;
  126294. private _handleError;
  126295. private _handleStop;
  126296. }
  126297. }
  126298. declare module BABYLON {
  126299. /**
  126300. * Class containing a set of static utilities functions for screenshots
  126301. */
  126302. export class ScreenshotTools {
  126303. /**
  126304. * Captures a screenshot of the current rendering
  126305. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126306. * @param engine defines the rendering engine
  126307. * @param camera defines the source camera
  126308. * @param size This parameter can be set to a single number or to an object with the
  126309. * following (optional) properties: precision, width, height. If a single number is passed,
  126310. * it will be used for both width and height. If an object is passed, the screenshot size
  126311. * will be derived from the parameters. The precision property is a multiplier allowing
  126312. * rendering at a higher or lower resolution
  126313. * @param successCallback defines the callback receives a single parameter which contains the
  126314. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  126315. * src parameter of an <img> to display it
  126316. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  126317. * Check your browser for supported MIME types
  126318. */
  126319. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  126320. /**
  126321. * Captures a screenshot of the current rendering
  126322. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126323. * @param engine defines the rendering engine
  126324. * @param camera defines the source camera
  126325. * @param size This parameter can be set to a single number or to an object with the
  126326. * following (optional) properties: precision, width, height. If a single number is passed,
  126327. * it will be used for both width and height. If an object is passed, the screenshot size
  126328. * will be derived from the parameters. The precision property is a multiplier allowing
  126329. * rendering at a higher or lower resolution
  126330. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  126331. * Check your browser for supported MIME types
  126332. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  126333. * to the src parameter of an <img> to display it
  126334. */
  126335. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  126336. /**
  126337. * Generates an image screenshot from the specified camera.
  126338. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126339. * @param engine The engine to use for rendering
  126340. * @param camera The camera to use for rendering
  126341. * @param size This parameter can be set to a single number or to an object with the
  126342. * following (optional) properties: precision, width, height. If a single number is passed,
  126343. * it will be used for both width and height. If an object is passed, the screenshot size
  126344. * will be derived from the parameters. The precision property is a multiplier allowing
  126345. * rendering at a higher or lower resolution
  126346. * @param successCallback The callback receives a single parameter which contains the
  126347. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  126348. * src parameter of an <img> to display it
  126349. * @param mimeType The MIME type of the screenshot image (default: image/png).
  126350. * Check your browser for supported MIME types
  126351. * @param samples Texture samples (default: 1)
  126352. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  126353. * @param fileName A name for for the downloaded file.
  126354. */
  126355. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  126356. /**
  126357. * Generates an image screenshot from the specified camera.
  126358. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126359. * @param engine The engine to use for rendering
  126360. * @param camera The camera to use for rendering
  126361. * @param size This parameter can be set to a single number or to an object with the
  126362. * following (optional) properties: precision, width, height. If a single number is passed,
  126363. * it will be used for both width and height. If an object is passed, the screenshot size
  126364. * will be derived from the parameters. The precision property is a multiplier allowing
  126365. * rendering at a higher or lower resolution
  126366. * @param mimeType The MIME type of the screenshot image (default: image/png).
  126367. * Check your browser for supported MIME types
  126368. * @param samples Texture samples (default: 1)
  126369. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  126370. * @param fileName A name for for the downloaded file.
  126371. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  126372. * to the src parameter of an <img> to display it
  126373. */
  126374. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  126375. /**
  126376. * Gets height and width for screenshot size
  126377. * @private
  126378. */
  126379. private static _getScreenshotSize;
  126380. }
  126381. }
  126382. declare module BABYLON {
  126383. /**
  126384. * A cursor which tracks a point on a path
  126385. */
  126386. export class PathCursor {
  126387. private path;
  126388. /**
  126389. * Stores path cursor callbacks for when an onchange event is triggered
  126390. */
  126391. private _onchange;
  126392. /**
  126393. * The value of the path cursor
  126394. */
  126395. value: number;
  126396. /**
  126397. * The animation array of the path cursor
  126398. */
  126399. animations: Animation[];
  126400. /**
  126401. * Initializes the path cursor
  126402. * @param path The path to track
  126403. */
  126404. constructor(path: Path2);
  126405. /**
  126406. * Gets the cursor point on the path
  126407. * @returns A point on the path cursor at the cursor location
  126408. */
  126409. getPoint(): Vector3;
  126410. /**
  126411. * Moves the cursor ahead by the step amount
  126412. * @param step The amount to move the cursor forward
  126413. * @returns This path cursor
  126414. */
  126415. moveAhead(step?: number): PathCursor;
  126416. /**
  126417. * Moves the cursor behind by the step amount
  126418. * @param step The amount to move the cursor back
  126419. * @returns This path cursor
  126420. */
  126421. moveBack(step?: number): PathCursor;
  126422. /**
  126423. * Moves the cursor by the step amount
  126424. * If the step amount is greater than one, an exception is thrown
  126425. * @param step The amount to move the cursor
  126426. * @returns This path cursor
  126427. */
  126428. move(step: number): PathCursor;
  126429. /**
  126430. * Ensures that the value is limited between zero and one
  126431. * @returns This path cursor
  126432. */
  126433. private ensureLimits;
  126434. /**
  126435. * Runs onchange callbacks on change (used by the animation engine)
  126436. * @returns This path cursor
  126437. */
  126438. private raiseOnChange;
  126439. /**
  126440. * Executes a function on change
  126441. * @param f A path cursor onchange callback
  126442. * @returns This path cursor
  126443. */
  126444. onchange(f: (cursor: PathCursor) => void): PathCursor;
  126445. }
  126446. }
  126447. declare module BABYLON {
  126448. /** @hidden */
  126449. export var blurPixelShader: {
  126450. name: string;
  126451. shader: string;
  126452. };
  126453. }
  126454. declare module BABYLON {
  126455. /** @hidden */
  126456. export var pointCloudVertexDeclaration: {
  126457. name: string;
  126458. shader: string;
  126459. };
  126460. }
  126461. // Mixins
  126462. interface Window {
  126463. mozIndexedDB: IDBFactory;
  126464. webkitIndexedDB: IDBFactory;
  126465. msIndexedDB: IDBFactory;
  126466. webkitURL: typeof URL;
  126467. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  126468. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  126469. WebGLRenderingContext: WebGLRenderingContext;
  126470. MSGesture: MSGesture;
  126471. CANNON: any;
  126472. AudioContext: AudioContext;
  126473. webkitAudioContext: AudioContext;
  126474. PointerEvent: any;
  126475. Math: Math;
  126476. Uint8Array: Uint8ArrayConstructor;
  126477. Float32Array: Float32ArrayConstructor;
  126478. mozURL: typeof URL;
  126479. msURL: typeof URL;
  126480. VRFrameData: any; // WebVR, from specs 1.1
  126481. DracoDecoderModule: any;
  126482. setImmediate(handler: (...args: any[]) => void): number;
  126483. }
  126484. interface HTMLCanvasElement {
  126485. requestPointerLock(): void;
  126486. msRequestPointerLock?(): void;
  126487. mozRequestPointerLock?(): void;
  126488. webkitRequestPointerLock?(): void;
  126489. /** Track wether a record is in progress */
  126490. isRecording: boolean;
  126491. /** Capture Stream method defined by some browsers */
  126492. captureStream(fps?: number): MediaStream;
  126493. }
  126494. interface CanvasRenderingContext2D {
  126495. msImageSmoothingEnabled: boolean;
  126496. }
  126497. interface MouseEvent {
  126498. mozMovementX: number;
  126499. mozMovementY: number;
  126500. webkitMovementX: number;
  126501. webkitMovementY: number;
  126502. msMovementX: number;
  126503. msMovementY: number;
  126504. }
  126505. interface Navigator {
  126506. mozGetVRDevices: (any: any) => any;
  126507. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126508. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126509. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126510. webkitGetGamepads(): Gamepad[];
  126511. msGetGamepads(): Gamepad[];
  126512. webkitGamepads(): Gamepad[];
  126513. }
  126514. interface HTMLVideoElement {
  126515. mozSrcObject: any;
  126516. }
  126517. interface Math {
  126518. fround(x: number): number;
  126519. imul(a: number, b: number): number;
  126520. }
  126521. interface WebGLRenderingContext {
  126522. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  126523. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  126524. vertexAttribDivisor(index: number, divisor: number): void;
  126525. createVertexArray(): any;
  126526. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  126527. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  126528. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  126529. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  126530. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  126531. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  126532. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  126533. // Queries
  126534. createQuery(): WebGLQuery;
  126535. deleteQuery(query: WebGLQuery): void;
  126536. beginQuery(target: number, query: WebGLQuery): void;
  126537. endQuery(target: number): void;
  126538. getQueryParameter(query: WebGLQuery, pname: number): any;
  126539. getQuery(target: number, pname: number): any;
  126540. MAX_SAMPLES: number;
  126541. RGBA8: number;
  126542. READ_FRAMEBUFFER: number;
  126543. DRAW_FRAMEBUFFER: number;
  126544. UNIFORM_BUFFER: number;
  126545. HALF_FLOAT_OES: number;
  126546. RGBA16F: number;
  126547. RGBA32F: number;
  126548. R32F: number;
  126549. RG32F: number;
  126550. RGB32F: number;
  126551. R16F: number;
  126552. RG16F: number;
  126553. RGB16F: number;
  126554. RED: number;
  126555. RG: number;
  126556. R8: number;
  126557. RG8: number;
  126558. UNSIGNED_INT_24_8: number;
  126559. DEPTH24_STENCIL8: number;
  126560. /* Multiple Render Targets */
  126561. drawBuffers(buffers: number[]): void;
  126562. readBuffer(src: number): void;
  126563. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  126564. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  126565. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  126566. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  126567. // Occlusion Query
  126568. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  126569. ANY_SAMPLES_PASSED: number;
  126570. QUERY_RESULT_AVAILABLE: number;
  126571. QUERY_RESULT: number;
  126572. }
  126573. interface WebGLProgram {
  126574. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  126575. }
  126576. interface EXT_disjoint_timer_query {
  126577. QUERY_COUNTER_BITS_EXT: number;
  126578. TIME_ELAPSED_EXT: number;
  126579. TIMESTAMP_EXT: number;
  126580. GPU_DISJOINT_EXT: number;
  126581. QUERY_RESULT_EXT: number;
  126582. QUERY_RESULT_AVAILABLE_EXT: number;
  126583. queryCounterEXT(query: WebGLQuery, target: number): void;
  126584. createQueryEXT(): WebGLQuery;
  126585. beginQueryEXT(target: number, query: WebGLQuery): void;
  126586. endQueryEXT(target: number): void;
  126587. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  126588. deleteQueryEXT(query: WebGLQuery): void;
  126589. }
  126590. interface WebGLUniformLocation {
  126591. _currentState: any;
  126592. }
  126593. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  126594. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  126595. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  126596. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126597. interface WebGLRenderingContext {
  126598. readonly RASTERIZER_DISCARD: number;
  126599. readonly DEPTH_COMPONENT24: number;
  126600. readonly TEXTURE_3D: number;
  126601. readonly TEXTURE_2D_ARRAY: number;
  126602. readonly TEXTURE_COMPARE_FUNC: number;
  126603. readonly TEXTURE_COMPARE_MODE: number;
  126604. readonly COMPARE_REF_TO_TEXTURE: number;
  126605. readonly TEXTURE_WRAP_R: number;
  126606. readonly HALF_FLOAT: number;
  126607. readonly RGB8: number;
  126608. readonly RED_INTEGER: number;
  126609. readonly RG_INTEGER: number;
  126610. readonly RGB_INTEGER: number;
  126611. readonly RGBA_INTEGER: number;
  126612. readonly R8_SNORM: number;
  126613. readonly RG8_SNORM: number;
  126614. readonly RGB8_SNORM: number;
  126615. readonly RGBA8_SNORM: number;
  126616. readonly R8I: number;
  126617. readonly RG8I: number;
  126618. readonly RGB8I: number;
  126619. readonly RGBA8I: number;
  126620. readonly R8UI: number;
  126621. readonly RG8UI: number;
  126622. readonly RGB8UI: number;
  126623. readonly RGBA8UI: number;
  126624. readonly R16I: number;
  126625. readonly RG16I: number;
  126626. readonly RGB16I: number;
  126627. readonly RGBA16I: number;
  126628. readonly R16UI: number;
  126629. readonly RG16UI: number;
  126630. readonly RGB16UI: number;
  126631. readonly RGBA16UI: number;
  126632. readonly R32I: number;
  126633. readonly RG32I: number;
  126634. readonly RGB32I: number;
  126635. readonly RGBA32I: number;
  126636. readonly R32UI: number;
  126637. readonly RG32UI: number;
  126638. readonly RGB32UI: number;
  126639. readonly RGBA32UI: number;
  126640. readonly RGB10_A2UI: number;
  126641. readonly R11F_G11F_B10F: number;
  126642. readonly RGB9_E5: number;
  126643. readonly RGB10_A2: number;
  126644. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  126645. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  126646. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  126647. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  126648. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  126649. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  126650. 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;
  126651. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  126652. readonly TRANSFORM_FEEDBACK: number;
  126653. readonly INTERLEAVED_ATTRIBS: number;
  126654. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  126655. createTransformFeedback(): WebGLTransformFeedback;
  126656. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  126657. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  126658. beginTransformFeedback(primitiveMode: number): void;
  126659. endTransformFeedback(): void;
  126660. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  126661. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126662. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126663. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126664. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  126665. }
  126666. interface ImageBitmap {
  126667. readonly width: number;
  126668. readonly height: number;
  126669. close(): void;
  126670. }
  126671. interface WebGLQuery extends WebGLObject {
  126672. }
  126673. declare var WebGLQuery: {
  126674. prototype: WebGLQuery;
  126675. new(): WebGLQuery;
  126676. };
  126677. interface WebGLSampler extends WebGLObject {
  126678. }
  126679. declare var WebGLSampler: {
  126680. prototype: WebGLSampler;
  126681. new(): WebGLSampler;
  126682. };
  126683. interface WebGLSync extends WebGLObject {
  126684. }
  126685. declare var WebGLSync: {
  126686. prototype: WebGLSync;
  126687. new(): WebGLSync;
  126688. };
  126689. interface WebGLTransformFeedback extends WebGLObject {
  126690. }
  126691. declare var WebGLTransformFeedback: {
  126692. prototype: WebGLTransformFeedback;
  126693. new(): WebGLTransformFeedback;
  126694. };
  126695. interface WebGLVertexArrayObject extends WebGLObject {
  126696. }
  126697. declare var WebGLVertexArrayObject: {
  126698. prototype: WebGLVertexArrayObject;
  126699. new(): WebGLVertexArrayObject;
  126700. };
  126701. // Type definitions for WebVR API
  126702. // Project: https://w3c.github.io/webvr/
  126703. // Definitions by: six a <https://github.com/lostfictions>
  126704. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126705. interface VRDisplay extends EventTarget {
  126706. /**
  126707. * Dictionary of capabilities describing the VRDisplay.
  126708. */
  126709. readonly capabilities: VRDisplayCapabilities;
  126710. /**
  126711. * z-depth defining the far plane of the eye view frustum
  126712. * enables mapping of values in the render target depth
  126713. * attachment to scene coordinates. Initially set to 10000.0.
  126714. */
  126715. depthFar: number;
  126716. /**
  126717. * z-depth defining the near plane of the eye view frustum
  126718. * enables mapping of values in the render target depth
  126719. * attachment to scene coordinates. Initially set to 0.01.
  126720. */
  126721. depthNear: number;
  126722. /**
  126723. * An identifier for this distinct VRDisplay. Used as an
  126724. * association point in the Gamepad API.
  126725. */
  126726. readonly displayId: number;
  126727. /**
  126728. * A display name, a user-readable name identifying it.
  126729. */
  126730. readonly displayName: string;
  126731. readonly isConnected: boolean;
  126732. readonly isPresenting: boolean;
  126733. /**
  126734. * If this VRDisplay supports room-scale experiences, the optional
  126735. * stage attribute contains details on the room-scale parameters.
  126736. */
  126737. readonly stageParameters: VRStageParameters | null;
  126738. /**
  126739. * Passing the value returned by `requestAnimationFrame` to
  126740. * `cancelAnimationFrame` will unregister the callback.
  126741. * @param handle Define the hanle of the request to cancel
  126742. */
  126743. cancelAnimationFrame(handle: number): void;
  126744. /**
  126745. * Stops presenting to the VRDisplay.
  126746. * @returns a promise to know when it stopped
  126747. */
  126748. exitPresent(): Promise<void>;
  126749. /**
  126750. * Return the current VREyeParameters for the given eye.
  126751. * @param whichEye Define the eye we want the parameter for
  126752. * @returns the eye parameters
  126753. */
  126754. getEyeParameters(whichEye: string): VREyeParameters;
  126755. /**
  126756. * Populates the passed VRFrameData with the information required to render
  126757. * the current frame.
  126758. * @param frameData Define the data structure to populate
  126759. * @returns true if ok otherwise false
  126760. */
  126761. getFrameData(frameData: VRFrameData): boolean;
  126762. /**
  126763. * Get the layers currently being presented.
  126764. * @returns the list of VR layers
  126765. */
  126766. getLayers(): VRLayer[];
  126767. /**
  126768. * Return a VRPose containing the future predicted pose of the VRDisplay
  126769. * when the current frame will be presented. The value returned will not
  126770. * change until JavaScript has returned control to the browser.
  126771. *
  126772. * The VRPose will contain the position, orientation, velocity,
  126773. * and acceleration of each of these properties.
  126774. * @returns the pose object
  126775. */
  126776. getPose(): VRPose;
  126777. /**
  126778. * Return the current instantaneous pose of the VRDisplay, with no
  126779. * prediction applied.
  126780. * @returns the current instantaneous pose
  126781. */
  126782. getImmediatePose(): VRPose;
  126783. /**
  126784. * The callback passed to `requestAnimationFrame` will be called
  126785. * any time a new frame should be rendered. When the VRDisplay is
  126786. * presenting the callback will be called at the native refresh
  126787. * rate of the HMD. When not presenting this function acts
  126788. * identically to how window.requestAnimationFrame acts. Content should
  126789. * make no assumptions of frame rate or vsync behavior as the HMD runs
  126790. * asynchronously from other displays and at differing refresh rates.
  126791. * @param callback Define the eaction to run next frame
  126792. * @returns the request handle it
  126793. */
  126794. requestAnimationFrame(callback: FrameRequestCallback): number;
  126795. /**
  126796. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  126797. * Repeat calls while already presenting will update the VRLayers being displayed.
  126798. * @param layers Define the list of layer to present
  126799. * @returns a promise to know when the request has been fulfilled
  126800. */
  126801. requestPresent(layers: VRLayer[]): Promise<void>;
  126802. /**
  126803. * Reset the pose for this display, treating its current position and
  126804. * orientation as the "origin/zero" values. VRPose.position,
  126805. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  126806. * updated when calling resetPose(). This should be called in only
  126807. * sitting-space experiences.
  126808. */
  126809. resetPose(): void;
  126810. /**
  126811. * The VRLayer provided to the VRDisplay will be captured and presented
  126812. * in the HMD. Calling this function has the same effect on the source
  126813. * canvas as any other operation that uses its source image, and canvases
  126814. * created without preserveDrawingBuffer set to true will be cleared.
  126815. * @param pose Define the pose to submit
  126816. */
  126817. submitFrame(pose?: VRPose): void;
  126818. }
  126819. declare var VRDisplay: {
  126820. prototype: VRDisplay;
  126821. new(): VRDisplay;
  126822. };
  126823. interface VRLayer {
  126824. leftBounds?: number[] | Float32Array | null;
  126825. rightBounds?: number[] | Float32Array | null;
  126826. source?: HTMLCanvasElement | null;
  126827. }
  126828. interface VRDisplayCapabilities {
  126829. readonly canPresent: boolean;
  126830. readonly hasExternalDisplay: boolean;
  126831. readonly hasOrientation: boolean;
  126832. readonly hasPosition: boolean;
  126833. readonly maxLayers: number;
  126834. }
  126835. interface VREyeParameters {
  126836. /** @deprecated */
  126837. readonly fieldOfView: VRFieldOfView;
  126838. readonly offset: Float32Array;
  126839. readonly renderHeight: number;
  126840. readonly renderWidth: number;
  126841. }
  126842. interface VRFieldOfView {
  126843. readonly downDegrees: number;
  126844. readonly leftDegrees: number;
  126845. readonly rightDegrees: number;
  126846. readonly upDegrees: number;
  126847. }
  126848. interface VRFrameData {
  126849. readonly leftProjectionMatrix: Float32Array;
  126850. readonly leftViewMatrix: Float32Array;
  126851. readonly pose: VRPose;
  126852. readonly rightProjectionMatrix: Float32Array;
  126853. readonly rightViewMatrix: Float32Array;
  126854. readonly timestamp: number;
  126855. }
  126856. interface VRPose {
  126857. readonly angularAcceleration: Float32Array | null;
  126858. readonly angularVelocity: Float32Array | null;
  126859. readonly linearAcceleration: Float32Array | null;
  126860. readonly linearVelocity: Float32Array | null;
  126861. readonly orientation: Float32Array | null;
  126862. readonly position: Float32Array | null;
  126863. readonly timestamp: number;
  126864. }
  126865. interface VRStageParameters {
  126866. sittingToStandingTransform?: Float32Array;
  126867. sizeX?: number;
  126868. sizeY?: number;
  126869. }
  126870. interface Navigator {
  126871. getVRDisplays(): Promise<VRDisplay[]>;
  126872. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  126873. }
  126874. interface Window {
  126875. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  126876. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  126877. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  126878. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126879. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126880. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  126881. }
  126882. interface Gamepad {
  126883. readonly displayId: number;
  126884. }
  126885. type XRSessionMode =
  126886. | "inline"
  126887. | "immersive-vr"
  126888. | "immersive-ar";
  126889. type XRReferenceSpaceType =
  126890. | "viewer"
  126891. | "local"
  126892. | "local-floor"
  126893. | "bounded-floor"
  126894. | "unbounded";
  126895. type XREnvironmentBlendMode =
  126896. | "opaque"
  126897. | "additive"
  126898. | "alpha-blend";
  126899. type XRVisibilityState =
  126900. | "visible"
  126901. | "visible-blurred"
  126902. | "hidden";
  126903. type XRHandedness =
  126904. | "none"
  126905. | "left"
  126906. | "right";
  126907. type XRTargetRayMode =
  126908. | "gaze"
  126909. | "tracked-pointer"
  126910. | "screen";
  126911. type XREye =
  126912. | "none"
  126913. | "left"
  126914. | "right";
  126915. interface XRSpace extends EventTarget {
  126916. }
  126917. interface XRRenderState {
  126918. depthNear?: number;
  126919. depthFar?: number;
  126920. inlineVerticalFieldOfView?: number;
  126921. baseLayer?: XRWebGLLayer;
  126922. }
  126923. interface XRInputSource {
  126924. handedness: XRHandedness;
  126925. targetRayMode: XRTargetRayMode;
  126926. targetRaySpace: XRSpace;
  126927. gripSpace: XRSpace | undefined;
  126928. gamepad: Gamepad | undefined;
  126929. profiles: Array<string>;
  126930. }
  126931. interface XRSession {
  126932. addEventListener: Function;
  126933. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126934. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  126935. requestAnimationFrame: Function;
  126936. end(): Promise<void>;
  126937. renderState: XRRenderState;
  126938. inputSources: Array<XRInputSource>;
  126939. }
  126940. interface XRReferenceSpace extends XRSpace {
  126941. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  126942. onreset: any;
  126943. }
  126944. interface XRFrame {
  126945. session: XRSession;
  126946. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  126947. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  126948. }
  126949. interface XRViewerPose extends XRPose {
  126950. views: Array<XRView>;
  126951. }
  126952. interface XRPose {
  126953. transform: XRRigidTransform;
  126954. emulatedPosition: boolean;
  126955. }
  126956. declare var XRWebGLLayer: {
  126957. prototype: XRWebGLLayer;
  126958. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  126959. };
  126960. interface XRWebGLLayer {
  126961. framebuffer: WebGLFramebuffer;
  126962. framebufferWidth: number;
  126963. framebufferHeight: number;
  126964. getViewport: Function;
  126965. }
  126966. interface XRRigidTransform {
  126967. position: DOMPointReadOnly;
  126968. orientation: DOMPointReadOnly;
  126969. matrix: Float32Array;
  126970. inverse: XRRigidTransform;
  126971. }
  126972. interface XRView {
  126973. eye: XREye;
  126974. projectionMatrix: Float32Array;
  126975. transform: XRRigidTransform;
  126976. }
  126977. interface XRInputSourceChangeEvent {
  126978. session: XRSession;
  126979. removed: Array<XRInputSource>;
  126980. added: Array<XRInputSource>;
  126981. }